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

Home

Readme
Download
Installation
Build

API Docs
Samples
Schema

FAQs
Programming
Migration

Releases
Bug-Reporting
Feedback

Y2K Compliance
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.18  2001/08/21 16:06:10  tng
00060  * Schema: Unique Particle Attribution Constraint Checking.
00061  *
00062  * Revision 1.17  2001/07/24 18:30:47  knoaman
00063  * Added support for <group> + extra constraint checking for complexType
00064  *
00065  * Revision 1.16  2001/06/21 14:25:28  knoaman
00066  * Fix for bug 1946
00067  *
00068  * Revision 1.15  2001/05/11 13:25:32  tng
00069  * Copyright update.
00070  *
00071  * Revision 1.14  2001/05/03 20:34:22  tng
00072  * Schema: SchemaValidator update
00073  *
00074  * Revision 1.13  2001/04/19 18:16:52  tng
00075  * Schema: SchemaValidator update, and use QName in Content Model
00076  *
00077  * Revision 1.12  2001/03/21 21:56:02  tng
00078  * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
00079  *
00080  * Revision 1.11  2001/03/21 19:29:29  tng
00081  * Schema: Content Model Updates, by Pei Yong Zhang.
00082  *
00083  * Revision 1.10  2001/02/26 19:29:13  tng
00084  * Schema: add virtual method getURI(), getContentSpec and setContenSpec in XMLElementDecl, and DTDElementDecl.
00085  *
00086  * Revision 1.9  2001/02/26 19:21:30  tng
00087  * Schema: add parameter prefix in findElem and findAttr.
00088  *
00089  * Revision 1.8  2000/12/14 18:49:57  tng
00090  * Fix API document generation warning: "Warning: end of member group without matching begin"
00091  *
00092  * Revision 1.7  2000/11/30 18:22:38  andyh
00093  * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
00094  * pools already containing some items.  Fixed by Tinny Ng.
00095  *
00096  * Revision 1.6  2000/05/11 23:11:32  andyh
00097  * Add missing validity checks for stand-alone documents, character range
00098  * and Well-formed parsed entities.  Changes contributed by Sean MacRoibeaird
00099  * <sean.Macroibeaird@ireland.sun.com>
00100  *
00101  * Revision 1.5  2000/02/24 20:00:23  abagchi
00102  * Swat for removing Log from API docs
00103  *
00104  * Revision 1.4  2000/02/16 19:48:56  roddey
00105  * More documentation updates
00106  *
00107  * Revision 1.3  2000/02/15 01:21:30  roddey
00108  * Some initial documentation improvements. More to come...
00109  *
00110  * Revision 1.2  2000/02/06 07:47:48  rahulj
00111  * Year 2K copyright swat.
00112  *
00113  * Revision 1.1.1.1  1999/11/09 01:08:32  twl
00114  * Initial checkin
00115  *
00116  * Revision 1.2  1999/11/08 20:44:38  rahul
00117  * Swat for adding in Product name and CVS comment log variable.
00118  *
00119  */
00120 
00121 #if !defined(XMLELEMENTDECL_HPP)
00122 #define XMLELEMENTDECL_HPP
00123 
00124 #include <util/XMLString.hpp>
00125 #include <framework/XMLAttr.hpp>
00126 #include <framework/XMLAttDefList.hpp>
00127 
00128 class ContentSpecNode;
00129 class XMLContentModel;
00130 
00146 class  XMLElementDecl
00147 {
00148  public:
00149     // -----------------------------------------------------------------------
00150     //  Class specific types
00151     //
00152     //  CreateReasons
00153     //      This type is used to store how an element declaration got into
00154     //      the grammar's element pool. They are faulted in for various
00155     //      reasons.
00156     //
00157     //  LookupOpts
00158     //      These are the values used by the attribute lookup methods.
00159     //
00160     //  CharDataOpts
00161     //      This is used to indicate how this type of element reacts to
00162     //      character data as content.
00163     // -----------------------------------------------------------------------
00164     enum CreateReasons
00165     {
00166         NoReason
00167         , Declared
00168         , AttList
00169         , InContentModel
00170         , AsRootElem
00171         , JustFaultIn
00172     };
00173 
00174     enum LookupOpts
00175     {
00176         AddIfNotFound
00177         , FailIfNotFound
00178     };
00179 
00180     enum CharDataOpts
00181     {
00182         NoCharData
00183         , SpacesOk
00184         , AllCharData
00185     };
00186 
00187 
00188     // -----------------------------------------------------------------------
00189     //  Public static data
00190     //
00191     //  fgInvalidElemId
00192     //      A value to represent an invalid element node id.
00193     //
00194     //  fgPCDataElemId
00195     //      This is the value to use to represent a PCDATA node when an
00196     //      element id is required.
00197     //
00198     //  fgPCDataElemName
00199     //      This is the value to use to represent a PCDATA node when an
00200     //      element name is required.
00201     // -----------------------------------------------------------------------
00202     static const unsigned int   fgInvalidElemId;
00203     static const unsigned int   fgPCDataElemId;
00204     static const XMLCh          fgPCDataElemName[];
00205 
00206 
00207 
00208     // -----------------------------------------------------------------------
00209     //  Destructor
00210     // -----------------------------------------------------------------------
00213     virtual ~XMLElementDecl();
00215 
00216 
00217     // -----------------------------------------------------------------------
00218     //  The virtual element decl interface
00219     // -----------------------------------------------------------------------
00220 
00223 
00252     virtual XMLAttDef* findAttr
00253     (
00254         const   XMLCh* const    qName
00255         , const unsigned int    uriId
00256         , const XMLCh* const    baseName
00257         , const XMLCh* const    prefix
00258         , const LookupOpts      options
00259         ,       bool&           wasAdded
00260     )   const = 0;
00261 
00273     virtual XMLAttDefList& getAttDefList() const = 0;
00274 
00282     virtual CharDataOpts getCharDataOpts() const = 0;
00283 
00290     virtual bool hasAttDefs() const = 0;
00291 
00299     virtual bool resetDefs() = 0;
00300 
00308     virtual const ContentSpecNode* getContentSpec() const = 0;
00309 
00315     virtual ContentSpecNode* getContentSpec() = 0;
00316 
00326     virtual void setContentSpec(ContentSpecNode* toAdopt) = 0;
00327     
00339     virtual XMLContentModel* getContentModel() = 0;    
00340     
00352     virtual void setContentModel(XMLContentModel* const newModelToAdopt) = 0;    
00353     
00366     virtual const XMLCh* getFormattedContentModel ()   const = 0;    
00367 
00369 
00370 
00371     // -----------------------------------------------------------------------
00372     //  Getter methods
00373     // -----------------------------------------------------------------------
00374 
00377 
00385     const XMLCh* getBaseName() const;
00386     XMLCh* getBaseName();
00387 
00394     const unsigned int getURI() const;
00395 
00403     const QName* getElementName() const;
00404     QName* getElementName();
00405 
00414     const XMLCh* getFullName() const;
00415 
00426 
00427     CreateReasons getCreateReason() const;
00428 
00438     unsigned int getId() const;
00439 
00449     bool isDeclared() const;
00450 
00458 
00459     bool isExternal() const;
00460 
00462 
00463 
00464     // -----------------------------------------------------------------------
00465     //  Setter methods
00466     // -----------------------------------------------------------------------
00467 
00470 
00481       void setElementName(const XMLCh* const       prefix
00482                         , const XMLCh* const       localPart
00483                         , const int                uriId );
00484 
00494       void setElementName(const XMLCh* const    rawName
00495                         , const int             uriId );
00496 
00505       void setElementName(const QName* const    elementName);
00506 
00517     void setCreateReason(const CreateReasons newReason);
00518 
00525     void setId(const unsigned int newId);
00526 
00527 
00531     void setExternalElemDeclaration(const bool aValue);
00532 
00534 
00535 
00536     // -----------------------------------------------------------------------
00537     //  Miscellaneous methods
00538     // -----------------------------------------------------------------------
00539 
00542 
00544 
00545 
00546 protected :
00547     // -----------------------------------------------------------------------
00548     //  Hidden constructors
00549     // -----------------------------------------------------------------------
00550     XMLElementDecl();
00551 
00552 private :
00553     // -----------------------------------------------------------------------
00554     //  Unimplemented constructors and operators
00555     // -----------------------------------------------------------------------
00556     XMLElementDecl(const XMLElementDecl&);
00557     void operator=(const XMLElementDecl&);
00558 
00559 
00560     // -----------------------------------------------------------------------
00561     //  Data members
00562     //
00563     //  fElementName
00564     //      This is the name of the element decl.
00565     //
00566     //  fCreateReason
00567     //      We sometimes have to put an element decl object into the elem
00568     //      decl pool before the element's declaration is seen, such as when
00569     //      its used in another element's content model or an att list is
00570     //      seen for it. This flag tells us whether its been declared, and
00571     //      if not why it had to be created.
00572     //
00573     //  fId
00574     //      The unique id of this element. This is created by the derived
00575     //      class, or more accurately the grammar that owns the objects
00576     //      of the derived types. But, since they all have to have them, we
00577     //      let them all store the id here. It is defaulted to have the
00578     //      value fgInvalidElem until explicitly set.
00579     //
00580     //  fExternalElement
00581     //      This flag indicates whether or the element was declared externally.
00582     // -----------------------------------------------------------------------
00583     QName*              fElementName;
00584     CreateReasons       fCreateReason;
00585     unsigned int        fId;
00586     bool                fExternalElement;
00587 };
00588 
00589 
00590 // ---------------------------------------------------------------------------
00591 //  XMLElementDecl: Getter methods
00592 // ---------------------------------------------------------------------------
00593 inline const XMLCh* XMLElementDecl::getBaseName() const
00594 {
00595     return fElementName->getLocalPart();
00596 }
00597 
00598 inline XMLCh* XMLElementDecl::getBaseName()
00599 {
00600     return fElementName->getLocalPart();
00601 }
00602 
00603 inline const unsigned int XMLElementDecl::getURI() const
00604 {
00605     return fElementName->getURI();
00606 }
00607 
00608 inline const QName* XMLElementDecl::getElementName() const
00609 {
00610     return fElementName;
00611 }
00612 
00613 inline QName* XMLElementDecl::getElementName()
00614 {
00615     return fElementName;
00616 }
00617 
00618 inline const XMLCh* XMLElementDecl::getFullName() const
00619 {
00620     return fElementName->getRawName();
00621 }
00622 
00623 inline XMLElementDecl::CreateReasons XMLElementDecl::getCreateReason() const
00624 {
00625     return fCreateReason;
00626 }
00627 
00628 inline unsigned int XMLElementDecl::getId() const
00629 {
00630     return fId;
00631 }
00632 
00633 inline bool XMLElementDecl::isDeclared() const
00634 {
00635     return (fCreateReason == Declared);
00636 }
00637 
00638 
00639 inline bool XMLElementDecl::isExternal() const
00640 {
00641     return fExternalElement;
00642 }
00643 
00644 
00645 // ---------------------------------------------------------------------------
00646 //  XMLElementDecl: Setter methods
00647 // ---------------------------------------------------------------------------
00648 inline void
00649 XMLElementDecl::setCreateReason(const XMLElementDecl::CreateReasons newReason)
00650 {
00651     fCreateReason = newReason;
00652 }
00653 
00654 inline void XMLElementDecl::setId(const unsigned int newId)
00655 {
00656     fId = newId;
00657 }
00658 
00659 
00660 inline void XMLElementDecl::setExternalElemDeclaration(const bool aValue)
00661 {
00662     fExternalElement = aValue;
00663 }
00664 
00665 #endif


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