| 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.4  2003/01/29 19:45:35  gareth
    00060  * added api for DOMTypeInfo
    00061  *
    00062  * Revision 1.3  2002/11/04 15:00:21  tng
    00063  * C++ Namespace Support.
    00064  *
    00065  * Revision 1.2  2002/08/20 16:55:33  tng
    00066  * [Bug 6251] Info during compilation.
    00067  *
    00068  * Revision 1.1.1.1  2002/02/01 22:21:51  peiyongz
    00069  * sane_include
    00070  *
    00071  * Revision 1.18  2001/08/21 16:06:10  tng
    00072  * Schema: Unique Particle Attribution Constraint Checking.
    00073  *
    00074  * Revision 1.17  2001/07/24 18:30:47  knoaman
    00075  * Added support for <group> + extra constraint checking for complexType
    00076  *
    00077  * Revision 1.16  2001/06/21 14:25:28  knoaman
    00078  * Fix for bug 1946
    00079  *
    00080  * Revision 1.15  2001/05/11 13:25:32  tng
    00081  * Copyright update.
    00082  *
    00083  * Revision 1.14  2001/05/03 20:34:22  tng
    00084  * Schema: SchemaValidator update
    00085  *
    00086  * Revision 1.13  2001/04/19 18:16:52  tng
    00087  * Schema: SchemaValidator update, and use QName in Content Model
    00088  *
    00089  * Revision 1.12  2001/03/21 21:56:02  tng
    00090  * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
    00091  *
    00092  * Revision 1.11  2001/03/21 19:29:29  tng
    00093  * Schema: Content Model Updates, by Pei Yong Zhang.
    00094  *
    00095  * Revision 1.10  2001/02/26 19:29:13  tng
    00096  * Schema: add virtual method getURI(), getContentSpec and setContenSpec in XMLElementDecl, and DTDElementDecl.
    00097  *
    00098  * Revision 1.9  2001/02/26 19:21:30  tng
    00099  * Schema: add parameter prefix in findElem and findAttr.
    00100  *
    00101  * Revision 1.8  2000/12/14 18:49:57  tng
    00102  * Fix API document generation warning: "Warning: end of member group without matching begin"
    00103  *
    00104  * Revision 1.7  2000/11/30 18:22:38  andyh
    00105  * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
    00106  * pools already containing some items.  Fixed by Tinny Ng.
    00107  *
    00108  * Revision 1.6  2000/05/11 23:11:32  andyh
    00109  * Add missing validity checks for stand-alone documents, character range
    00110  * and Well-formed parsed entities.  Changes contributed by Sean MacRoibeaird
    00111  * <sean.Macroibeaird@ireland.sun.com>
    00112  *
    00113  * Revision 1.5  2000/02/24 20:00:23  abagchi
    00114  * Swat for removing Log from API docs
    00115  *
    00116  * Revision 1.4  2000/02/16 19:48:56  roddey
    00117  * More documentation updates
    00118  *
    00119  * Revision 1.3  2000/02/15 01:21:30  roddey
    00120  * Some initial documentation improvements. More to come...
    00121  *
    00122  * Revision 1.2  2000/02/06 07:47:48  rahulj
    00123  * Year 2K copyright swat.
    00124  *
    00125  * Revision 1.1.1.1  1999/11/09 01:08:32  twl
    00126  * Initial checkin
    00127  *
    00128  * Revision 1.2  1999/11/08 20:44:38  rahul
    00129  * Swat for adding in Product name and CVS comment log variable.
    00130  *
    00131  */
    00132
    00133 #if !defined(XMLELEMENTDECL_HPP)
    00134 #define XMLELEMENTDECL_HPP
    00135
    00136 #include <xercesc/util/XMLString.hpp>
    00137 #include <xercesc/framework/XMLAttr.hpp>
    00138 #include <xercesc/framework/XMLAttDefList.hpp>
    00139
    00140 XERCES_CPP_NAMESPACE_BEGIN
    00141
    00142 class ContentSpecNode;
    00143 class XMLContentModel;
    00144
    00160 class  XMLElementDecl
    00161 {
    00162  public:
    00163     // -----------------------------------------------------------------------
    00164     //  Class specific types
    00165     //
    00166     //  CreateReasons
    00167     //      This type is used to store how an element declaration got into
    00168     //      the grammar's element pool. They are faulted in for various
    00169     //      reasons.
    00170     //
    00171     //  LookupOpts
    00172     //      These are the values used by the attribute lookup methods.
    00173     //
    00174     //  CharDataOpts
    00175     //      This is used to indicate how this type of element reacts to
    00176     //      character data as content.
    00177     // -----------------------------------------------------------------------
    00178     enum CreateReasons
    00179     {
    00180         NoReason
    00181         , Declared
    00182         , AttList
    00183         , InContentModel
    00184         , AsRootElem
    00185         , JustFaultIn
    00186     };
    00187
    00188     enum LookupOpts
    00189     {
    00190         AddIfNotFound
    00191         , FailIfNotFound
    00192     };
    00193
    00194     enum CharDataOpts
    00195     {
    00196         NoCharData
    00197         , SpacesOk
    00198         , AllCharData
    00199     };
    00200
    00201
    00202     // -----------------------------------------------------------------------
    00203     //  Public static data
    00204     //
    00205     //  fgInvalidElemId
    00206     //      A value to represent an invalid element node id.
    00207     //
    00208     //  fgPCDataElemId
    00209     //      This is the value to use to represent a PCDATA node when an
    00210     //      element id is required.
    00211     //
    00212     //  fgPCDataElemName
    00213     //      This is the value to use to represent a PCDATA node when an
    00214     //      element name is required.
    00215     // -----------------------------------------------------------------------
    00216     static const unsigned int   fgInvalidElemId;
    00217     static const unsigned int   fgPCDataElemId;
    00218     static const XMLCh          fgPCDataElemName[];
    00219
    00220
    00221
    00222     // -----------------------------------------------------------------------
    00223     //  Destructor
    00224     // -----------------------------------------------------------------------
    00227     virtual ~XMLElementDecl();
    00229
    00230
    00231     // -----------------------------------------------------------------------
    00232     //  The virtual element decl interface
    00233     // -----------------------------------------------------------------------
    00234
    00237
    00266     virtual XMLAttDef* findAttr
    00267     (
    00268         const   XMLCh* const    qName
    00269         , const unsigned int    uriId
    00270         , const XMLCh* const    baseName
    00271         , const XMLCh* const    prefix
    00272         , const LookupOpts      options
    00273         ,       bool&           wasAdded
    00274     )   const = 0;
    00275
    00287     virtual XMLAttDefList& getAttDefList() const = 0;
    00288
    00296     virtual CharDataOpts getCharDataOpts() const = 0;
    00297
    00304     virtual bool hasAttDefs() const = 0;
    00305
    00313     virtual bool resetDefs() = 0;
    00314
    00322     virtual const ContentSpecNode* getContentSpec() const = 0;
    00323
    00329     virtual ContentSpecNode* getContentSpec() = 0;
    00330
    00340     virtual void setContentSpec(ContentSpecNode* toAdopt) = 0;
    00341
    00353     virtual XMLContentModel* getContentModel() = 0;
    00354
    00366     virtual void setContentModel(XMLContentModel* const newModelToAdopt) = 0;
    00367
    00380     virtual const XMLCh* getFormattedContentModel ()   const = 0;
    00381
    00383
    00384
    00385     // -----------------------------------------------------------------------
    00386     //  Getter methods
    00387     // -----------------------------------------------------------------------
    00388
    00391
    00399     const XMLCh* getBaseName() const;
    00400     XMLCh* getBaseName();
    00401
    00408     unsigned int getURI() const;
    00409
    00417     const QName* getElementName() const;
    00418     QName* getElementName();
    00419
    00428     const XMLCh* getFullName() const;
    00429
    00441     CreateReasons getCreateReason() const;
    00442
    00452     unsigned int getId() const;
    00453
    00454
    00458     virtual const XMLCh* getDOMTypeInfoUri() const = 0;
    00459
    00463     virtual const XMLCh* getDOMTypeInfoName() const = 0;
    00464
    00465
    00475     bool isDeclared() const;
    00476
    00485     bool isExternal() const;
    00486
    00488
    00489
    00490     // -----------------------------------------------------------------------
    00491     //  Setter methods
    00492     // -----------------------------------------------------------------------
    00493
    00496
    00507       void setElementName(const XMLCh* const       prefix
    00508                         , const XMLCh* const       localPart
    00509                         , const int                uriId );
    00510
    00520       void setElementName(const XMLCh* const    rawName
    00521                         , const int             uriId );
    00522
    00531       void setElementName(const QName* const    elementName);
    00532
    00543     void setCreateReason(const CreateReasons newReason);
    00544
    00551     void setId(const unsigned int newId);
    00552
    00553
    00557     void setExternalElemDeclaration(const bool aValue);
    00558
    00560
    00561
    00562     // -----------------------------------------------------------------------
    00563     //  Miscellaneous methods
    00564     // -----------------------------------------------------------------------
    00565
    00568
    00570
    00571
    00572 protected :
    00573     // -----------------------------------------------------------------------
    00574     //  Hidden constructors
    00575     // -----------------------------------------------------------------------
    00576     XMLElementDecl();
    00577
    00578 private :
    00579     // -----------------------------------------------------------------------
    00580     //  Unimplemented constructors and operators
    00581     // -----------------------------------------------------------------------
    00582     XMLElementDecl(const XMLElementDecl&);
    00583     void operator=(const XMLElementDecl&);
    00584
    00585
    00586     // -----------------------------------------------------------------------
    00587     //  Data members
    00588     //
    00589     //  fElementName
    00590     //      This is the name of the element decl.
    00591     //
    00592     //  fCreateReason
    00593     //      We sometimes have to put an element decl object into the elem
    00594     //      decl pool before the element's declaration is seen, such as when
    00595     //      its used in another element's content model or an att list is
    00596     //      seen for it. This flag tells us whether its been declared, and
    00597     //      if not why it had to be created.
    00598     //
    00599     //  fId
    00600     //      The unique id of this element. This is created by the derived
    00601     //      class, or more accurately the grammar that owns the objects
    00602     //      of the derived types. But, since they all have to have them, we
    00603     //      let them all store the id here. It is defaulted to have the
    00604     //      value fgInvalidElem until explicitly set.
    00605     //
    00606     //  fExternalElement
    00607     //      This flag indicates whether or the element was declared externally.
    00608     // -----------------------------------------------------------------------
    00609     QName*              fElementName;
    00610     CreateReasons       fCreateReason;
    00611     unsigned int        fId;
    00612     bool                fExternalElement;
    00613 };
    00614
    00615
    00616 // ---------------------------------------------------------------------------
    00617 //  XMLElementDecl: Getter methods
    00618 // ---------------------------------------------------------------------------
    00619 inline const XMLCh* XMLElementDecl::getBaseName() const
    00620 {
    00621     return fElementName->getLocalPart();
    00622 }
    00623
    00624 inline XMLCh* XMLElementDecl::getBaseName()
    00625 {
    00626     return fElementName->getLocalPart();
    00627 }
    00628
    00629 inline unsigned int XMLElementDecl::getURI() const
    00630 {
    00631     return fElementName->getURI();
    00632 }
    00633
    00634 inline const QName* XMLElementDecl::getElementName() const
    00635 {
    00636     return fElementName;
    00637 }
    00638
    00639 inline QName* XMLElementDecl::getElementName()
    00640 {
    00641     return fElementName;
    00642 }
    00643
    00644 inline const XMLCh* XMLElementDecl::getFullName() const
    00645 {
    00646     return fElementName->getRawName();
    00647 }
    00648
    00649 inline XMLElementDecl::CreateReasons XMLElementDecl::getCreateReason() const
    00650 {
    00651     return fCreateReason;
    00652 }
    00653
    00654 inline unsigned int XMLElementDecl::getId() const
    00655 {
    00656     return fId;
    00657 }
    00658
    00659 inline bool XMLElementDecl::isDeclared() const
    00660 {
    00661     return (fCreateReason == Declared);
    00662 }
    00663
    00664
    00665 inline bool XMLElementDecl::isExternal() const
    00666 {
    00667     return fExternalElement;
    00668 }
    00669
    00670
    00671 // ---------------------------------------------------------------------------
    00672 //  XMLElementDecl: Setter methods
    00673 // ---------------------------------------------------------------------------
    00674 inline void
    00675 XMLElementDecl::setCreateReason(const XMLElementDecl::CreateReasons newReason)
    00676 {
    00677     fCreateReason = newReason;
    00678 }
    00679
    00680 inline void XMLElementDecl::setId(const unsigned int newId)
    00681 {
    00682     fId = newId;
    00683 }
    00684
    00685
    00686 inline void XMLElementDecl::setExternalElemDeclaration(const bool aValue)
    00687 {
    00688     fExternalElement = aValue;
    00689 }
    00690
    00691 XERCES_CPP_NAMESPACE_END
    00692
    00693 #endif

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