| 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  * Copyright 1999-2001,2004 The Apache Software Foundation.
    00003  *
    00004  * Licensed under the Apache License, Version 2.0 (the "License");
    00005  * you may not use this file except in compliance with the License.
    00006  * You may obtain a copy of the License at
    00007  *
    00008  *      http://www.apache.org/licenses/LICENSE-2.0
    00009  *
    00010  * Unless required by applicable law or agreed to in writing, software
    00011  * distributed under the License is distributed on an "AS IS" BASIS,
    00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013  * See the License for the specific language governing permissions and
    00014  * limitations under the License.
    00015  */
    00016
    00017 /*
    00018  * $Log: XMLElementDecl.hpp,v $
    00019  * Revision 1.12  2004/09/08 13:55:58  peiyongz
    00020  * Apache License Version 2.0
    00021  *
    00022  * Revision 1.11  2003/12/12 18:34:43  peiyongz
    00023  * loadElement/storeElement
    00024  *
    00025  * Revision 1.10  2003/11/27 06:08:18  neilg
    00026  * mark DOMTypeInfo-related methods on XMLElementDecl deprecated since they are not thread-safe
    00027  *
    00028  * Revision 1.9  2003/11/24 05:19:15  neilg
    00029  * update method documentation
    00030  *
    00031  * Revision 1.8  2003/10/10 16:23:29  peiyongz
    00032  * Implementation of Serialization/Deserialization
    00033  *
    00034  * Revision 1.7  2003/05/16 21:36:55  knoaman
    00035  * Memory manager implementation: Modify constructors to pass in the memory manager.
    00036  *
    00037  * Revision 1.6  2003/05/15 18:26:07  knoaman
    00038  * Partial implementation of the configurable memory manager.
    00039  *
    00040  * Revision 1.5  2003/03/07 18:08:10  tng
    00041  * Return a reference instead of void for operator=
    00042  *
    00043  * Revision 1.4  2003/01/29 19:45:35  gareth
    00044  * added api for DOMTypeInfo
    00045  *
    00046  * Revision 1.3  2002/11/04 15:00:21  tng
    00047  * C++ Namespace Support.
    00048  *
    00049  * Revision 1.2  2002/08/20 16:55:33  tng
    00050  * [Bug 6251] Info during compilation.
    00051  *
    00052  * Revision 1.1.1.1  2002/02/01 22:21:51  peiyongz
    00053  * sane_include
    00054  *
    00055  * Revision 1.18  2001/08/21 16:06:10  tng
    00056  * Schema: Unique Particle Attribution Constraint Checking.
    00057  *
    00058  * Revision 1.17  2001/07/24 18:30:47  knoaman
    00059  * Added support for <group> + extra constraint checking for complexType
    00060  *
    00061  * Revision 1.16  2001/06/21 14:25:28  knoaman
    00062  * Fix for bug 1946
    00063  *
    00064  * Revision 1.15  2001/05/11 13:25:32  tng
    00065  * Copyright update.
    00066  *
    00067  * Revision 1.14  2001/05/03 20:34:22  tng
    00068  * Schema: SchemaValidator update
    00069  *
    00070  * Revision 1.13  2001/04/19 18:16:52  tng
    00071  * Schema: SchemaValidator update, and use QName in Content Model
    00072  *
    00073  * Revision 1.12  2001/03/21 21:56:02  tng
    00074  * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
    00075  *
    00076  * Revision 1.11  2001/03/21 19:29:29  tng
    00077  * Schema: Content Model Updates, by Pei Yong Zhang.
    00078  *
    00079  * Revision 1.10  2001/02/26 19:29:13  tng
    00080  * Schema: add virtual method getURI(), getContentSpec and setContenSpec in XMLElementDecl, and DTDElementDecl.
    00081  *
    00082  * Revision 1.9  2001/02/26 19:21:30  tng
    00083  * Schema: add parameter prefix in findElem and findAttr.
    00084  *
    00085  * Revision 1.8  2000/12/14 18:49:57  tng
    00086  * Fix API document generation warning: "Warning: end of member group without matching begin"
    00087  *
    00088  * Revision 1.7  2000/11/30 18:22:38  andyh
    00089  * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
    00090  * pools already containing some items.  Fixed by Tinny Ng.
    00091  *
    00092  * Revision 1.6  2000/05/11 23:11:32  andyh
    00093  * Add missing validity checks for stand-alone documents, character range
    00094  * and Well-formed parsed entities.  Changes contributed by Sean MacRoibeaird
    00095  * <sean.Macroibeaird@ireland.sun.com>
    00096  *
    00097  * Revision 1.5  2000/02/24 20:00:23  abagchi
    00098  * Swat for removing Log from API docs
    00099  *
    00100  * Revision 1.4  2000/02/16 19:48:56  roddey
    00101  * More documentation updates
    00102  *
    00103  * Revision 1.3  2000/02/15 01:21:30  roddey
    00104  * Some initial documentation improvements. More to come...
    00105  *
    00106  * Revision 1.2  2000/02/06 07:47:48  rahulj
    00107  * Year 2K copyright swat.
    00108  *
    00109  * Revision 1.1.1.1  1999/11/09 01:08:32  twl
    00110  * Initial checkin
    00111  *
    00112  * Revision 1.2  1999/11/08 20:44:38  rahul
    00113  * Swat for adding in Product name and CVS comment log variable.
    00114  *
    00115  */
    00116
    00117 #if !defined(XMLELEMENTDECL_HPP)
    00118 #define XMLELEMENTDECL_HPP
    00119
    00120 #include <xercesc/framework/XMLAttr.hpp>
    00121 #include <xercesc/framework/XMLAttDefList.hpp>
    00122 #include <xercesc/util/XMLString.hpp>
    00123 #include <xercesc/util/PlatformUtils.hpp>
    00124 #include <xercesc/internal/XSerializable.hpp>
    00125
    00126 XERCES_CPP_NAMESPACE_BEGIN
    00127
    00128 class ContentSpecNode;
    00129 class XMLContentModel;
    00130
    00146 class  XMLElementDecl : public XSerializable, public XMemory
    00147 {
    00148  public:
    00149     // -----------------------------------------------------------------------
    00150     //  Class specific types
    00151     //
    00152     //  CreateReasons
    00153     //      This type is used to store how an element declaration got into
    00154     //      the grammar's element pool. They are faulted in for various
    00155     //      reasons.
    00156     //
    00157     //  LookupOpts
    00158     //      These are the values used by the attribute lookup methods.
    00159     //
    00160     //  CharDataOpts
    00161     //      This is used to indicate how this type of element reacts to
    00162     //      character data as content.
    00163     // -----------------------------------------------------------------------
    00164     enum CreateReasons
    00165     {
    00166         NoReason
    00167         , Declared
    00168         , AttList
    00169         , InContentModel
    00170         , AsRootElem
    00171         , JustFaultIn
    00172     };
    00173
    00178     enum LookupOpts
    00179     {
    00180         AddIfNotFound
    00181         , FailIfNotFound
    00182     };
    00183
    00184     enum CharDataOpts
    00185     {
    00186         NoCharData
    00187         , SpacesOk
    00188         , AllCharData
    00189     };
    00190
    00191
    00192     // -----------------------------------------------------------------------
    00193     //  Public static data
    00194     //
    00195     //  fgInvalidElemId
    00196     //      A value to represent an invalid element node id.
    00197     //
    00198     //  fgPCDataElemId
    00199     //      This is the value to use to represent a PCDATA node when an
    00200     //      element id is required.
    00201     //
    00202     //  fgPCDataElemName
    00203     //      This is the value to use to represent a PCDATA node when an
    00204     //      element name is required.
    00205     // -----------------------------------------------------------------------
    00206     static const unsigned int   fgInvalidElemId;
    00207     static const unsigned int   fgPCDataElemId;
    00208     static const XMLCh          fgPCDataElemName[];
    00209
    00210
    00211
    00212     // -----------------------------------------------------------------------
    00213     //  Destructor
    00214     // -----------------------------------------------------------------------
    00217     virtual ~XMLElementDecl();
    00219
    00220
    00221     // -----------------------------------------------------------------------
    00222     //  The virtual element decl interface
    00223     // -----------------------------------------------------------------------
    00224
    00227
    00258     virtual XMLAttDef* findAttr
    00259     (
    00260         const   XMLCh* const    qName
    00261         , const unsigned int    uriId
    00262         , const XMLCh* const    baseName
    00263         , const XMLCh* const    prefix
    00264         , const LookupOpts      options
    00265         ,       bool&           wasAdded
    00266     )   const = 0;
    00267
    00279     virtual XMLAttDefList& getAttDefList() const = 0;
    00280
    00288     virtual CharDataOpts getCharDataOpts() const = 0;
    00289
    00296     virtual bool hasAttDefs() const = 0;
    00297
    00305     virtual bool resetDefs() = 0;
    00306
    00314     virtual const ContentSpecNode* getContentSpec() const = 0;
    00315
    00321     virtual ContentSpecNode* getContentSpec() = 0;
    00322
    00332     virtual void setContentSpec(ContentSpecNode* toAdopt) = 0;
    00333
    00345     virtual XMLContentModel* getContentModel() = 0;
    00346
    00358     virtual void setContentModel(XMLContentModel* const newModelToAdopt) = 0;
    00359
    00372     virtual const XMLCh* getFormattedContentModel ()   const = 0;
    00373
    00375
    00376
    00377     // -----------------------------------------------------------------------
    00378     //  Getter methods
    00379     // -----------------------------------------------------------------------
    00380
    00383
    00391     const XMLCh* getBaseName() const;
    00392     XMLCh* getBaseName();
    00393
    00400     unsigned int getURI() const;
    00401
    00409     const QName* getElementName() const;
    00410     QName* getElementName();
    00411
    00420     const XMLCh* getFullName() const;
    00421
    00433     CreateReasons getCreateReason() const;
    00434
    00444     unsigned int getId() const;
    00445
    00446
    00451     virtual const XMLCh* getDOMTypeInfoUri() const = 0;
    00452
    00457     virtual const XMLCh* getDOMTypeInfoName() const = 0;
    00458
    00459
    00469     bool isDeclared() const;
    00470
    00479     bool isExternal() const;
    00480
    00488     MemoryManager* getMemoryManager() const;
    00489
    00491
    00492
    00493     // -----------------------------------------------------------------------
    00494     //  Setter methods
    00495     // -----------------------------------------------------------------------
    00496
    00499
    00510       void setElementName(const XMLCh* const       prefix
    00511                         , const XMLCh* const       localPart
    00512                         , const int                uriId );
    00513
    00523       void setElementName(const XMLCh* const    rawName
    00524                         , const int             uriId );
    00525
    00534       void setElementName(const QName* const    elementName);
    00535
    00546     void setCreateReason(const CreateReasons newReason);
    00547
    00554     void setId(const unsigned int newId);
    00555
    00556
    00560     void setExternalElemDeclaration(const bool aValue);
    00561
    00563
    00564
    00565     // -----------------------------------------------------------------------
    00566     //  Miscellaneous methods
    00567     // -----------------------------------------------------------------------
    00568
    00571
    00573
    00574     /***
    00575      * Support for Serialization/De-serialization
    00576      ***/
    00577     DECL_XSERIALIZABLE(XMLElementDecl)
    00578
    00579     enum objectType
    00580     {
    00581         Schema
    00582       , DTD
    00583       , UnKnown
    00584     };
    00585
    00586     virtual XMLElementDecl::objectType  getObjectType() const = 0;
    00587
    00588     static void            storeElementDecl(XSerializeEngine&        serEng
    00589                                           , XMLElementDecl*    const element);
    00590
    00591     static XMLElementDecl* loadElementDecl(XSerializeEngine& serEng);
    00592
    00593 protected :
    00594     // -----------------------------------------------------------------------
    00595     //  Hidden constructors
    00596     // -----------------------------------------------------------------------
    00597     XMLElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00598
    00599 private :
    00600     // -----------------------------------------------------------------------
    00601     //  Unimplemented constructors and operators
    00602     // -----------------------------------------------------------------------
    00603     XMLElementDecl(const XMLElementDecl&);
    00604     XMLElementDecl& operator=(const XMLElementDecl&);
    00605
    00606
    00607     // -----------------------------------------------------------------------
    00608     //  Data members
    00609     //
    00610     //  fElementName
    00611     //      This is the name of the element decl.
    00612     //
    00613     //  fCreateReason
    00614     //      We sometimes have to put an element decl object into the elem
    00615     //      decl pool before the element's declaration is seen, such as when
    00616     //      its used in another element's content model or an att list is
    00617     //      seen for it. This flag tells us whether its been declared, and
    00618     //      if not why it had to be created.
    00619     //
    00620     //  fId
    00621     //      The unique id of this element. This is created by the derived
    00622     //      class, or more accurately the grammar that owns the objects
    00623     //      of the derived types. But, since they all have to have them, we
    00624     //      let them all store the id here. It is defaulted to have the
    00625     //      value fgInvalidElem until explicitly set.
    00626     //
    00627     //  fExternalElement
    00628     //      This flag indicates whether or the element was declared externally.
    00629     // -----------------------------------------------------------------------
    00630     MemoryManager*      fMemoryManager;
    00631     QName*              fElementName;
    00632     CreateReasons       fCreateReason;
    00633     unsigned int        fId;
    00634     bool                fExternalElement;
    00635 };
    00636
    00637
    00638 // ---------------------------------------------------------------------------
    00639 //  XMLElementDecl: Getter methods
    00640 // ---------------------------------------------------------------------------
    00641 inline const XMLCh* XMLElementDecl::getBaseName() const
    00642 {
    00643     return fElementName->getLocalPart();
    00644 }
    00645
    00646 inline XMLCh* XMLElementDecl::getBaseName()
    00647 {
    00648     return fElementName->getLocalPart();
    00649 }
    00650
    00651 inline unsigned int XMLElementDecl::getURI() const
    00652 {
    00653     return fElementName->getURI();
    00654 }
    00655
    00656 inline const QName* XMLElementDecl::getElementName() const
    00657 {
    00658     return fElementName;
    00659 }
    00660
    00661 inline QName* XMLElementDecl::getElementName()
    00662 {
    00663     return fElementName;
    00664 }
    00665
    00666 inline const XMLCh* XMLElementDecl::getFullName() const
    00667 {
    00668     return fElementName->getRawName();
    00669 }
    00670
    00671 inline XMLElementDecl::CreateReasons XMLElementDecl::getCreateReason() const
    00672 {
    00673     return fCreateReason;
    00674 }
    00675
    00676 inline unsigned int XMLElementDecl::getId() const
    00677 {
    00678     return fId;
    00679 }
    00680
    00681 inline bool XMLElementDecl::isDeclared() const
    00682 {
    00683     return (fCreateReason == Declared);
    00684 }
    00685
    00686
    00687 inline bool XMLElementDecl::isExternal() const
    00688 {
    00689     return fExternalElement;
    00690 }
    00691
    00692 inline MemoryManager* XMLElementDecl::getMemoryManager() const
    00693 {
    00694     return fMemoryManager;
    00695 }
    00696
    00697
    00698 // ---------------------------------------------------------------------------
    00699 //  XMLElementDecl: Setter methods
    00700 // ---------------------------------------------------------------------------
    00701 inline void
    00702 XMLElementDecl::setCreateReason(const XMLElementDecl::CreateReasons newReason)
    00703 {
    00704     fCreateReason = newReason;
    00705 }
    00706
    00707 inline void XMLElementDecl::setId(const unsigned int newId)
    00708 {
    00709     fId = newId;
    00710 }
    00711
    00712
    00713 inline void XMLElementDecl::setExternalElemDeclaration(const bool aValue)
    00714 {
    00715     fExternalElement = aValue;
    00716 }
    00717
    00718 XERCES_CPP_NAMESPACE_END
    00719
    00720 #endif

Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.