XMLElementDecl.hpp Source File

| API Docs for SAX and DOM |

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# XMLElementDecl.hpp

Go to the documentation of this file.

    00001 /*
    00002  * The Apache Software License, Version 1.1
    00003  *
    00004  * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
    00005  * reserved.
    00006  *
    00007  * Redistribution and use in source and binary forms, with or without
    00008  * modification, are permitted provided that the following conditions
    00009  * are met:
    00010  *
    00011  * 1. Redistributions of source code must retain the above copyright
    00012  *    notice, this list of conditions and the following disclaimer.
    00013  *
    00014  * 2. Redistributions in binary form must reproduce the above copyright
    00015  *    notice, this list of conditions and the following disclaimer in
    00016  *    the documentation and/or other materials provided with the
    00017  *    distribution.
    00018  *
    00019  * 3. The end-user documentation included with the redistribution,
    00020  *    if any, must include the following acknowledgment:
    00021  *       "This product includes software developed by the
    00022  *        Apache Software Foundation (http://www.apache.org/)."
    00023  *    Alternately, this acknowledgment may appear in the software itself,
    00024  *    if and wherever such third-party acknowledgments normally appear.
    00025  *
    00026  * 4. The names "Xerces" and "Apache Software Foundation" must
    00027  *    not be used to endorse or promote products derived from this
    00028  *    software without prior written permission. For written
    00029  *    permission, please contact apache\@apache.org.
    00030  *
    00031  * 5. Products derived from this software may not be called "Apache",
    00032  *    nor may "Apache" appear in their name, without prior written
    00033  *    permission of the Apache Software Foundation.
    00034  *
    00035  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    00036  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    00037  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    00038  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
    00039  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    00040  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    00041  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    00042  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    00043  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    00044  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    00045  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    00046  * SUCH DAMAGE.
    00047  * ====================================================================
    00048  *
    00049  * This software consists of voluntary contributions made by many
    00050  * individuals on behalf of the Apache Software Foundation, and was
    00051  * originally based on software copyright (c) 1999, International
    00052  * Business Machines, Inc., http://www.ibm.com .  For more information
    00053  * on the Apache Software Foundation, please see
    00054  * <http://www.apache.org/>.
    00055  */
    00056
    00057 /*
    00058  * $Log: XMLElementDecl.hpp,v $
    00059  * Revision 1.7  2003/05/16 21:36:55  knoaman
    00060  * Memory manager implementation: Modify constructors to pass in the memory manager.
    00061  *
    00062  * Revision 1.6  2003/05/15 18:26:07  knoaman
    00063  * Partial implementation of the configurable memory manager.
    00064  *
    00065  * Revision 1.5  2003/03/07 18:08:10  tng
    00066  * Return a reference instead of void for operator=
    00067  *
    00068  * Revision 1.4  2003/01/29 19:45:35  gareth
    00069  * added api for DOMTypeInfo
    00070  *
    00071  * Revision 1.3  2002/11/04 15:00:21  tng
    00072  * C++ Namespace Support.
    00073  *
    00074  * Revision 1.2  2002/08/20 16:55:33  tng
    00075  * [Bug 6251] Info during compilation.
    00076  *
    00077  * Revision 1.1.1.1  2002/02/01 22:21:51  peiyongz
    00078  * sane_include
    00079  *
    00080  * Revision 1.18  2001/08/21 16:06:10  tng
    00081  * Schema: Unique Particle Attribution Constraint Checking.
    00082  *
    00083  * Revision 1.17  2001/07/24 18:30:47  knoaman
    00084  * Added support for <group> + extra constraint checking for complexType
    00085  *
    00086  * Revision 1.16  2001/06/21 14:25:28  knoaman
    00087  * Fix for bug 1946
    00088  *
    00089  * Revision 1.15  2001/05/11 13:25:32  tng
    00090  * Copyright update.
    00091  *
    00092  * Revision 1.14  2001/05/03 20:34:22  tng
    00093  * Schema: SchemaValidator update
    00094  *
    00095  * Revision 1.13  2001/04/19 18:16:52  tng
    00096  * Schema: SchemaValidator update, and use QName in Content Model
    00097  *
    00098  * Revision 1.12  2001/03/21 21:56:02  tng
    00099  * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
    00100  *
    00101  * Revision 1.11  2001/03/21 19:29:29  tng
    00102  * Schema: Content Model Updates, by Pei Yong Zhang.
    00103  *
    00104  * Revision 1.10  2001/02/26 19:29:13  tng
    00105  * Schema: add virtual method getURI(), getContentSpec and setContenSpec in XMLElementDecl, and DTDElementDecl.
    00106  *
    00107  * Revision 1.9  2001/02/26 19:21:30  tng
    00108  * Schema: add parameter prefix in findElem and findAttr.
    00109  *
    00110  * Revision 1.8  2000/12/14 18:49:57  tng
    00111  * Fix API document generation warning: "Warning: end of member group without matching begin"
    00112  *
    00113  * Revision 1.7  2000/11/30 18:22:38  andyh
    00114  * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
    00115  * pools already containing some items.  Fixed by Tinny Ng.
    00116  *
    00117  * Revision 1.6  2000/05/11 23:11:32  andyh
    00118  * Add missing validity checks for stand-alone documents, character range
    00119  * and Well-formed parsed entities.  Changes contributed by Sean MacRoibeaird
    00120  * <sean.Macroibeaird@ireland.sun.com>
    00121  *
    00122  * Revision 1.5  2000/02/24 20:00:23  abagchi
    00123  * Swat for removing Log from API docs
    00124  *
    00125  * Revision 1.4  2000/02/16 19:48:56  roddey
    00126  * More documentation updates
    00127  *
    00128  * Revision 1.3  2000/02/15 01:21:30  roddey
    00129  * Some initial documentation improvements. More to come...
    00130  *
    00131  * Revision 1.2  2000/02/06 07:47:48  rahulj
    00132  * Year 2K copyright swat.
    00133  *
    00134  * Revision 1.1.1.1  1999/11/09 01:08:32  twl
    00135  * Initial checkin
    00136  *
    00137  * Revision 1.2  1999/11/08 20:44:38  rahul
    00138  * Swat for adding in Product name and CVS comment log variable.
    00139  *
    00140  */
    00141
    00142 #if !defined(XMLELEMENTDECL_HPP)
    00143 #define XMLELEMENTDECL_HPP
    00144
    00145 #include <xercesc/framework/XMLAttr.hpp>
    00146 #include <xercesc/framework/XMLAttDefList.hpp>
    00147 #include <xercesc/util/XMLString.hpp>
    00148 #include <xercesc/util/PlatformUtils.hpp>
    00149
    00150 XERCES_CPP_NAMESPACE_BEGIN
    00151
    00152 class ContentSpecNode;
    00153 class XMLContentModel;
    00154
    00170 class  XMLElementDecl : public XMemory
    00171 {
    00172  public:
    00173     // -----------------------------------------------------------------------
    00174     //  Class specific types
    00175     //
    00176     //  CreateReasons
    00177     //      This type is used to store how an element declaration got into
    00178     //      the grammar's element pool. They are faulted in for various
    00179     //      reasons.
    00180     //
    00181     //  LookupOpts
    00182     //      These are the values used by the attribute lookup methods.
    00183     //
    00184     //  CharDataOpts
    00185     //      This is used to indicate how this type of element reacts to
    00186     //      character data as content.
    00187     // -----------------------------------------------------------------------
    00188     enum CreateReasons
    00189     {
    00190         NoReason
    00191         , Declared
    00192         , AttList
    00193         , InContentModel
    00194         , AsRootElem
    00195         , JustFaultIn
    00196     };
    00197
    00198     enum LookupOpts
    00199     {
    00200         AddIfNotFound
    00201         , FailIfNotFound
    00202     };
    00203
    00204     enum CharDataOpts
    00205     {
    00206         NoCharData
    00207         , SpacesOk
    00208         , AllCharData
    00209     };
    00210
    00211
    00212     // -----------------------------------------------------------------------
    00213     //  Public static data
    00214     //
    00215     //  fgInvalidElemId
    00216     //      A value to represent an invalid element node id.
    00217     //
    00218     //  fgPCDataElemId
    00219     //      This is the value to use to represent a PCDATA node when an
    00220     //      element id is required.
    00221     //
    00222     //  fgPCDataElemName
    00223     //      This is the value to use to represent a PCDATA node when an
    00224     //      element name is required.
    00225     // -----------------------------------------------------------------------
    00226     static const unsigned int   fgInvalidElemId;
    00227     static const unsigned int   fgPCDataElemId;
    00228     static const XMLCh          fgPCDataElemName[];
    00229
    00230
    00231
    00232     // -----------------------------------------------------------------------
    00233     //  Destructor
    00234     // -----------------------------------------------------------------------
    00237     virtual ~XMLElementDecl();
    00239
    00240
    00241     // -----------------------------------------------------------------------
    00242     //  The virtual element decl interface
    00243     // -----------------------------------------------------------------------
    00244
    00247
    00276     virtual XMLAttDef* findAttr
    00277     (
    00278         const   XMLCh* const    qName
    00279         , const unsigned int    uriId
    00280         , const XMLCh* const    baseName
    00281         , const XMLCh* const    prefix
    00282         , const LookupOpts      options
    00283         ,       bool&           wasAdded
    00284     )   const = 0;
    00285
    00297     virtual XMLAttDefList& getAttDefList() const = 0;
    00298
    00306     virtual CharDataOpts getCharDataOpts() const = 0;
    00307
    00314     virtual bool hasAttDefs() const = 0;
    00315
    00323     virtual bool resetDefs() = 0;
    00324
    00332     virtual const ContentSpecNode* getContentSpec() const = 0;
    00333
    00339     virtual ContentSpecNode* getContentSpec() = 0;
    00340
    00350     virtual void setContentSpec(ContentSpecNode* toAdopt) = 0;
    00351
    00363     virtual XMLContentModel* getContentModel() = 0;
    00364
    00376     virtual void setContentModel(XMLContentModel* const newModelToAdopt) = 0;
    00377
    00390     virtual const XMLCh* getFormattedContentModel ()   const = 0;
    00391
    00393
    00394
    00395     // -----------------------------------------------------------------------
    00396     //  Getter methods
    00397     // -----------------------------------------------------------------------
    00398
    00401
    00409     const XMLCh* getBaseName() const;
    00410     XMLCh* getBaseName();
    00411
    00418     unsigned int getURI() const;
    00419
    00427     const QName* getElementName() const;
    00428     QName* getElementName();
    00429
    00438     const XMLCh* getFullName() const;
    00439
    00451     CreateReasons getCreateReason() const;
    00452
    00462     unsigned int getId() const;
    00463
    00464
    00468     virtual const XMLCh* getDOMTypeInfoUri() const = 0;
    00469
    00473     virtual const XMLCh* getDOMTypeInfoName() const = 0;
    00474
    00475
    00485     bool isDeclared() const;
    00486
    00495     bool isExternal() const;
    00496
    00504     MemoryManager* getMemoryManager() const;
    00505
    00507
    00508
    00509     // -----------------------------------------------------------------------
    00510     //  Setter methods
    00511     // -----------------------------------------------------------------------
    00512
    00515
    00526       void setElementName(const XMLCh* const       prefix
    00527                         , const XMLCh* const       localPart
    00528                         , const int                uriId );
    00529
    00539       void setElementName(const XMLCh* const    rawName
    00540                         , const int             uriId );
    00541
    00550       void setElementName(const QName* const    elementName);
    00551
    00562     void setCreateReason(const CreateReasons newReason);
    00563
    00570     void setId(const unsigned int newId);
    00571
    00572
    00576     void setExternalElemDeclaration(const bool aValue);
    00577
    00579
    00580
    00581     // -----------------------------------------------------------------------
    00582     //  Miscellaneous methods
    00583     // -----------------------------------------------------------------------
    00584
    00587
    00589
    00590
    00591 protected :
    00592     // -----------------------------------------------------------------------
    00593     //  Hidden constructors
    00594     // -----------------------------------------------------------------------
    00595     XMLElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00596
    00597 private :
    00598     // -----------------------------------------------------------------------
    00599     //  Unimplemented constructors and operators
    00600     // -----------------------------------------------------------------------
    00601     XMLElementDecl(const XMLElementDecl&);
    00602     XMLElementDecl& operator=(const XMLElementDecl&);
    00603
    00604
    00605     // -----------------------------------------------------------------------
    00606     //  Data members
    00607     //
    00608     //  fElementName
    00609     //      This is the name of the element decl.
    00610     //
    00611     //  fCreateReason
    00612     //      We sometimes have to put an element decl object into the elem
    00613     //      decl pool before the element's declaration is seen, such as when
    00614     //      its used in another element's content model or an att list is
    00615     //      seen for it. This flag tells us whether its been declared, and
    00616     //      if not why it had to be created.
    00617     //
    00618     //  fId
    00619     //      The unique id of this element. This is created by the derived
    00620     //      class, or more accurately the grammar that owns the objects
    00621     //      of the derived types. But, since they all have to have them, we
    00622     //      let them all store the id here. It is defaulted to have the
    00623     //      value fgInvalidElem until explicitly set.
    00624     //
    00625     //  fExternalElement
    00626     //      This flag indicates whether or the element was declared externally.
    00627     // -----------------------------------------------------------------------
    00628     MemoryManager*      fMemoryManager;
    00629     QName*              fElementName;
    00630     CreateReasons       fCreateReason;
    00631     unsigned int        fId;
    00632     bool                fExternalElement;
    00633 };
    00634
    00635
    00636 // ---------------------------------------------------------------------------
    00637 //  XMLElementDecl: Getter methods
    00638 // ---------------------------------------------------------------------------
    00639 inline const XMLCh* XMLElementDecl::getBaseName() const
    00640 {
    00641     return fElementName->getLocalPart();
    00642 }
    00643
    00644 inline XMLCh* XMLElementDecl::getBaseName()
    00645 {
    00646     return fElementName->getLocalPart();
    00647 }
    00648
    00649 inline unsigned int XMLElementDecl::getURI() const
    00650 {
    00651     return fElementName->getURI();
    00652 }
    00653
    00654 inline const QName* XMLElementDecl::getElementName() const
    00655 {
    00656     return fElementName;
    00657 }
    00658
    00659 inline QName* XMLElementDecl::getElementName()
    00660 {
    00661     return fElementName;
    00662 }
    00663
    00664 inline const XMLCh* XMLElementDecl::getFullName() const
    00665 {
    00666     return fElementName->getRawName();
    00667 }
    00668
    00669 inline XMLElementDecl::CreateReasons XMLElementDecl::getCreateReason() const
    00670 {
    00671     return fCreateReason;
    00672 }
    00673
    00674 inline unsigned int XMLElementDecl::getId() const
    00675 {
    00676     return fId;
    00677 }
    00678
    00679 inline bool XMLElementDecl::isDeclared() const
    00680 {
    00681     return (fCreateReason == Declared);
    00682 }
    00683
    00684
    00685 inline bool XMLElementDecl::isExternal() const
    00686 {
    00687     return fExternalElement;
    00688 }
    00689
    00690 inline MemoryManager* XMLElementDecl::getMemoryManager() const
    00691 {
    00692     return fMemoryManager;
    00693 }
    00694
    00695
    00696 // ---------------------------------------------------------------------------
    00697 //  XMLElementDecl: Setter methods
    00698 // ---------------------------------------------------------------------------
    00699 inline void
    00700 XMLElementDecl::setCreateReason(const XMLElementDecl::CreateReasons newReason)
    00701 {
    00702     fCreateReason = newReason;
    00703 }
    00704
    00705 inline void XMLElementDecl::setId(const unsigned int newId)
    00706 {
    00707     fId = newId;
    00708 }
    00709
    00710
    00711 inline void XMLElementDecl::setExternalElemDeclaration(const bool aValue)
    00712 {
    00713     fExternalElement = aValue;
    00714 }
    00715
    00716 XERCES_CPP_NAMESPACE_END
    00717
    00718 #endif

Copyright © 2000 The Apache Software Foundation. All Rights Reserved.