| API Docs for SAX and DOM |

Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

# 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  * $Id: XMLElementDecl.hpp 191054 2005-06-17 02:56:35Z jberry $
    00019  */
    00020
    00021 #if !defined(XMLELEMENTDECL_HPP)
    00022 #define XMLELEMENTDECL_HPP
    00023
    00024 #include <xercesc/framework/XMLAttr.hpp>
    00025 #include <xercesc/framework/XMLAttDefList.hpp>
    00026 #include <xercesc/util/XMLString.hpp>
    00027 #include <xercesc/util/PlatformUtils.hpp>
    00028 #include <xercesc/internal/XSerializable.hpp>
    00029
    00030 XERCES_CPP_NAMESPACE_BEGIN
    00031
    00032 class ContentSpecNode;
    00033 class XMLContentModel;
    00034
    00050 class  XMLElementDecl : public XSerializable, public XMemory
    00051 {
    00052  public:
    00053     // -----------------------------------------------------------------------
    00054     //  Class specific types
    00055     //
    00056     //  CreateReasons
    00057     //      This type is used to store how an element declaration got into
    00058     //      the grammar's element pool. They are faulted in for various
    00059     //      reasons.
    00060     //
    00061     //  LookupOpts
    00062     //      These are the values used by the attribute lookup methods.
    00063     //
    00064     //  CharDataOpts
    00065     //      This is used to indicate how this type of element reacts to
    00066     //      character data as content.
    00067     // -----------------------------------------------------------------------
    00068     enum CreateReasons
    00069     {
    00070         NoReason
    00071         , Declared
    00072         , AttList
    00073         , InContentModel
    00074         , AsRootElem
    00075         , JustFaultIn
    00076     };
    00077
    00082     enum LookupOpts
    00083     {
    00084         AddIfNotFound
    00085         , FailIfNotFound
    00086     };
    00087
    00088     enum CharDataOpts
    00089     {
    00090         NoCharData
    00091         , SpacesOk
    00092         , AllCharData
    00093     };
    00094
    00095
    00096     // -----------------------------------------------------------------------
    00097     //  Public static data
    00098     //
    00099     //  fgInvalidElemId
    00100     //      A value to represent an invalid element node id.
    00101     //
    00102     //  fgPCDataElemId
    00103     //      This is the value to use to represent a PCDATA node when an
    00104     //      element id is required.
    00105     //
    00106     //  fgPCDataElemName
    00107     //      This is the value to use to represent a PCDATA node when an
    00108     //      element name is required.
    00109     // -----------------------------------------------------------------------
    00110     static const unsigned int   fgInvalidElemId;
    00111     static const unsigned int   fgPCDataElemId;
    00112     static const XMLCh          fgPCDataElemName[];
    00113
    00114
    00115
    00116     // -----------------------------------------------------------------------
    00117     //  Destructor
    00118     // -----------------------------------------------------------------------
    00121     virtual ~XMLElementDecl();
    00123
    00124
    00125     // -----------------------------------------------------------------------
    00126     //  The virtual element decl interface
    00127     // -----------------------------------------------------------------------
    00128
    00131
    00162     virtual XMLAttDef* findAttr
    00163     (
    00164         const   XMLCh* const    qName
    00165         , const unsigned int    uriId
    00166         , const XMLCh* const    baseName
    00167         , const XMLCh* const    prefix
    00168         , const LookupOpts      options
    00169         ,       bool&           wasAdded
    00170     )   const = 0;
    00171
    00183     virtual XMLAttDefList& getAttDefList() const = 0;
    00184
    00192     virtual CharDataOpts getCharDataOpts() const = 0;
    00193
    00200     virtual bool hasAttDefs() const = 0;
    00201
    00209     virtual bool resetDefs() = 0;
    00210
    00218     virtual const ContentSpecNode* getContentSpec() const = 0;
    00219
    00225     virtual ContentSpecNode* getContentSpec() = 0;
    00226
    00236     virtual void setContentSpec(ContentSpecNode* toAdopt) = 0;
    00237
    00249     virtual XMLContentModel* getContentModel() = 0;
    00250
    00262     virtual void setContentModel(XMLContentModel* const newModelToAdopt) = 0;
    00263
    00276     virtual const XMLCh* getFormattedContentModel ()   const = 0;
    00277
    00279
    00280
    00281     // -----------------------------------------------------------------------
    00282     //  Getter methods
    00283     // -----------------------------------------------------------------------
    00284
    00287
    00295     const XMLCh* getBaseName() const;
    00296     XMLCh* getBaseName();
    00297
    00304     unsigned int getURI() const;
    00305
    00313     const QName* getElementName() const;
    00314     QName* getElementName();
    00315
    00324     const XMLCh* getFullName() const;
    00325
    00337     CreateReasons getCreateReason() const;
    00338
    00348     unsigned int getId() const;
    00349
    00350
    00355     virtual const XMLCh* getDOMTypeInfoUri() const = 0;
    00356
    00361     virtual const XMLCh* getDOMTypeInfoName() const = 0;
    00362
    00363
    00373     bool isDeclared() const;
    00374
    00383     bool isExternal() const;
    00384
    00392     MemoryManager* getMemoryManager() const;
    00393
    00395
    00396
    00397     // -----------------------------------------------------------------------
    00398     //  Setter methods
    00399     // -----------------------------------------------------------------------
    00400
    00403
    00414       void setElementName(const XMLCh* const       prefix
    00415                         , const XMLCh* const       localPart
    00416                         , const int                uriId );
    00417
    00427       void setElementName(const XMLCh* const    rawName
    00428                         , const int             uriId );
    00429
    00438       void setElementName(const QName* const    elementName);
    00439
    00450     void setCreateReason(const CreateReasons newReason);
    00451
    00458     void setId(const unsigned int newId);
    00459
    00460
    00464     void setExternalElemDeclaration(const bool aValue);
    00465
    00467
    00468
    00469     // -----------------------------------------------------------------------
    00470     //  Miscellaneous methods
    00471     // -----------------------------------------------------------------------
    00472
    00475
    00477
    00478     /***
    00479      * Support for Serialization/De-serialization
    00480      ***/
    00481     DECL_XSERIALIZABLE(XMLElementDecl)
    00482
    00483     enum objectType
    00484     {
    00485         Schema
    00486       , DTD
    00487       , UnKnown
    00488     };
    00489
    00490     virtual XMLElementDecl::objectType  getObjectType() const = 0;
    00491
    00492     static void            storeElementDecl(XSerializeEngine&        serEng
    00493                                           , XMLElementDecl*    const element);
    00494
    00495     static XMLElementDecl* loadElementDecl(XSerializeEngine& serEng);
    00496
    00497 protected :
    00498     // -----------------------------------------------------------------------
    00499     //  Hidden constructors
    00500     // -----------------------------------------------------------------------
    00501     XMLElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00502
    00503 private :
    00504     // -----------------------------------------------------------------------
    00505     //  Unimplemented constructors and operators
    00506     // -----------------------------------------------------------------------
    00507     XMLElementDecl(const XMLElementDecl&);
    00508     XMLElementDecl& operator=(const XMLElementDecl&);
    00509
    00510
    00511     // -----------------------------------------------------------------------
    00512     //  Data members
    00513     //
    00514     //  fElementName
    00515     //      This is the name of the element decl.
    00516     //
    00517     //  fCreateReason
    00518     //      We sometimes have to put an element decl object into the elem
    00519     //      decl pool before the element's declaration is seen, such as when
    00520     //      its used in another element's content model or an att list is
    00521     //      seen for it. This flag tells us whether its been declared, and
    00522     //      if not why it had to be created.
    00523     //
    00524     //  fId
    00525     //      The unique id of this element. This is created by the derived
    00526     //      class, or more accurately the grammar that owns the objects
    00527     //      of the derived types. But, since they all have to have them, we
    00528     //      let them all store the id here. It is defaulted to have the
    00529     //      value fgInvalidElem until explicitly set.
    00530     //
    00531     //  fExternalElement
    00532     //      This flag indicates whether or the element was declared externally.
    00533     // -----------------------------------------------------------------------
    00534     MemoryManager*      fMemoryManager;
    00535     QName*              fElementName;
    00536     CreateReasons       fCreateReason;
    00537     unsigned int        fId;
    00538     bool                fExternalElement;
    00539 };
    00540
    00541
    00542 // ---------------------------------------------------------------------------
    00543 //  XMLElementDecl: Getter methods
    00544 // ---------------------------------------------------------------------------
    00545 inline const XMLCh* XMLElementDecl::getBaseName() const
    00546 {
    00547     return fElementName->getLocalPart();
    00548 }
    00549
    00550 inline XMLCh* XMLElementDecl::getBaseName()
    00551 {
    00552     return fElementName->getLocalPart();
    00553 }
    00554
    00555 inline unsigned int XMLElementDecl::getURI() const
    00556 {
    00557     return fElementName->getURI();
    00558 }
    00559
    00560 inline const QName* XMLElementDecl::getElementName() const
    00561 {
    00562     return fElementName;
    00563 }
    00564
    00565 inline QName* XMLElementDecl::getElementName()
    00566 {
    00567     return fElementName;
    00568 }
    00569
    00570 inline const XMLCh* XMLElementDecl::getFullName() const
    00571 {
    00572     return fElementName->getRawName();
    00573 }
    00574
    00575 inline XMLElementDecl::CreateReasons XMLElementDecl::getCreateReason() const
    00576 {
    00577     return fCreateReason;
    00578 }
    00579
    00580 inline unsigned int XMLElementDecl::getId() const
    00581 {
    00582     return fId;
    00583 }
    00584
    00585 inline bool XMLElementDecl::isDeclared() const
    00586 {
    00587     return (fCreateReason == Declared);
    00588 }
    00589
    00590
    00591 inline bool XMLElementDecl::isExternal() const
    00592 {
    00593     return fExternalElement;
    00594 }
    00595
    00596 inline MemoryManager* XMLElementDecl::getMemoryManager() const
    00597 {
    00598     return fMemoryManager;
    00599 }
    00600
    00601
    00602 // ---------------------------------------------------------------------------
    00603 //  XMLElementDecl: Setter methods
    00604 // ---------------------------------------------------------------------------
    00605 inline void
    00606 XMLElementDecl::setCreateReason(const XMLElementDecl::CreateReasons newReason)
    00607 {
    00608     fCreateReason = newReason;
    00609 }
    00610
    00611 inline void XMLElementDecl::setId(const unsigned int newId)
    00612 {
    00613     fId = newId;
    00614 }
    00615
    00616
    00617 inline void XMLElementDecl::setExternalElemDeclaration(const bool aValue)
    00618 {
    00619     fExternalElement = aValue;
    00620 }
    00621
    00622 XERCES_CPP_NAMESPACE_END
    00623
    00624 #endif

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