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  * Copyright 2003,2004 The Apache Software Foundation.
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 /*
00018  * $Log: XSModel.hpp,v $
00019  * Revision 1.12  2004/09/08 13:56:08  peiyongz
00020  * Apache License Version 2.0
00021  *
00022  * Revision 1.11  2004/05/04 19:02:40  cargilld
00023  * Enable IDs to work on all kinds of schema components
00024  *
00025  * Revision 1.10  2003/12/24 17:42:02  knoaman
00026  * Misc. PSVI updates
00027  *
00028  * Revision 1.9  2003/11/26 16:12:23  knoaman
00029  * Add a method to return the XSObject mapped to a schema grammar component
00030  *
00031  * Revision 1.8  2003/11/21 22:34:45  neilg
00032  * More schema component model implementation, thanks to David Cargill.
00033  * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
00034  * XSAttributeDeclaration and XSAttributeGroup implementations.
00035  *
00036  * Revision 1.7  2003/11/21 17:25:09  knoaman
00037  * Use XSObjectFactory to create various components.
00038  *
00039  * Revision 1.6  2003/11/15 21:18:39  neilg
00040  * fixes for compilation under gcc
00041  *
00042  * Revision 1.5  2003/11/14 22:47:53  neilg
00043  * fix bogus log message from previous commit...
00044  *
00045  * Revision 1.4  2003/11/14 22:33:30  neilg
00046  * Second phase of schema component model implementation.  
00047  * Implement XSModel, XSNamespaceItem, and the plumbing necessary
00048  * to connect them to the other components.
00049  * Thanks to David Cargill.
00050  *
00051  * Revision 1.3  2003/11/06 15:30:04  neilg
00052  * 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.
00053  *
00054  * Revision 1.2  2003/10/10 18:37:51  neilg
00055  * 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
00056  *
00057  * Revision 1.1  2003/09/16 14:33:36  neilg
00058  * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
00059  *
00060  */
00061 
00062 #if !defined(XSMODEL_HPP)
00063 #define XSMODEL_HPP
00064 
00065 #include <xercesc/util/PlatformUtils.hpp>
00066 #include <xercesc/framework/psvi/XSObject.hpp>
00067 #include <xercesc/framework/psvi/XSNamedMap.hpp>
00068 
00069 #include <xercesc/util/ValueVectorOf.hpp>
00070 #include <xercesc/validators/schema/SchemaElementDecl.hpp>
00071 
00072 XERCES_CPP_NAMESPACE_BEGIN
00073 
00086 // forward declarations
00087 class Grammar;
00088 class XMLGrammarPool;
00089 class XSAnnotation;
00090 class XSAttributeDeclaration;
00091 class XSAttributeGroupDefinition;
00092 class XSElementDeclaration;
00093 class XSModelGroupDefinition;
00094 class XSNamespaceItem;
00095 class XSNotationDeclaration;
00096 class XSTypeDefinition;
00097 class XSObjectFactory;
00098 
00099 class  XSModel : public XMemory
00100 {
00101 public:
00102 
00103     //  Constructors and Destructor
00104     // -----------------------------------------------------------------------
00107 
00113     XSModel( XMLGrammarPool *grammarPool
00114                 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00115 
00125     XSModel( XSModel *baseModel
00126                 , GrammarResolver *grammarResolver
00127                 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00128 
00130 
00133     ~XSModel();
00135 
00136     //---------------------
00140 
00147     StringList *getNamespaces();
00148 
00157     XSNamespaceItemList *getNamespaceItems();
00158 
00169     XSNamedMap<XSObject> *getComponents(XSConstants::COMPONENT_TYPE objectType);
00170 
00183     XSNamedMap<XSObject> *getComponentsByNamespace(XSConstants::COMPONENT_TYPE objectType, 
00184                                                const XMLCh *compNamespace);
00185 
00189     XSAnnotationList *getAnnotations();
00190 
00198     XSElementDeclaration *getElementDeclaration(const XMLCh *name
00199             , const XMLCh *compNamespace);
00200 
00208     XSAttributeDeclaration *getAttributeDeclaration(const XMLCh *name
00209             , const XMLCh *compNamespace);
00210 
00219     XSTypeDefinition *getTypeDefinition(const XMLCh *name
00220             , const XMLCh *compNamespace);
00221 
00229     XSAttributeGroupDefinition *getAttributeGroup(const XMLCh *name
00230             , const XMLCh *compNamespace);
00231 
00239     XSModelGroupDefinition *getModelGroupDefinition(const XMLCh *name
00240             , const XMLCh *compNamespace);
00241 
00249     XSNotationDeclaration *getNotationDeclaration(const XMLCh *name
00250             , const XMLCh *compNamespace);
00251 
00261     XSObject *getXSObjectById(unsigned int  compId
00262                 , XSConstants::COMPONENT_TYPE compType);
00263 
00265 
00266     //----------------------------------
00270     XMLStringPool*  getURIStringPool();
00271 
00272     XSNamespaceItem* getNamespaceItem(const XMLCh* const key);
00273 
00281     XSObject* getXSObject(void* key);
00282 
00284 private:
00285 
00286     // -----------------------------------------------------------------------
00287     //  Helper methods
00288     // -----------------------------------------------------------------------
00289     void addGrammarToXSModel
00290     (
00291         XSNamespaceItem* namespaceItem
00292     );
00293     void addS4SToXSModel
00294     (
00295         XSNamespaceItem* const namespaceItem
00296         , RefHashTableOf<DatatypeValidator>* const builtInDV
00297     );
00298     void addComponentToNamespace
00299     (
00300          XSNamespaceItem* const namespaceItem
00301          , XSObject* const component
00302          , int componentIndex
00303          , bool addToXSModel = true
00304     );
00305 
00306     void addComponentToIdVector
00307     (
00308         XSObject* const component
00309         , int componentIndex
00310     );
00311 
00312     // -----------------------------------------------------------------------
00313     //  Unimplemented constructors and operators
00314     // -----------------------------------------------------------------------
00315     XSModel(const XSModel&);
00316     XSModel & operator=(const XSModel &);
00317 
00318 protected:
00319     friend class XSObjectFactory;
00320     friend class XSObject;
00321 
00322     // -----------------------------------------------------------------------
00323     //  data members
00324     // -----------------------------------------------------------------------
00325     // fMemoryManager:
00326     //  used for any memory allocations
00327     MemoryManager* const                    fMemoryManager;
00328  
00329     StringList*                             fNamespaceStringList;
00330     XSNamespaceItemList*                    fXSNamespaceItemList;
00331 
00332     RefVectorOf<XSObject>*                  fIdVector[XSConstants::MULTIVALUE_FACET];    
00333 
00334     /* Need a XSNamedMap for each component    top-level?
00335           ATTRIBUTE_DECLARATION     = 1,       
00336           ELEMENT_DECLARATION       = 2,        
00337           TYPE_DEFINITION           = 3,        
00338           ATTRIBUTE_USE             = 4,       no 
00339           ATTRIBUTE_GROUP_DEFINITION= 5,        
00340           MODEL_GROUP_DEFINITION    = 6,       
00341           MODEL_GROUP               = 7,       no 
00342           PARTICLE                  = 8,       no
00343           WILDCARD                  = 9,       no
00344           IDENTITY_CONSTRAINT       = 10,      no
00345           NOTATION_DECLARATION      = 11,       
00346           ANNOTATION                = 12,      no 
00347           FACET                     = 13,      no
00348           MULTIVALUE_FACET          = 14       no
00349     */
00350     XSNamedMap<XSObject>*                   fComponentMap[XSConstants::MULTIVALUE_FACET];
00351     XMLStringPool*                          fURIStringPool;
00352     XSAnnotationList*                       fXSAnnotationList;
00353     RefHashTableOf<XSNamespaceItem>*        fHashNamespace;
00354     XSObjectFactory*                        fObjFactory;
00355     RefVectorOf<XSNamespaceItem>*           fDeleteNamespace;
00356     XSModel*                                fParent;
00357     bool                                    fDeleteParent;
00358     bool                                    fAddedS4SGrammar;
00359 };
00360 
00361 inline XMLStringPool*  XSModel::getURIStringPool()
00362 {
00363     return fURIStringPool;
00364 }
00365 
00366 inline StringList *XSModel::getNamespaces()
00367 {
00368     return fNamespaceStringList;
00369 }
00370 
00371 inline XSNamespaceItemList *XSModel::getNamespaceItems()
00372 {
00373     return fXSNamespaceItemList;
00374 }
00375 
00376 XERCES_CPP_NAMESPACE_END
00377 
00378 #endif


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