| 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.2  2002/08/20 16:55:33  tng
    00060  * [Bug 6251] Info during compilation.
    00061  *
    00062  * Revision 1.1.1.1  2002/02/01 22:21:51  peiyongz
    00063  * sane_include
    00064  *
    00065  * Revision 1.18  2001/08/21 16:06:10  tng
    00066  * Schema: Unique Particle Attribution Constraint Checking.
    00067  *
    00068  * Revision 1.17  2001/07/24 18:30:47  knoaman
    00069  * Added support for <group> + extra constraint checking for complexType
    00070  *
    00071  * Revision 1.16  2001/06/21 14:25:28  knoaman
    00072  * Fix for bug 1946
    00073  *
    00074  * Revision 1.15  2001/05/11 13:25:32  tng
    00075  * Copyright update.
    00076  *
    00077  * Revision 1.14  2001/05/03 20:34:22  tng
    00078  * Schema: SchemaValidator update
    00079  *
    00080  * Revision 1.13  2001/04/19 18:16:52  tng
    00081  * Schema: SchemaValidator update, and use QName in Content Model
    00082  *
    00083  * Revision 1.12  2001/03/21 21:56:02  tng
    00084  * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
    00085  *
    00086  * Revision 1.11  2001/03/21 19:29:29  tng
    00087  * Schema: Content Model Updates, by Pei Yong Zhang.
    00088  *
    00089  * Revision 1.10  2001/02/26 19:29:13  tng
    00090  * Schema: add virtual method getURI(), getContentSpec and setContenSpec in XMLElementDecl, and DTDElementDecl.
    00091  *
    00092  * Revision 1.9  2001/02/26 19:21:30  tng
    00093  * Schema: add parameter prefix in findElem and findAttr.
    00094  *
    00095  * Revision 1.8  2000/12/14 18:49:57  tng
    00096  * Fix API document generation warning: "Warning: end of member group without matching begin"
    00097  *
    00098  * Revision 1.7  2000/11/30 18:22:38  andyh
    00099  * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
    00100  * pools already containing some items.  Fixed by Tinny Ng.
    00101  *
    00102  * Revision 1.6  2000/05/11 23:11:32  andyh
    00103  * Add missing validity checks for stand-alone documents, character range
    00104  * and Well-formed parsed entities.  Changes contributed by Sean MacRoibeaird
    00105  * <sean.Macroibeaird@ireland.sun.com>
    00106  *
    00107  * Revision 1.5  2000/02/24 20:00:23  abagchi
    00108  * Swat for removing Log from API docs
    00109  *
    00110  * Revision 1.4  2000/02/16 19:48:56  roddey
    00111  * More documentation updates
    00112  *
    00113  * Revision 1.3  2000/02/15 01:21:30  roddey
    00114  * Some initial documentation improvements. More to come...
    00115  *
    00116  * Revision 1.2  2000/02/06 07:47:48  rahulj
    00117  * Year 2K copyright swat.
    00118  *
    00119  * Revision 1.1.1.1  1999/11/09 01:08:32  twl
    00120  * Initial checkin
    00121  *
    00122  * Revision 1.2  1999/11/08 20:44:38  rahul
    00123  * Swat for adding in Product name and CVS comment log variable.
    00124  *
    00125  */
    00126
    00127 #if !defined(XMLELEMENTDECL_HPP)
    00128 #define XMLELEMENTDECL_HPP
    00129
    00130 #include <xercesc/util/XMLString.hpp>
    00131 #include <xercesc/framework/XMLAttr.hpp>
    00132 #include <xercesc/framework/XMLAttDefList.hpp>
    00133
    00134 class ContentSpecNode;
    00135 class XMLContentModel;
    00136
    00152 class  XMLElementDecl
    00153 {
    00154  public:
    00155     // -----------------------------------------------------------------------
    00156     //  Class specific types
    00157     //
    00158     //  CreateReasons
    00159     //      This type is used to store how an element declaration got into
    00160     //      the grammar's element pool. They are faulted in for various
    00161     //      reasons.
    00162     //
    00163     //  LookupOpts
    00164     //      These are the values used by the attribute lookup methods.
    00165     //
    00166     //  CharDataOpts
    00167     //      This is used to indicate how this type of element reacts to
    00168     //      character data as content.
    00169     // -----------------------------------------------------------------------
    00170     enum CreateReasons
    00171     {
    00172         NoReason
    00173         , Declared
    00174         , AttList
    00175         , InContentModel
    00176         , AsRootElem
    00177         , JustFaultIn
    00178     };
    00179
    00180     enum LookupOpts
    00181     {
    00182         AddIfNotFound
    00183         , FailIfNotFound
    00184     };
    00185
    00186     enum CharDataOpts
    00187     {
    00188         NoCharData
    00189         , SpacesOk
    00190         , AllCharData
    00191     };
    00192
    00193
    00194     // -----------------------------------------------------------------------
    00195     //  Public static data
    00196     //
    00197     //  fgInvalidElemId
    00198     //      A value to represent an invalid element node id.
    00199     //
    00200     //  fgPCDataElemId
    00201     //      This is the value to use to represent a PCDATA node when an
    00202     //      element id is required.
    00203     //
    00204     //  fgPCDataElemName
    00205     //      This is the value to use to represent a PCDATA node when an
    00206     //      element name is required.
    00207     // -----------------------------------------------------------------------
    00208     static const unsigned int   fgInvalidElemId;
    00209     static const unsigned int   fgPCDataElemId;
    00210     static const XMLCh          fgPCDataElemName[];
    00211
    00212
    00213
    00214     // -----------------------------------------------------------------------
    00215     //  Destructor
    00216     // -----------------------------------------------------------------------
    00219     virtual ~XMLElementDecl();
    00221
    00222
    00223     // -----------------------------------------------------------------------
    00224     //  The virtual element decl interface
    00225     // -----------------------------------------------------------------------
    00226
    00229
    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
    00432
    00433     CreateReasons getCreateReason() const;
    00434
    00444     unsigned int getId() const;
    00445
    00455     bool isDeclared() const;
    00456
    00464
    00465     bool isExternal() const;
    00466
    00468
    00469
    00470     // -----------------------------------------------------------------------
    00471     //  Setter methods
    00472     // -----------------------------------------------------------------------
    00473
    00476
    00487       void setElementName(const XMLCh* const       prefix
    00488                         , const XMLCh* const       localPart
    00489                         , const int                uriId );
    00490
    00500       void setElementName(const XMLCh* const    rawName
    00501                         , const int             uriId );
    00502
    00511       void setElementName(const QName* const    elementName);
    00512
    00523     void setCreateReason(const CreateReasons newReason);
    00524
    00531     void setId(const unsigned int newId);
    00532
    00533
    00537     void setExternalElemDeclaration(const bool aValue);
    00538
    00540
    00541
    00542     // -----------------------------------------------------------------------
    00543     //  Miscellaneous methods
    00544     // -----------------------------------------------------------------------
    00545
    00548
    00550
    00551
    00552 protected :
    00553     // -----------------------------------------------------------------------
    00554     //  Hidden constructors
    00555     // -----------------------------------------------------------------------
    00556     XMLElementDecl();
    00557
    00558 private :
    00559     // -----------------------------------------------------------------------
    00560     //  Unimplemented constructors and operators
    00561     // -----------------------------------------------------------------------
    00562     XMLElementDecl(const XMLElementDecl&);
    00563     void operator=(const XMLElementDecl&);
    00564
    00565
    00566     // -----------------------------------------------------------------------
    00567     //  Data members
    00568     //
    00569     //  fElementName
    00570     //      This is the name of the element decl.
    00571     //
    00572     //  fCreateReason
    00573     //      We sometimes have to put an element decl object into the elem
    00574     //      decl pool before the element's declaration is seen, such as when
    00575     //      its used in another element's content model or an att list is
    00576     //      seen for it. This flag tells us whether its been declared, and
    00577     //      if not why it had to be created.
    00578     //
    00579     //  fId
    00580     //      The unique id of this element. This is created by the derived
    00581     //      class, or more accurately the grammar that owns the objects
    00582     //      of the derived types. But, since they all have to have them, we
    00583     //      let them all store the id here. It is defaulted to have the
    00584     //      value fgInvalidElem until explicitly set.
    00585     //
    00586     //  fExternalElement
    00587     //      This flag indicates whether or the element was declared externally.
    00588     // -----------------------------------------------------------------------
    00589     QName*              fElementName;
    00590     CreateReasons       fCreateReason;
    00591     unsigned int        fId;
    00592     bool                fExternalElement;
    00593 };
    00594
    00595
    00596 // ---------------------------------------------------------------------------
    00597 //  XMLElementDecl: Getter methods
    00598 // ---------------------------------------------------------------------------
    00599 inline const XMLCh* XMLElementDecl::getBaseName() const
    00600 {
    00601     return fElementName->getLocalPart();
    00602 }
    00603
    00604 inline XMLCh* XMLElementDecl::getBaseName()
    00605 {
    00606     return fElementName->getLocalPart();
    00607 }
    00608
    00609 inline unsigned int XMLElementDecl::getURI() const
    00610 {
    00611     return fElementName->getURI();
    00612 }
    00613
    00614 inline const QName* XMLElementDecl::getElementName() const
    00615 {
    00616     return fElementName;
    00617 }
    00618
    00619 inline QName* XMLElementDecl::getElementName()
    00620 {
    00621     return fElementName;
    00622 }
    00623
    00624 inline const XMLCh* XMLElementDecl::getFullName() const
    00625 {
    00626     return fElementName->getRawName();
    00627 }
    00628
    00629 inline XMLElementDecl::CreateReasons XMLElementDecl::getCreateReason() const
    00630 {
    00631     return fCreateReason;
    00632 }
    00633
    00634 inline unsigned int XMLElementDecl::getId() const
    00635 {
    00636     return fId;
    00637 }
    00638
    00639 inline bool XMLElementDecl::isDeclared() const
    00640 {
    00641     return (fCreateReason == Declared);
    00642 }
    00643
    00644
    00645 inline bool XMLElementDecl::isExternal() const
    00646 {
    00647     return fExternalElement;
    00648 }
    00649
    00650
    00651 // ---------------------------------------------------------------------------
    00652 //  XMLElementDecl: Setter methods
    00653 // ---------------------------------------------------------------------------
    00654 inline void
    00655 XMLElementDecl::setCreateReason(const XMLElementDecl::CreateReasons newReason)
    00656 {
    00657     fCreateReason = newReason;
    00658 }
    00659
    00660 inline void XMLElementDecl::setId(const unsigned int newId)
    00661 {
    00662     fId = newId;
    00663 }
    00664
    00665
    00666 inline void XMLElementDecl::setExternalElemDeclaration(const bool aValue)
    00667 {
    00668     fExternalElement = aValue;
    00669 }
    00670
    00671 #endif

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