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  

XSModel.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  * Copyright (c) 2003 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: XSModel.hpp,v $
00059  * Revision 1.10  2003/12/24 17:42:02  knoaman
00060  * Misc. PSVI updates
00061  *
00062  * Revision 1.9  2003/11/26 16:12:23  knoaman
00063  * Add a method to return the XSObject mapped to a schema grammar component
00064  *
00065  * Revision 1.8  2003/11/21 22:34:45  neilg
00066  * More schema component model implementation, thanks to David Cargill.
00067  * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
00068  * XSAttributeDeclaration and XSAttributeGroup implementations.
00069  *
00070  * Revision 1.7  2003/11/21 17:25:09  knoaman
00071  * Use XSObjectFactory to create various components.
00072  *
00073  * Revision 1.6  2003/11/15 21:18:39  neilg
00074  * fixes for compilation under gcc
00075  *
00076  * Revision 1.5  2003/11/14 22:47:53  neilg
00077  * fix bogus log message from previous commit...
00078  *
00079  * Revision 1.4  2003/11/14 22:33:30  neilg
00080  * Second phase of schema component model implementation.  
00081  * Implement XSModel, XSNamespaceItem, and the plumbing necessary
00082  * to connect them to the other components.
00083  * Thanks to David Cargill.
00084  *
00085  * Revision 1.3  2003/11/06 15:30:04  neilg
00086  * first part of PSVI/schema component model implementation, thanks to David Cargill.  This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse.
00087  *
00088  * Revision 1.2  2003/10/10 18:37:51  neilg
00089  * update XSModel and XSObject interface so that IDs can be used to query components in XSModels, and so that those IDs can be recovered from components
00090  *
00091  * Revision 1.1  2003/09/16 14:33:36  neilg
00092  * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
00093  *
00094  */
00095 
00096 #if !defined(XSMODEL_HPP)
00097 #define XSMODEL_HPP
00098 
00099 #include <xercesc/util/PlatformUtils.hpp>
00100 #include <xercesc/framework/psvi/XSObject.hpp>
00101 #include <xercesc/framework/psvi/XSNamedMap.hpp>
00102 
00103 #include <xercesc/util/ValueVectorOf.hpp>
00104 #include <xercesc/validators/schema/SchemaElementDecl.hpp>
00105 
00106 XERCES_CPP_NAMESPACE_BEGIN
00107 
00120 // forward declarations
00121 class Grammar;
00122 class XMLGrammarPool;
00123 class XSAnnotation;
00124 class XSAttributeDeclaration;
00125 class XSAttributeGroupDefinition;
00126 class XSElementDeclaration;
00127 class XSModelGroupDefinition;
00128 class XSNamespaceItem;
00129 class XSNotationDeclaration;
00130 class XSTypeDefinition;
00131 class XSObjectFactory;
00132 
00133 class  XSModel : public XMemory
00134 {
00135 public:
00136 
00137     //  Constructors and Destructor
00138     // -----------------------------------------------------------------------
00141 
00147     XSModel( XMLGrammarPool *grammarPool
00148                 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00149 
00159     XSModel( XSModel *baseModel
00160                 , GrammarResolver *grammarResolver
00161                 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00162 
00164 
00167     ~XSModel();
00169 
00170     //---------------------
00174 
00181     StringList *getNamespaces();
00182 
00191     XSNamespaceItemList *getNamespaceItems();
00192 
00203     XSNamedMap<XSObject> *getComponents(XSConstants::COMPONENT_TYPE objectType);
00204 
00217     XSNamedMap<XSObject> *getComponentsByNamespace(XSConstants::COMPONENT_TYPE objectType, 
00218                                                const XMLCh *compNamespace);
00219 
00223     XSAnnotationList *getAnnotations();
00224 
00232     XSElementDeclaration *getElementDeclaration(const XMLCh *name
00233             , const XMLCh *compNamespace);
00234 
00242     XSAttributeDeclaration *getAttributeDeclaration(const XMLCh *name
00243             , const XMLCh *compNamespace);
00244 
00253     XSTypeDefinition *getTypeDefinition(const XMLCh *name
00254             , const XMLCh *compNamespace);
00255 
00263     XSAttributeGroupDefinition *getAttributeGroup(const XMLCh *name
00264             , const XMLCh *compNamespace);
00265 
00273     XSModelGroupDefinition *getModelGroupDefinition(const XMLCh *name
00274             , const XMLCh *compNamespace);
00275 
00283     XSNotationDeclaration *getNotationDeclaration(const XMLCh *name
00284             , const XMLCh *compNamespace);
00285 
00295     XSObject *getXSObjectById(unsigned int  compId
00296                 , XSConstants::COMPONENT_TYPE compType);
00297 
00299 
00300     //----------------------------------
00304     XMLStringPool*  getURIStringPool();
00305 
00306     XSNamespaceItem* getNamespaceItem(const XMLCh* const key);
00307 
00315     XSObject* getXSObject(void* key);
00316 
00318 private:
00319 
00320     // -----------------------------------------------------------------------
00321     //  Helper methods
00322     // -----------------------------------------------------------------------
00323     void addGrammarToXSModel
00324     (
00325         XSNamespaceItem* namespaceItem
00326     );
00327     void addS4SToXSModel
00328     (
00329         XSNamespaceItem* const namespaceItem
00330         , RefHashTableOf<DatatypeValidator>* const builtInDV
00331     );
00332     void addComponentToNamespace
00333     (
00334          XSNamespaceItem* const namespaceItem
00335          , XSObject* const component
00336          , int componentIndex
00337          , bool addToXSModel = true
00338     );
00339 
00340     // -----------------------------------------------------------------------
00341     //  Unimplemented constructors and operators
00342     // -----------------------------------------------------------------------
00343     XSModel(const XSModel&);
00344     XSModel & operator=(const XSModel &);
00345 
00346 protected:
00347     friend class XSObjectFactory;
00348 
00349     // -----------------------------------------------------------------------
00350     //  data members
00351     // -----------------------------------------------------------------------
00352     // fMemoryManager:
00353     //  used for any memory allocations
00354     MemoryManager* const                    fMemoryManager;
00355  
00356     StringList*                             fNamespaceStringList;
00357     XSNamespaceItemList*                    fXSNamespaceItemList;
00358 
00359     RefVectorOf<XSElementDeclaration>*      fElementDeclarationVector;
00360     RefVectorOf<XSAttributeDeclaration>*    fAttributeDeclarationVector;
00361 
00362     /* Need a XSNamedMap for each component    top-level?
00363           ATTRIBUTE_DECLARATION     = 1,       
00364           ELEMENT_DECLARATION       = 2,        
00365           TYPE_DEFINITION           = 3,        
00366           ATTRIBUTE_USE             = 4,       no 
00367           ATTRIBUTE_GROUP_DEFINITION= 5,        
00368           MODEL_GROUP_DEFINITION    = 6,       
00369           MODEL_GROUP               = 7,       no 
00370           PARTICLE                  = 8,       no
00371           WILDCARD                  = 9,       no
00372           IDENTITY_CONSTRAINT       = 10,      no
00373           NOTATION_DECLARATION      = 11,       
00374           ANNOTATION                = 12,      no 
00375           FACET                     = 13,      no
00376           MULTIVALUE_FACET          = 14       no
00377     */
00378     XSNamedMap<XSObject>*                   fComponentMap[XSConstants::MULTIVALUE_FACET];
00379     XMLStringPool*                          fURIStringPool;
00380     XSAnnotationList*                       fXSAnnotationList;
00381     RefHashTableOf<XSNamespaceItem>*        fHashNamespace;
00382     XSObjectFactory*                        fObjFactory;
00383     RefVectorOf<XSNamespaceItem>*           fDeleteNamespace;
00384     XSModel*                                fParent;
00385     bool                                    fDeleteParent;
00386     bool                                    fAddedS4SGrammar;
00387 };
00388 
00389 inline XMLStringPool*  XSModel::getURIStringPool()
00390 {
00391     return fURIStringPool;
00392 }
00393 
00394 inline StringList *XSModel::getNamespaces()
00395 {
00396     return fNamespaceStringList;
00397 }
00398 
00399 inline XSNamespaceItemList *XSModel::getNamespaceItems()
00400 {
00401     return fXSNamespaceItemList;
00402 }
00403 
00404 XERCES_CPP_NAMESPACE_END
00405 
00406 #endif


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