http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Release Info

Installation
Download
Build

FAQs
Samples
API Docs

DOM C++ Binding
Programming
Migration Guide

Feedback
Bug-Reporting
PDF Document

CVS Repository
Mail Archive

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


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