| 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.10  2003/11/27 06:08:18  neilg
    00060  * mark DOMTypeInfo-related methods on XMLElementDecl deprecated since they are not thread-safe
    00061  *
    00062  * Revision 1.9  2003/11/24 05:19:15  neilg
    00063  * update method documentation
    00064  *
    00065  * Revision 1.8  2003/10/10 16:23:29  peiyongz
    00066  * Implementation of Serialization/Deserialization
    00067  *
    00068  * Revision 1.7  2003/05/16 21:36:55  knoaman
    00069  * Memory manager implementation: Modify constructors to pass in the memory manager.
    00070  *
    00071  * Revision 1.6  2003/05/15 18:26:07  knoaman
    00072  * Partial implementation of the configurable memory manager.
    00073  *
    00074  * Revision 1.5  2003/03/07 18:08:10  tng
    00075  * Return a reference instead of void for operator=
    00076  *
    00077  * Revision 1.4  2003/01/29 19:45:35  gareth
    00078  * added api for DOMTypeInfo
    00079  *
    00080  * Revision 1.3  2002/11/04 15:00:21  tng
    00081  * C++ Namespace Support.
    00082  *
    00083  * Revision 1.2  2002/08/20 16:55:33  tng
    00084  * [Bug 6251] Info during compilation.
    00085  *
    00086  * Revision 1.1.1.1  2002/02/01 22:21:51  peiyongz
    00087  * sane_include
    00088  *
    00089  * Revision 1.18  2001/08/21 16:06:10  tng
    00090  * Schema: Unique Particle Attribution Constraint Checking.
    00091  *
    00092  * Revision 1.17  2001/07/24 18:30:47  knoaman
    00093  * Added support for <group> + extra constraint checking for complexType
    00094  *
    00095  * Revision 1.16  2001/06/21 14:25:28  knoaman
    00096  * Fix for bug 1946
    00097  *
    00098  * Revision 1.15  2001/05/11 13:25:32  tng
    00099  * Copyright update.
    00100  *
    00101  * Revision 1.14  2001/05/03 20:34:22  tng
    00102  * Schema: SchemaValidator update
    00103  *
    00104  * Revision 1.13  2001/04/19 18:16:52  tng
    00105  * Schema: SchemaValidator update, and use QName in Content Model
    00106  *
    00107  * Revision 1.12  2001/03/21 21:56:02  tng
    00108  * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
    00109  *
    00110  * Revision 1.11  2001/03/21 19:29:29  tng
    00111  * Schema: Content Model Updates, by Pei Yong Zhang.
    00112  *
    00113  * Revision 1.10  2001/02/26 19:29:13  tng
    00114  * Schema: add virtual method getURI(), getContentSpec and setContenSpec in XMLElementDecl, and DTDElementDecl.
    00115  *
    00116  * Revision 1.9  2001/02/26 19:21:30  tng
    00117  * Schema: add parameter prefix in findElem and findAttr.
    00118  *
    00119  * Revision 1.8  2000/12/14 18:49:57  tng
    00120  * Fix API document generation warning: "Warning: end of member group without matching begin"
    00121  *
    00122  * Revision 1.7  2000/11/30 18:22:38  andyh
    00123  * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
    00124  * pools already containing some items.  Fixed by Tinny Ng.
    00125  *
    00126  * Revision 1.6  2000/05/11 23:11:32  andyh
    00127  * Add missing validity checks for stand-alone documents, character range
    00128  * and Well-formed parsed entities.  Changes contributed by Sean MacRoibeaird
    00129  * <sean.Macroibeaird@ireland.sun.com>
    00130  *
    00131  * Revision 1.5  2000/02/24 20:00:23  abagchi
    00132  * Swat for removing Log from API docs
    00133  *
    00134  * Revision 1.4  2000/02/16 19:48:56  roddey
    00135  * More documentation updates
    00136  *
    00137  * Revision 1.3  2000/02/15 01:21:30  roddey
    00138  * Some initial documentation improvements. More to come...
    00139  *
    00140  * Revision 1.2  2000/02/06 07:47:48  rahulj
    00141  * Year 2K copyright swat.
    00142  *
    00143  * Revision 1.1.1.1  1999/11/09 01:08:32  twl
    00144  * Initial checkin
    00145  *
    00146  * Revision 1.2  1999/11/08 20:44:38  rahul
    00147  * Swat for adding in Product name and CVS comment log variable.
    00148  *
    00149  */
    00150
    00151 #if !defined(XMLELEMENTDECL_HPP)
    00152 #define XMLELEMENTDECL_HPP
    00153
    00154 #include <xercesc/framework/XMLAttr.hpp>
    00155 #include <xercesc/framework/XMLAttDefList.hpp>
    00156 #include <xercesc/util/XMLString.hpp>
    00157 #include <xercesc/util/PlatformUtils.hpp>
    00158 #include <xercesc/internal/XSerializable.hpp>
    00159
    00160 XERCES_CPP_NAMESPACE_BEGIN
    00161
    00162 class ContentSpecNode;
    00163 class XMLContentModel;
    00164
    00180 class  XMLElementDecl : public XSerializable, public XMemory
    00181 {
    00182  public:
    00183     // -----------------------------------------------------------------------
    00184     //  Class specific types
    00185     //
    00186     //  CreateReasons
    00187     //      This type is used to store how an element declaration got into
    00188     //      the grammar's element pool. They are faulted in for various
    00189     //      reasons.
    00190     //
    00191     //  LookupOpts
    00192     //      These are the values used by the attribute lookup methods.
    00193     //
    00194     //  CharDataOpts
    00195     //      This is used to indicate how this type of element reacts to
    00196     //      character data as content.
    00197     // -----------------------------------------------------------------------
    00198     enum CreateReasons
    00199     {
    00200         NoReason
    00201         , Declared
    00202         , AttList
    00203         , InContentModel
    00204         , AsRootElem
    00205         , JustFaultIn
    00206     };
    00207
    00212     enum LookupOpts
    00213     {
    00214         AddIfNotFound
    00215         , FailIfNotFound
    00216     };
    00217
    00218     enum CharDataOpts
    00219     {
    00220         NoCharData
    00221         , SpacesOk
    00222         , AllCharData
    00223     };
    00224
    00225
    00226     // -----------------------------------------------------------------------
    00227     //  Public static data
    00228     //
    00229     //  fgInvalidElemId
    00230     //      A value to represent an invalid element node id.
    00231     //
    00232     //  fgPCDataElemId
    00233     //      This is the value to use to represent a PCDATA node when an
    00234     //      element id is required.
    00235     //
    00236     //  fgPCDataElemName
    00237     //      This is the value to use to represent a PCDATA node when an
    00238     //      element name is required.
    00239     // -----------------------------------------------------------------------
    00240     static const unsigned int   fgInvalidElemId;
    00241     static const unsigned int   fgPCDataElemId;
    00242     static const XMLCh          fgPCDataElemName[];
    00243
    00244
    00245
    00246     // -----------------------------------------------------------------------
    00247     //  Destructor
    00248     // -----------------------------------------------------------------------
    00251     virtual ~XMLElementDecl();
    00253
    00254
    00255     // -----------------------------------------------------------------------
    00256     //  The virtual element decl interface
    00257     // -----------------------------------------------------------------------
    00258
    00261
    00292     virtual XMLAttDef* findAttr
    00293     (
    00294         const   XMLCh* const    qName
    00295         , const unsigned int    uriId
    00296         , const XMLCh* const    baseName
    00297         , const XMLCh* const    prefix
    00298         , const LookupOpts      options
    00299         ,       bool&           wasAdded
    00300     )   const = 0;
    00301
    00313     virtual XMLAttDefList& getAttDefList() const = 0;
    00314
    00322     virtual CharDataOpts getCharDataOpts() const = 0;
    00323
    00330     virtual bool hasAttDefs() const = 0;
    00331
    00339     virtual bool resetDefs() = 0;
    00340
    00348     virtual const ContentSpecNode* getContentSpec() const = 0;
    00349
    00355     virtual ContentSpecNode* getContentSpec() = 0;
    00356
    00366     virtual void setContentSpec(ContentSpecNode* toAdopt) = 0;
    00367
    00379     virtual XMLContentModel* getContentModel() = 0;
    00380
    00392     virtual void setContentModel(XMLContentModel* const newModelToAdopt) = 0;
    00393
    00406     virtual const XMLCh* getFormattedContentModel ()   const = 0;
    00407
    00409
    00410
    00411     // -----------------------------------------------------------------------
    00412     //  Getter methods
    00413     // -----------------------------------------------------------------------
    00414
    00417
    00425     const XMLCh* getBaseName() const;
    00426     XMLCh* getBaseName();
    00427
    00434     unsigned int getURI() const;
    00435
    00443     const QName* getElementName() const;
    00444     QName* getElementName();
    00445
    00454     const XMLCh* getFullName() const;
    00455
    00467     CreateReasons getCreateReason() const;
    00468
    00478     unsigned int getId() const;
    00479
    00480
    00485     virtual const XMLCh* getDOMTypeInfoUri() const = 0;
    00486
    00491     virtual const XMLCh* getDOMTypeInfoName() const = 0;
    00492
    00493
    00503     bool isDeclared() const;
    00504
    00513     bool isExternal() const;
    00514
    00522     MemoryManager* getMemoryManager() const;
    00523
    00525
    00526
    00527     // -----------------------------------------------------------------------
    00528     //  Setter methods
    00529     // -----------------------------------------------------------------------
    00530
    00533
    00544       void setElementName(const XMLCh* const       prefix
    00545                         , const XMLCh* const       localPart
    00546                         , const int                uriId );
    00547
    00557       void setElementName(const XMLCh* const    rawName
    00558                         , const int             uriId );
    00559
    00568       void setElementName(const QName* const    elementName);
    00569
    00580     void setCreateReason(const CreateReasons newReason);
    00581
    00588     void setId(const unsigned int newId);
    00589
    00590
    00594     void setExternalElemDeclaration(const bool aValue);
    00595
    00597
    00598
    00599     // -----------------------------------------------------------------------
    00600     //  Miscellaneous methods
    00601     // -----------------------------------------------------------------------
    00602
    00605
    00607
    00608     /***
    00609      * Support for Serialization/De-serialization
    00610      ***/
    00611     DECL_XSERIALIZABLE(XMLElementDecl)
    00612
    00613 protected :
    00614     // -----------------------------------------------------------------------
    00615     //  Hidden constructors
    00616     // -----------------------------------------------------------------------
    00617     XMLElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00618
    00619 private :
    00620     // -----------------------------------------------------------------------
    00621     //  Unimplemented constructors and operators
    00622     // -----------------------------------------------------------------------
    00623     XMLElementDecl(const XMLElementDecl&);
    00624     XMLElementDecl& operator=(const XMLElementDecl&);
    00625
    00626
    00627     // -----------------------------------------------------------------------
    00628     //  Data members
    00629     //
    00630     //  fElementName
    00631     //      This is the name of the element decl.
    00632     //
    00633     //  fCreateReason
    00634     //      We sometimes have to put an element decl object into the elem
    00635     //      decl pool before the element's declaration is seen, such as when
    00636     //      its used in another element's content model or an att list is
    00637     //      seen for it. This flag tells us whether its been declared, and
    00638     //      if not why it had to be created.
    00639     //
    00640     //  fId
    00641     //      The unique id of this element. This is created by the derived
    00642     //      class, or more accurately the grammar that owns the objects
    00643     //      of the derived types. But, since they all have to have them, we
    00644     //      let them all store the id here. It is defaulted to have the
    00645     //      value fgInvalidElem until explicitly set.
    00646     //
    00647     //  fExternalElement
    00648     //      This flag indicates whether or the element was declared externally.
    00649     // -----------------------------------------------------------------------
    00650     MemoryManager*      fMemoryManager;
    00651     QName*              fElementName;
    00652     CreateReasons       fCreateReason;
    00653     unsigned int        fId;
    00654     bool                fExternalElement;
    00655 };
    00656
    00657
    00658 // ---------------------------------------------------------------------------
    00659 //  XMLElementDecl: Getter methods
    00660 // ---------------------------------------------------------------------------
    00661 inline const XMLCh* XMLElementDecl::getBaseName() const
    00662 {
    00663     return fElementName->getLocalPart();
    00664 }
    00665
    00666 inline XMLCh* XMLElementDecl::getBaseName()
    00667 {
    00668     return fElementName->getLocalPart();
    00669 }
    00670
    00671 inline unsigned int XMLElementDecl::getURI() const
    00672 {
    00673     return fElementName->getURI();
    00674 }
    00675
    00676 inline const QName* XMLElementDecl::getElementName() const
    00677 {
    00678     return fElementName;
    00679 }
    00680
    00681 inline QName* XMLElementDecl::getElementName()
    00682 {
    00683     return fElementName;
    00684 }
    00685
    00686 inline const XMLCh* XMLElementDecl::getFullName() const
    00687 {
    00688     return fElementName->getRawName();
    00689 }
    00690
    00691 inline XMLElementDecl::CreateReasons XMLElementDecl::getCreateReason() const
    00692 {
    00693     return fCreateReason;
    00694 }
    00695
    00696 inline unsigned int XMLElementDecl::getId() const
    00697 {
    00698     return fId;
    00699 }
    00700
    00701 inline bool XMLElementDecl::isDeclared() const
    00702 {
    00703     return (fCreateReason == Declared);
    00704 }
    00705
    00706
    00707 inline bool XMLElementDecl::isExternal() const
    00708 {
    00709     return fExternalElement;
    00710 }
    00711
    00712 inline MemoryManager* XMLElementDecl::getMemoryManager() const
    00713 {
    00714     return fMemoryManager;
    00715 }
    00716
    00717
    00718 // ---------------------------------------------------------------------------
    00719 //  XMLElementDecl: Setter methods
    00720 // ---------------------------------------------------------------------------
    00721 inline void
    00722 XMLElementDecl::setCreateReason(const XMLElementDecl::CreateReasons newReason)
    00723 {
    00724     fCreateReason = newReason;
    00725 }
    00726
    00727 inline void XMLElementDecl::setId(const unsigned int newId)
    00728 {
    00729     fId = newId;
    00730 }
    00731
    00732
    00733 inline void XMLElementDecl::setExternalElemDeclaration(const bool aValue)
    00734 {
    00735     fExternalElement = aValue;
    00736 }
    00737
    00738 XERCES_CPP_NAMESPACE_END
    00739
    00740 #endif

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