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


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