You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2003/12/24 18:42:03 UTC
cvs commit: xml-xerces/c/src/xercesc/validators/schema TraverseSchema.cpp SchemaElementDecl.hpp SchemaElementDecl.cpp SchemaAttDef.hpp SchemaAttDef.cpp PSVIDefs.hpp ComplexTypeInfo.hpp ComplexTypeInfo.cpp
knoaman 2003/12/24 09:42:03
Modified: c/src/xercesc/framework/psvi XSSimpleTypeDefinition.hpp
XSNamespaceItem.hpp XSNamespaceItem.cpp XSModel.hpp
XSModel.cpp XSElementDeclaration.hpp
XSComplexTypeDefinition.hpp
XSComplexTypeDefinition.cpp
XSAttributeDeclaration.hpp
c/src/xercesc/internal XSObjectFactory.hpp
XSObjectFactory.cpp
c/src/xercesc/validators/schema TraverseSchema.cpp
SchemaElementDecl.hpp SchemaElementDecl.cpp
SchemaAttDef.hpp SchemaAttDef.cpp PSVIDefs.hpp
ComplexTypeInfo.hpp ComplexTypeInfo.cpp
Log:
Misc. PSVI updates
Revision Changes Path
1.10 +11 -1 xml-xerces/c/src/xercesc/framework/psvi/XSSimpleTypeDefinition.hpp
Index: XSSimpleTypeDefinition.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSSimpleTypeDefinition.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XSSimpleTypeDefinition.hpp 1 Dec 2003 23:23:26 -0000 1.9
+++ XSSimpleTypeDefinition.hpp 24 Dec 2003 17:42:02 -0000 1.10
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.10 2003/12/24 17:42:02 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.9 2003/12/01 23:23:26 neilg
* fix for bug 25118; thanks to Jeroen Witmond
*
@@ -428,6 +431,7 @@
, XSMultiValueFacetList* const xsMultiValueFacetList
, StringList* const patternList
);
+ void setPrimitiveType(XSSimpleTypeDefinition* const toSet);
friend class XSObjectFactory;
@@ -502,6 +506,12 @@
inline XSAnnotationList *XSSimpleTypeDefinition::getAnnotations()
{
return fXSAnnotationList;
+}
+
+inline void
+XSSimpleTypeDefinition::setPrimitiveType(XSSimpleTypeDefinition* const toSet)
+{
+ fPrimitiveOrItemType = toSet;
}
XERCES_CPP_NAMESPACE_END
1.8 +19 -8 xml-xerces/c/src/xercesc/framework/psvi/XSNamespaceItem.hpp
Index: XSNamespaceItem.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSNamespaceItem.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSNamespaceItem.hpp 1 Dec 2003 23:23:26 -0000 1.7
+++ XSNamespaceItem.hpp 24 Dec 2003 17:42:02 -0000 1.8
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.8 2003/12/24 17:42:02 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.7 2003/12/01 23:23:26 neilg
* fix for bug 25118; thanks to Jeroen Witmond
*
@@ -138,6 +141,13 @@
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
+ XSNamespaceItem
+ (
+ XSModel* const xsModel
+ , const XMLCh* const schemaNamespace
+ , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
+ );
+
//@};
/** @name Destructor */
@@ -234,7 +244,7 @@
/** methods needed by implementation */
//@{
- SchemaGrammar* getSchemaGrammar() const;
+
//@}
private:
@@ -247,6 +257,7 @@
protected:
friend class XSModel;
+ friend class XSObjectFactory;
// -----------------------------------------------------------------------
// data members
// -----------------------------------------------------------------------
@@ -275,20 +286,20 @@
*/
XSNamedMap<XSObject>* fComponentMap[XSConstants::MULTIVALUE_FACET];
XSAnnotationList* fXSAnnotationList;
-
RefHashTableOf<XSObject>* fHashMap[XSConstants::MULTIVALUE_FACET];
-
+ const XMLCh* fSchemaNamespace;
};
-inline SchemaGrammar* XSNamespaceItem::getSchemaGrammar() const
+inline XSAnnotationList* XSNamespaceItem::getAnnotations()
{
- return fGrammar;
+ return fXSAnnotationList;
}
-inline XSAnnotationList* XSNamespaceItem::getAnnotations()
+inline const XMLCh *XSNamespaceItem::getSchemaNamespace()
{
- return fXSAnnotationList;
+ return fSchemaNamespace;
}
+
XERCES_CPP_NAMESPACE_END
1.8 +61 -6 xml-xerces/c/src/xercesc/framework/psvi/XSNamespaceItem.cpp
Index: XSNamespaceItem.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSNamespaceItem.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSNamespaceItem.cpp 15 Dec 2003 17:23:48 -0000 1.7
+++ XSNamespaceItem.cpp 24 Dec 2003 17:42:02 -0000 1.8
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.8 2003/12/24 17:42:02 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.7 2003/12/15 17:23:48 cargilld
* psvi updates; cleanup revisits and bug fixes
*
@@ -102,6 +105,60 @@
, fGrammar(grammar)
, fXSModel(xsModel)
, fXSAnnotationList(0)
+ , fSchemaNamespace(grammar->getTargetNamespace())
+{
+ // Populate XSNamedMaps by going through the components
+ for (unsigned int i=0; i<XSConstants::MULTIVALUE_FACET; i++)
+ {
+ switch (i+1)
+ {
+ case XSConstants::ATTRIBUTE_DECLARATION:
+ case XSConstants::ELEMENT_DECLARATION:
+ case XSConstants::TYPE_DEFINITION:
+ case XSConstants::ATTRIBUTE_GROUP_DEFINITION:
+ case XSConstants::MODEL_GROUP_DEFINITION:
+ case XSConstants::NOTATION_DECLARATION:
+ fComponentMap[i] = new (fMemoryManager) XSNamedMap<XSObject>
+ (
+ 20, // size
+ 29, // modulus
+ fXSModel->getURIStringPool(),
+ false, // adoptElems
+ fMemoryManager
+ );
+ fHashMap[i] = new (fMemoryManager) RefHashTableOf<XSObject>
+ (
+ 29,
+ false,
+ fMemoryManager
+ );
+ break;
+ default:
+ // ATTRIBUTE_USE
+ // MODEL_GROUP
+ // PARTICLE
+ // IDENTITY_CONSTRAINT
+ // WILDCARD
+ // ANNOTATION
+ // FACET
+ // MULTIVALUE
+ fComponentMap[i] = 0;
+ fHashMap[i] = 0;
+ break;
+ }
+ }
+
+ fXSAnnotationList = new (manager) RefVectorOf <XSAnnotation> (5, false, manager);
+}
+
+XSNamespaceItem::XSNamespaceItem(XSModel* const xsModel,
+ const XMLCh* const schemaNamespace,
+ MemoryManager* const manager)
+ : fMemoryManager(manager)
+ , fGrammar(0)
+ , fXSModel(xsModel)
+ , fXSAnnotationList(0)
+ , fSchemaNamespace(schemaNamespace)
{
// Populate XSNamedMaps by going through the components
for (unsigned int i=0; i<XSConstants::MULTIVALUE_FACET; i++)
@@ -171,11 +228,6 @@
// ---------------------------------------------------------------------------
// XSNamespaceItem: access methods
// ---------------------------------------------------------------------------
-const XMLCh *XSNamespaceItem::getSchemaNamespace()
-{
- return fGrammar->getTargetNamespace();
-}
-
XSNamedMap<XSObject> *XSNamespaceItem::getComponents(XSConstants::COMPONENT_TYPE objectType)
{
return fComponentMap[objectType -1];
@@ -225,7 +277,10 @@
StringList *XSNamespaceItem::getDocumentLocations()
{
- return ((XMLSchemaDescriptionImpl*) fGrammar->getGrammarDescription())->getLocationHints();
+ if (fGrammar)
+ return ((XMLSchemaDescriptionImpl*) fGrammar->getGrammarDescription())->getLocationHints();
+
+ return 0;
}
XERCES_CPP_NAMESPACE_END
1.10 +25 -6 xml-xerces/c/src/xercesc/framework/psvi/XSModel.hpp
Index: XSModel.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSModel.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XSModel.hpp 26 Nov 2003 16:12:23 -0000 1.9
+++ XSModel.hpp 24 Dec 2003 17:42:02 -0000 1.10
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.10 2003/12/24 17:42:02 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.9 2003/11/26 16:12:23 knoaman
* Add a method to return the XSObject mapped to a schema grammar component
*
@@ -313,8 +316,26 @@
//@}
private:
- // Local Functions:
- void addGrammarToXSModel(XSNamespaceItem* namespaceItem);
+
+ // -----------------------------------------------------------------------
+ // Helper methods
+ // -----------------------------------------------------------------------
+ void addGrammarToXSModel
+ (
+ XSNamespaceItem* namespaceItem
+ );
+ void addS4SToXSModel
+ (
+ XSNamespaceItem* const namespaceItem
+ , RefHashTableOf<DatatypeValidator>* const builtInDV
+ );
+ void addComponentToNamespace
+ (
+ XSNamespaceItem* const namespaceItem
+ , XSObject* const component
+ , int componentIndex
+ , bool addToXSModel = true
+ );
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
@@ -355,16 +376,14 @@
MULTIVALUE_FACET = 14 no
*/
XSNamedMap<XSObject>* fComponentMap[XSConstants::MULTIVALUE_FACET];
-
XMLStringPool* fURIStringPool;
XSAnnotationList* fXSAnnotationList;
RefHashTableOf<XSNamespaceItem>* fHashNamespace;
XSObjectFactory* fObjFactory;
- RefVectorOf<XSNamespaceItem>* fDeleteNamespace;
-
+ RefVectorOf<XSNamespaceItem>* fDeleteNamespace;
XSModel* fParent;
bool fDeleteParent;
- bool fAddedBuiltinDatatypeValidators;
+ bool fAddedS4SGrammar;
};
inline XMLStringPool* XSModel::getURIStringPool()
1.15 +328 -209 xml-xerces/c/src/xercesc/framework/psvi/XSModel.cpp
Index: XSModel.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSModel.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XSModel.cpp 17 Dec 2003 00:18:34 -0000 1.14
+++ XSModel.cpp 24 Dec 2003 17:42:02 -0000 1.15
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.15 2003/12/24 17:42:02 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.14 2003/12/17 00:18:34 cargilld
* Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
*
@@ -123,147 +126,9 @@
XERCES_CPP_NAMESPACE_BEGIN
-// local constant
-static const XMLCh emptyString[] = {0};
-
-// the local routine to add a grammar to the XSModel
-void XSModel::addGrammarToXSModel(XSNamespaceItem* namespaceItem)
-{
- // First loop through top-level BUILTIN simple type definitions in the grammar...
- // all grammar's would be the same...
- RefHashTableOfEnumerator<DatatypeValidator> simpleEnum = RefHashTableOfEnumerator<DatatypeValidator> (namespaceItem->getSchemaGrammar()->getDatatypeRegistry()->getBuiltInRegistry(), false, fMemoryManager);
- while (simpleEnum.hasMoreElements())
- {
- DatatypeValidator& curSimple = simpleEnum.nextElement();
- XSSimpleTypeDefinition* xsSimple;
- xsSimple = fObjFactory->addOrFind(&curSimple, this);
- if (!fAddedBuiltinDatatypeValidators)
- {
- fComponentMap[XSConstants::TYPE_DEFINITION -1]->addElement(xsSimple, xsSimple->getName(), namespaceItem->getSchemaNamespace());
- }
- namespaceItem->fComponentMap[XSConstants::TYPE_DEFINITION -1]->addElement(xsSimple, xsSimple->getName(), namespaceItem->getSchemaNamespace());
- namespaceItem->fHashMap[XSConstants::TYPE_DEFINITION -1]->put((void *) xsSimple->getName(), xsSimple);
- }
- fAddedBuiltinDatatypeValidators = true;
- // end of simple BuiltIn loop
-
- // Loop through top-level attribute declarations in the grammar...
- RefHashTableOfEnumerator<XMLAttDef> attrEnum = RefHashTableOfEnumerator<XMLAttDef> (namespaceItem->getSchemaGrammar()->getAttributeDeclRegistry(), false, fMemoryManager);
-
- while (attrEnum.hasMoreElements())
- {
- SchemaAttDef* attDef = (SchemaAttDef*) &(attrEnum.nextElement());
- XSAttributeDeclaration* xsAttrDecl = fObjFactory->addOrFind(attDef, this);
- fComponentMap[XSConstants::ATTRIBUTE_DECLARATION-1]->addElement(xsAttrDecl, xsAttrDecl->getName(), namespaceItem->getSchemaNamespace());
- xsAttrDecl->setId(fAttributeDeclarationVector->size());
- fAttributeDeclarationVector->addElement(xsAttrDecl);
- namespaceItem->fComponentMap[XSConstants::ATTRIBUTE_DECLARATION-1]->addElement(xsAttrDecl, xsAttrDecl->getName(), namespaceItem->getSchemaNamespace());
- namespaceItem->fHashMap[XSConstants::ATTRIBUTE_DECLARATION -1]->put((void *) xsAttrDecl->getName(), xsAttrDecl);
- } // end of attribute loop
-
- // Loop through top-level elements in the grammar...
- RefHash3KeysIdPoolEnumerator<SchemaElementDecl> elemEnum = namespaceItem->getSchemaGrammar()->getElemEnumerator();
-
- while (elemEnum.hasMoreElements())
- {
- SchemaElementDecl& curElem = elemEnum.nextElement();
- if (curElem.getEnclosingScope() == Grammar::TOP_LEVEL_SCOPE)
- {
- XSElementDeclaration* xsElemDecl = fObjFactory->addOrFind(&curElem, this);
-
- fComponentMap[XSConstants::ELEMENT_DECLARATION-1]->addElement(xsElemDecl, xsElemDecl->getName(), namespaceItem->getSchemaNamespace());
- xsElemDecl->setId(fElementDeclarationVector->size());
- fElementDeclarationVector->addElement(xsElemDecl);
- namespaceItem->fComponentMap[XSConstants::ELEMENT_DECLARATION -1]->addElement(xsElemDecl, xsElemDecl->getName(), namespaceItem->getSchemaNamespace());
- namespaceItem->fHashMap[XSConstants::ELEMENT_DECLARATION -1]->put((void *) xsElemDecl->getName(), xsElemDecl);
- }
- } // end of element loop
-
- // Now loop through top-level User Defined simple type definitions in the grammar...
- DVHashTable* dvHT = namespaceItem->getSchemaGrammar()->getDatatypeRegistry()->getUserDefinedRegistry();
- if (dvHT)
- {
- RefHashTableOfEnumerator<DatatypeValidator> simpleUserEnum = RefHashTableOfEnumerator<DatatypeValidator> (dvHT, false, fMemoryManager);
- while (simpleUserEnum.hasMoreElements())
- {
- DatatypeValidator& curSimple = simpleUserEnum.nextElement();
- if (!curSimple.getAnonymous())
- {
- XSSimpleTypeDefinition* xsSimple = fObjFactory->addOrFind(&curSimple, this);
- fComponentMap[XSConstants::TYPE_DEFINITION -1]->addElement(xsSimple, xsSimple->getName(), namespaceItem->getSchemaNamespace());
- namespaceItem->fComponentMap[XSConstants::TYPE_DEFINITION -1]->addElement(xsSimple, xsSimple->getName(), namespaceItem->getSchemaNamespace());
- namespaceItem->fHashMap[XSConstants::TYPE_DEFINITION -1]->put((void *) xsSimple->getName(), xsSimple);
- }
- }
- // end of simple User loop
- }
-
- // Loop through top-level COMPLEX type definitions in the grammar...
- RefHashTableOfEnumerator<ComplexTypeInfo> complexEnum = RefHashTableOfEnumerator<ComplexTypeInfo> (namespaceItem->getSchemaGrammar()->getComplexTypeRegistry(), false, fMemoryManager);
- while (complexEnum.hasMoreElements())
- {
- ComplexTypeInfo& curComplex = complexEnum.nextElement();
- if (!curComplex.getAnonymous())
- {
- XSComplexTypeDefinition* xsComplex = fObjFactory->addOrFind(&curComplex, this);
- fComponentMap[XSConstants::TYPE_DEFINITION -1]->addElement(xsComplex, xsComplex->getName(), namespaceItem->getSchemaNamespace());
- namespaceItem->fComponentMap[XSConstants::TYPE_DEFINITION -1]->addElement(xsComplex, xsComplex->getName(), namespaceItem->getSchemaNamespace());
- namespaceItem->fHashMap[XSConstants::TYPE_DEFINITION -1]->put((void *) xsComplex->getName(), xsComplex);
- }
- } // end of type definition loop
-
- // Loop through top-level attribute group definitions in the grammar...
- RefHashTableOfEnumerator<XercesAttGroupInfo> attrGroupEnum = RefHashTableOfEnumerator<XercesAttGroupInfo> (namespaceItem->getSchemaGrammar()->getAttGroupInfoRegistry(), false, fMemoryManager);
- while (attrGroupEnum.hasMoreElements())
- {
- XercesAttGroupInfo& curAttrGroup = attrGroupEnum.nextElement();
- XSAttributeGroupDefinition* xsAttrGroupDecl = fObjFactory->createXSAttGroupDefinition(&curAttrGroup, this);
- fComponentMap[XSConstants::ATTRIBUTE_GROUP_DEFINITION -1]->addElement(xsAttrGroupDecl, xsAttrGroupDecl->getName(), namespaceItem->getSchemaNamespace());
- namespaceItem->fComponentMap[XSConstants::ATTRIBUTE_GROUP_DEFINITION -1]->addElement(xsAttrGroupDecl, xsAttrGroupDecl->getName(), namespaceItem->getSchemaNamespace());
- namespaceItem->fHashMap[XSConstants::ATTRIBUTE_GROUP_DEFINITION -1]->put((void *) xsAttrGroupDecl->getName(), xsAttrGroupDecl);
- } // end of attribute group loop
-
- // Loop through top-level model group definitions in the grammar...
- RefHashTableOfEnumerator<XercesGroupInfo> modelGroupEnum = RefHashTableOfEnumerator<XercesGroupInfo> (namespaceItem->getSchemaGrammar()->getGroupInfoRegistry(), false, fMemoryManager);
- while (modelGroupEnum.hasMoreElements())
- {
- XercesGroupInfo& curModelGroup = modelGroupEnum.nextElement();
- XSModelGroupDefinition* xsModelGroupDecl = fObjFactory->createXSModelGroupDefinition(&curModelGroup, this);
- fComponentMap[XSConstants::MODEL_GROUP_DEFINITION -1]->addElement(xsModelGroupDecl, xsModelGroupDecl->getName(), namespaceItem->getSchemaNamespace());
- namespaceItem->fComponentMap[XSConstants::MODEL_GROUP_DEFINITION -1]->addElement(xsModelGroupDecl, xsModelGroupDecl->getName(), namespaceItem->getSchemaNamespace());
- namespaceItem->fHashMap[XSConstants::MODEL_GROUP_DEFINITION -1]->put((void *) xsModelGroupDecl->getName(), xsModelGroupDecl);
- } // end of model group loop
-
- // Loop through notations in the grammar...
- NameIdPoolEnumerator<XMLNotationDecl> notationEnum = namespaceItem->getSchemaGrammar()->getNotationEnumerator();
- while (notationEnum.hasMoreElements())
- {
- XMLNotationDecl& notationDecl = notationEnum.nextElement();
- XSNotationDeclaration* xsNotationDecl = fObjFactory->addOrFind(¬ationDecl, this);
-
- fComponentMap[XSConstants::NOTATION_DECLARATION -1]->addElement(xsNotationDecl, xsNotationDecl->getName(), namespaceItem->getSchemaNamespace());
- namespaceItem->fComponentMap[XSConstants::NOTATION_DECLARATION -1]->addElement(xsNotationDecl, xsNotationDecl->getName(), namespaceItem->getSchemaNamespace());
- namespaceItem->fHashMap[XSConstants::NOTATION_DECLARATION -1]->put((void *) xsNotationDecl->getName(), xsNotationDecl);
- } // end of notation loop
-
- // Loop through annotations in the grammar...
- // As annotations are already created as XSAnnotations no need to create them
- // or store them in the XercesToXSMap.
- XSAnnotation* annot = namespaceItem->getSchemaGrammar()->getAnnotation();
- while (annot)
- {
- fXSAnnotationList->addElement(annot);
- namespaceItem->fXSAnnotationList->addElement(annot);
- annot = annot->getNext();
- } // end of annotation loop
-}
-
-/**
- * The constructor to be used when a grammar pool contains all needed info
- *
- * @param grammarPool the grammar pool containing the underlying data structures
- * @param manager The configurable memory manager
- */
+// ---------------------------------------------------------------------------
+// XSModel: Constructors and Destructor
+// ---------------------------------------------------------------------------
XSModel::XSModel( XMLGrammarPool *grammarPool
, MemoryManager* const manager)
: fMemoryManager(manager)
@@ -278,28 +143,28 @@
, fDeleteNamespace(0)
, fParent(0)
, fDeleteParent(false)
- , fAddedBuiltinDatatypeValidators(false)
+ , fAddedS4SGrammar(false)
{
fURIStringPool = grammarPool->getURIStringPool();
fObjFactory = new (fMemoryManager) XSObjectFactory(manager);
// Populate XSNamedMaps by going through the components
for (unsigned int i=0; i<XSConstants::MULTIVALUE_FACET; i++)
- {
- switch (i+1)
+ {
+ switch (i+1)
{
case XSConstants::ATTRIBUTE_DECLARATION:
case XSConstants::ELEMENT_DECLARATION:
case XSConstants::TYPE_DEFINITION:
case XSConstants::ATTRIBUTE_GROUP_DEFINITION:
case XSConstants::MODEL_GROUP_DEFINITION:
- case XSConstants::NOTATION_DECLARATION:
- fComponentMap[i] = new (fMemoryManager) XSNamedMap<XSObject>
+ case XSConstants::NOTATION_DECLARATION:
+ fComponentMap[i] = new (fMemoryManager) XSNamedMap<XSObject>
(
20, // size
29, // modulus
fURIStringPool,
- false, // adoptElems
+ false, // adoptElems
fMemoryManager
);
break;
@@ -316,7 +181,7 @@
break;
}
}
-
+
fNamespaceStringList = new (manager) RefArrayVectorOf <XMLCh>(10, true, manager);
fXSNamespaceItemList = new (manager) RefVectorOf <XSNamespaceItem>(10, true, manager);
fXSAnnotationList = new (manager) RefVectorOf <XSAnnotation> (10, false, manager);
@@ -327,42 +192,50 @@
// Loop through all grammars in the grammar pool to create the XSNamespaceItem's
// which will have access to Annotation Information which can be used later when
// we create all the XS components.
+ XSNamespaceItem* namespaceItem = 0;
RefHashTableOfEnumerator<Grammar> grammarEnum = grammarPool->getGrammarEnumerator();
-
while (grammarEnum.hasMoreElements())
{
SchemaGrammar& sGrammar = (SchemaGrammar&) grammarEnum.nextElement();
- if (sGrammar.getGrammarType() != Grammar::SchemaGrammarType)
+ if (sGrammar.getGrammarType() != Grammar::SchemaGrammarType ||
+ XMLString::equals(sGrammar.getTargetNamespace(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA))
continue;
-
+
// NOTE: In the grammarpool, preprocessed grammars without targetnamespace
// will use an empty string...
XMLCh* NameSpace = XMLString::replicate(sGrammar.getTargetNamespace(), manager);
fNamespaceStringList->addElement(NameSpace);
-
- XSNamespaceItem* namespaceItem = new (manager) XSNamespaceItem(this, &sGrammar, manager);
+ namespaceItem = new (manager) XSNamespaceItem(this, &sGrammar, manager);
fXSNamespaceItemList->addElement(namespaceItem);
-
fHashNamespace->put(NameSpace, namespaceItem);
}
-
+
// Now loop through all of the NamespaceItem's
+ // First, we add S4S namespace
unsigned int numberOfNamespaces = fXSNamespaceItemList->size();
- for (unsigned int j=0; j<numberOfNamespaces; j++)
- {
+ if (numberOfNamespaces)
+ {
+ namespaceItem = new (manager) XSNamespaceItem
+ (
+ this, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, manager
+ );
+
+ fNamespaceStringList->addElement
+ (
+ XMLString::replicate(SchemaSymbols::fgURI_SCHEMAFORSCHEMA,manager)
+ );
+ fXSNamespaceItemList->addElement(namespaceItem);
+ fHashNamespace->put
+ (
+ (void*) SchemaSymbols::fgURI_SCHEMAFORSCHEMA
+ , namespaceItem
+ );
+ }
+
+ for (unsigned int j = 0; j < numberOfNamespaces; j++)
addGrammarToXSModel(fXSNamespaceItemList->elementAt(j));
- } // end of namespaceItem loop
}
-/**
- * The constructor to be used when the XSModel must represent all
- * components in the union of an existing XSModel and a newly-created
- * Grammar(s) from the GrammarResolver
- *
- * @param baseModel the XSModel upon which this one is based
- * @param grammarResolver the grammar(s) whose components are to be merged
- * @param manager The configurable memory manager
- */
XSModel::XSModel( XSModel *baseModel
, GrammarResolver *grammarResolver
, MemoryManager* const manager)
@@ -378,29 +251,29 @@
, fObjFactory(0)
, fDeleteNamespace(0)
, fDeleteParent(true)
- , fAddedBuiltinDatatypeValidators(false)
+ , fAddedS4SGrammar(false)
{
- fURIStringPool = grammarResolver->getStringPool();
+ fURIStringPool = grammarResolver->getStringPool();
fObjFactory = new (manager) XSObjectFactory(manager);
unsigned int i;
// Populate XSNamedMaps by going through the components
for (i=0; i<XSConstants::MULTIVALUE_FACET; i++)
- {
- switch (i+1)
+ {
+ switch (i+1)
{
case XSConstants::ATTRIBUTE_DECLARATION:
case XSConstants::ELEMENT_DECLARATION:
case XSConstants::TYPE_DEFINITION:
case XSConstants::ATTRIBUTE_GROUP_DEFINITION:
case XSConstants::MODEL_GROUP_DEFINITION:
- case XSConstants::NOTATION_DECLARATION:
- fComponentMap[i] = new (fMemoryManager) XSNamedMap<XSObject>
+ case XSConstants::NOTATION_DECLARATION:
+ fComponentMap[i] = new (fMemoryManager) XSNamedMap<XSObject>
(
20, // size
29, // modulus
fURIStringPool,
- false, // adoptElems
+ false, // adoptElems
fMemoryManager
);
break;
@@ -417,7 +290,7 @@
break;
}
}
-
+
fNamespaceStringList = new (manager) RefArrayVectorOf <XMLCh>(10, true, manager);
fXSNamespaceItemList = new (manager) RefVectorOf <XSNamespaceItem>(10, false, manager);
fDeleteNamespace = new (manager) RefVectorOf <XSNamespaceItem>(10, true, manager);
@@ -428,17 +301,21 @@
if (fParent)
{
- if (fParent->fAddedBuiltinDatatypeValidators)
- fAddedBuiltinDatatypeValidators = true;
+ if (fParent->fAddedS4SGrammar)
+ fAddedS4SGrammar = true;
// Need to copy information from parent so it can be returned in this object...
for (i=0; i<fParent->fXSNamespaceItemList->size(); i++)
{
XSNamespaceItem* namespaceItem = fParent->fXSNamespaceItemList->elementAt(i);
fXSNamespaceItemList->addElement(namespaceItem);
-
- XMLCh* NameSpace = XMLString::replicate(namespaceItem->getSchemaNamespace(), manager);
- fNamespaceStringList->addElement(NameSpace);
+ fNamespaceStringList->addElement
+ (
+ XMLString::replicate
+ (
+ namespaceItem->getSchemaNamespace(), manager
+ )
+ );
}
for (i=0; i<XSConstants::MULTIVALUE_FACET; i++)
@@ -481,32 +358,56 @@
// XSNamespaceItem's so we can have access to the XSAnnotations...
ValueVectorOf<SchemaGrammar*>* grammarsToAdd = grammarResolver->getGrammarsToAddToXSModel();
unsigned int numberOfNamespaces = fXSNamespaceItemList->size();
- unsigned int numberOfNamespacesToAdd = grammarsToAdd->size();
- for (i=0; i < numberOfNamespacesToAdd; i++)
+ unsigned int numberOfNamespacesToAdd = 0;
+ for (i=0; i < grammarsToAdd->size(); i++)
{
- XMLCh* NameSpace = XMLString::replicate(grammarsToAdd->elementAt(i)->getTargetNamespace(), manager);
+ SchemaGrammar* lGrammar = grammarsToAdd->elementAt(i);
+ if (lGrammar->getGrammarType() != Grammar::SchemaGrammarType ||
+ XMLString::equals(lGrammar->getTargetNamespace(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA))
+ continue;
+
+ XMLCh* NameSpace = XMLString::replicate(lGrammar->getTargetNamespace(), manager);
fNamespaceStringList->addElement(NameSpace);
- XSNamespaceItem* namespaceItem = new (manager) XSNamespaceItem(this, grammarsToAdd->elementAt(i), manager);
+ XSNamespaceItem* namespaceItem = new (manager) XSNamespaceItem(this, lGrammar, manager);
fXSNamespaceItemList->addElement(namespaceItem);
-
fHashNamespace->put(NameSpace, namespaceItem);
+ fDeleteNamespace->addElement(namespaceItem);
+ ++numberOfNamespacesToAdd;
+ }
- fDeleteNamespace->addElement(namespaceItem);
+ // Add S4S namespace if needed
+ if (numberOfNamespacesToAdd && !fAddedS4SGrammar)
+ {
+ XSNamespaceItem* namespaceItem = new (manager) XSNamespaceItem
+ (
+ this, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, manager
+ );
+
+ fNamespaceStringList->addElement
+ (
+ XMLString::replicate(SchemaSymbols::fgURI_SCHEMAFORSCHEMA,manager)
+ );
+ fXSNamespaceItemList->addElement(namespaceItem);
+ fHashNamespace->put
+ (
+ (void*) SchemaSymbols::fgURI_SCHEMAFORSCHEMA , namespaceItem
+ );
+ fDeleteNamespace->addElement(namespaceItem);
}
-
- // Now loop through all of the newly created NamespaceItem's
+
+ // Now loop through all of the newly created NamespaceItem's
for (i=numberOfNamespaces; i<(numberOfNamespaces+numberOfNamespacesToAdd); i++)
- {
+ {
addGrammarToXSModel(fXSNamespaceItemList->elementAt(i));
} // end of namespaceItem loop
}
-XSModel::~XSModel()
+XSModel::~XSModel()
{
for (unsigned int i=0; i<XSConstants::MULTIVALUE_FACET; i++)
- {
- switch (i+1)
+ {
+ switch (i+1)
{
case XSConstants::ATTRIBUTE_DECLARATION:
case XSConstants::ELEMENT_DECLARATION:
@@ -515,11 +416,11 @@
case XSConstants::MODEL_GROUP_DEFINITION:
case XSConstants::NOTATION_DECLARATION:
delete fComponentMap[i];
- break;
+ break;
}
}
-
- delete fNamespaceStringList;
+
+ delete fNamespaceStringList;
delete fXSNamespaceItemList;
delete fXSAnnotationList;
delete fHashNamespace;
@@ -534,10 +435,228 @@
delete fParent;
}
+// ---------------------------------------------------------------------------
+// XSModel: Helper methods
+// ---------------------------------------------------------------------------
+void XSModel::addComponentToNamespace(XSNamespaceItem* const namespaceItem,
+ XSObject* const component,
+ int componentIndex,
+ bool addToXSModel)
+{
+ namespaceItem->fComponentMap[componentIndex]->addElement
+ (
+ component, component->getName(), namespaceItem->getSchemaNamespace()
+ );
+ namespaceItem->fHashMap[componentIndex]->put
+ (
+ (void *) component->getName(), component
+ );
+
+ if (addToXSModel)
+ {
+ fComponentMap[componentIndex]->addElement
+ (
+ component, component->getName(), namespaceItem->getSchemaNamespace()
+ );
+ }
+}
+
+void
+XSModel::addS4SToXSModel(XSNamespaceItem* const namespaceItem,
+ RefHashTableOf<DatatypeValidator>* const builtInDV)
+{
+ addComponentToNamespace
+ (
+ namespaceItem
+ , fObjFactory->addOrFind
+ (
+ ComplexTypeInfo::getAnyType
+ (
+ fURIStringPool->getId(XMLUni::fgZeroLenString)
+ )
+ , this
+ )
+ , XSConstants::TYPE_DEFINITION - 1
+ );
+
+ // Loop through built-in simple types
+ // First add 'anySimpleType' which is the base for the other built-ins
+ DatatypeValidator* dv = builtInDV->get(SchemaSymbols::fgDT_ANYSIMPLETYPE);
+ addComponentToNamespace
+ (
+ namespaceItem
+ , fObjFactory->addOrFind(dv, this, true)
+ , XSConstants::TYPE_DEFINITION - 1
+ );
+
+ // add remaining built-in
+ RefHashTableOfEnumerator<DatatypeValidator> simpleEnum =
+ RefHashTableOfEnumerator<DatatypeValidator> (builtInDV, false, fMemoryManager);
+ while (simpleEnum.hasMoreElements())
+ {
+ DatatypeValidator& curSimple = simpleEnum.nextElement();
+ if (&curSimple == dv)
+ continue;
+
+ addComponentToNamespace
+ (
+ namespaceItem
+ , fObjFactory->addOrFind(&curSimple, this)
+ , XSConstants::TYPE_DEFINITION - 1
+ );
+ }
+
+ // Set flag to indicate that we have added S4S grammar info
+ fAddedS4SGrammar = true;
+}
+
+
+void XSModel::addGrammarToXSModel(XSNamespaceItem* namespaceItem)
+{
+ // populate S4S namespace if needed
+ if (!fAddedS4SGrammar)
+ {
+ addS4SToXSModel
+ (
+ getNamespaceItem(SchemaSymbols::fgURI_SCHEMAFORSCHEMA)
+ , namespaceItem->fGrammar->getDatatypeRegistry()->getBuiltInRegistry()
+ );
+ }
+
+ // Loop through top-level attribute declarations in the grammar...
+ RefHashTableOfEnumerator<XMLAttDef> attrEnum = RefHashTableOfEnumerator<XMLAttDef> (namespaceItem->fGrammar->getAttributeDeclRegistry(), false, fMemoryManager);
+ while (attrEnum.hasMoreElements())
+ {
+ XSAttributeDeclaration* xsAttrDecl = fObjFactory->addOrFind
+ (
+ (SchemaAttDef*) &(attrEnum.nextElement()), this
+ );
+
+ xsAttrDecl->setId(fAttributeDeclarationVector->size());
+ fAttributeDeclarationVector->addElement(xsAttrDecl);
+ addComponentToNamespace
+ (
+ namespaceItem, xsAttrDecl, XSConstants::ATTRIBUTE_DECLARATION - 1
+ );
+ } // end of attribute loop
-// XSModel methods
+ // Loop through top-level elements in the grammar...
+ RefHash3KeysIdPoolEnumerator<SchemaElementDecl> elemEnum = namespaceItem->fGrammar->getElemEnumerator();
+ while (elemEnum.hasMoreElements())
+ {
+ SchemaElementDecl& curElem = elemEnum.nextElement();
+ if (curElem.getEnclosingScope() == Grammar::TOP_LEVEL_SCOPE)
+ {
+ XSElementDeclaration* xsElemDecl = fObjFactory->addOrFind
+ (
+ &curElem, this
+ );
+ xsElemDecl->setId(fElementDeclarationVector->size());
+ fElementDeclarationVector->addElement(xsElemDecl);
+ addComponentToNamespace
+ (
+ namespaceItem, xsElemDecl, XSConstants::ELEMENT_DECLARATION -1
+ );
+ }
+ } // end of element loop
+ // Now loop through top-level User Defined simple type definitions in the grammar...
+ DVHashTable* dvHT = namespaceItem->fGrammar->getDatatypeRegistry()->getUserDefinedRegistry();
+ if (dvHT)
+ {
+ RefHashTableOfEnumerator<DatatypeValidator> simpleUserEnum = RefHashTableOfEnumerator<DatatypeValidator> (dvHT, false, fMemoryManager);
+ while (simpleUserEnum.hasMoreElements())
+ {
+ DatatypeValidator& curSimple = simpleUserEnum.nextElement();
+ if (!curSimple.getAnonymous())
+ {
+ addComponentToNamespace
+ (
+ namespaceItem
+ , fObjFactory->addOrFind(&curSimple, this)
+ , XSConstants::TYPE_DEFINITION - 1
+ );
+ }
+ } // end of simple User loop
+ }
+
+ // Loop through top-level COMPLEX type definitions in the grammar...
+ RefHashTableOfEnumerator<ComplexTypeInfo> complexEnum = RefHashTableOfEnumerator<ComplexTypeInfo> (namespaceItem->fGrammar->getComplexTypeRegistry(), false, fMemoryManager);
+ while (complexEnum.hasMoreElements())
+ {
+ ComplexTypeInfo& curComplex = complexEnum.nextElement();
+ if (!curComplex.getAnonymous())
+ {
+ addComponentToNamespace
+ (
+ namespaceItem
+ , fObjFactory->addOrFind(&curComplex, this)
+ , XSConstants::TYPE_DEFINITION - 1
+ );
+ }
+ } // end of type definition loop
+
+ // Loop through top-level attribute group definitions in the grammar...
+ RefHashTableOfEnumerator<XercesAttGroupInfo> attrGroupEnum = RefHashTableOfEnumerator<XercesAttGroupInfo> (namespaceItem->fGrammar->getAttGroupInfoRegistry(), false, fMemoryManager);
+ while (attrGroupEnum.hasMoreElements())
+ {
+ addComponentToNamespace
+ (
+ namespaceItem
+ , fObjFactory->createXSAttGroupDefinition
+ (
+ &(attrGroupEnum.nextElement()), this
+ )
+ , XSConstants::ATTRIBUTE_GROUP_DEFINITION - 1
+ );
+ } // end of attribute group loop
+
+ // Loop through top-level model group definitions in the grammar...
+ RefHashTableOfEnumerator<XercesGroupInfo> modelGroupEnum = RefHashTableOfEnumerator<XercesGroupInfo> (namespaceItem->fGrammar->getGroupInfoRegistry(), false, fMemoryManager);
+ while (modelGroupEnum.hasMoreElements())
+ {
+ addComponentToNamespace
+ (
+ namespaceItem
+ , fObjFactory->createXSModelGroupDefinition
+ (
+ &(modelGroupEnum.nextElement()), this
+ )
+ , XSConstants::MODEL_GROUP_DEFINITION - 1
+ );
+ } // end of model group loop
+
+ // Loop through notations in the grammar...
+ NameIdPoolEnumerator<XMLNotationDecl> notationEnum = namespaceItem->fGrammar->getNotationEnumerator();
+ while (notationEnum.hasMoreElements())
+ {
+ addComponentToNamespace
+ (
+ namespaceItem
+ , fObjFactory->addOrFind(&(notationEnum.nextElement()), this)
+ , XSConstants::NOTATION_DECLARATION - 1
+ );
+ } // end of notation loop
+
+ // Loop through annotations in the grammar...
+ // As annotations are already created as XSAnnotations no need to create them
+ // or store them in the XercesToXSMap.
+ XSAnnotation* annot = namespaceItem->fGrammar->getAnnotation();
+ while (annot)
+ {
+ fXSAnnotationList->addElement(annot);
+ namespaceItem->fXSAnnotationList->addElement(annot);
+ annot = annot->getNext();
+ } // end of annotation loop
+}
+
+
+
+
+// ---------------------------------------------------------------------------
+// XSModel: Access methods
+// ---------------------------------------------------------------------------
/**
* [schema components]: a list of top-level components, i.e. element
* declarations, attribute declarations, etc.
@@ -565,14 +684,14 @@
* <code>objectType</code> and defined in the specified
* <code>namespace</code> or <code>null</code>.
*/
-XSNamedMap <XSObject> *XSModel::getComponentsByNamespace(XSConstants::COMPONENT_TYPE objectType,
+XSNamedMap <XSObject> *XSModel::getComponentsByNamespace(XSConstants::COMPONENT_TYPE objectType,
const XMLCh *compNamespace)
{
XSNamespaceItem* namespaceItem;
if (compNamespace)
namespaceItem = getNamespaceItem(compNamespace);
else
- namespaceItem = getNamespaceItem(emptyString);
+ namespaceItem = getNamespaceItem(XMLUni::fgZeroLenString);
if (namespaceItem)
return namespaceItem->getComponents(objectType);
@@ -602,8 +721,8 @@
if (compNamespace)
namespaceItem = getNamespaceItem(compNamespace);
else
- namespaceItem = getNamespaceItem(emptyString);
-
+ namespaceItem = getNamespaceItem(XMLUni::fgZeroLenString);
+
if (namespaceItem)
return namespaceItem->getElementDeclaration(name);
@@ -624,8 +743,8 @@
if (compNamespace)
namespaceItem = getNamespaceItem(compNamespace);
else
- namespaceItem = getNamespaceItem(emptyString);
-
+ namespaceItem = getNamespaceItem(XMLUni::fgZeroLenString);
+
if (namespaceItem)
return namespaceItem->getAttributeDeclaration(name);
@@ -647,7 +766,7 @@
if (compNamespace)
namespaceItem = getNamespaceItem(compNamespace);
else
- namespaceItem = getNamespaceItem(emptyString);
+ namespaceItem = getNamespaceItem(XMLUni::fgZeroLenString);
if (namespaceItem)
return namespaceItem->getTypeDefinition(name);
@@ -669,8 +788,8 @@
if (compNamespace)
namespaceItem = getNamespaceItem(compNamespace);
else
- namespaceItem = getNamespaceItem(emptyString);
-
+ namespaceItem = getNamespaceItem(XMLUni::fgZeroLenString);
+
if (namespaceItem)
return namespaceItem->getAttributeGroup(name);
@@ -691,8 +810,8 @@
if (compNamespace)
namespaceItem = getNamespaceItem(compNamespace);
else
- namespaceItem = getNamespaceItem(emptyString);
-
+ namespaceItem = getNamespaceItem(XMLUni::fgZeroLenString);
+
if (namespaceItem)
return namespaceItem->getModelGroupDefinition(name);
@@ -713,8 +832,8 @@
if (compNamespace)
namespaceItem = getNamespaceItem(compNamespace);
else
- namespaceItem = getNamespaceItem(emptyString);
-
+ namespaceItem = getNamespaceItem(XMLUni::fgZeroLenString);
+
if (namespaceItem)
return namespaceItem->getNotationDeclaration(name);
1.9 +12 -1 xml-xerces/c/src/xercesc/framework/psvi/XSElementDeclaration.hpp
Index: XSElementDeclaration.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSElementDeclaration.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XSElementDeclaration.hpp 1 Dec 2003 23:23:26 -0000 1.8
+++ XSElementDeclaration.hpp 24 Dec 2003 17:42:02 -0000 1.9
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.9 2003/12/24 17:42:02 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.8 2003/12/01 23:23:26 neilg
* fix for bug 25118; thanks to Jeroen Witmond
*
@@ -304,6 +307,9 @@
//@}
private:
+ void setEnclosingCTDefinition(XSComplexTypeDefinition* const toSet);
+ friend class XSObjectFactory;
+
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
@@ -375,6 +381,11 @@
inline void XSElementDeclaration::setTypeDefinition(XSTypeDefinition* typeDefinition)
{
fTypeDefinition = typeDefinition;
+}
+
+inline void XSElementDeclaration::setEnclosingCTDefinition(XSComplexTypeDefinition* const toSet)
+{
+ fEnclosingTypeDefinition = toSet;
}
XERCES_CPP_NAMESPACE_END
1.8 +15 -1 xml-xerces/c/src/xercesc/framework/psvi/XSComplexTypeDefinition.hpp
Index: XSComplexTypeDefinition.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSComplexTypeDefinition.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSComplexTypeDefinition.hpp 1 Dec 2003 23:23:26 -0000 1.7
+++ XSComplexTypeDefinition.hpp 24 Dec 2003 17:42:02 -0000 1.8
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.8 2003/12/24 17:42:02 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.7 2003/12/01 23:23:26 neilg
* fix for bug 25118; thanks to Jeroen Witmond
*
@@ -294,6 +297,12 @@
private:
+ /**
+ * Set the base type
+ */
+ void setBaseType(XSTypeDefinition* const xsBaseType);
+ friend class XSObjectFactory;
+
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
@@ -340,6 +349,11 @@
return fParticle;
}
+inline void
+XSComplexTypeDefinition::setBaseType(XSTypeDefinition* const xsBaseType)
+{
+ fBaseType = xsBaseType;
+}
XERCES_CPP_NAMESPACE_END
1.11 +4 -3 xml-xerces/c/src/xercesc/framework/psvi/XSComplexTypeDefinition.cpp
Index: XSComplexTypeDefinition.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSComplexTypeDefinition.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XSComplexTypeDefinition.cpp 19 Dec 2003 15:09:47 -0000 1.10
+++ XSComplexTypeDefinition.cpp 24 Dec 2003 17:42:02 -0000 1.11
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.11 2003/12/24 17:42:02 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.10 2003/12/19 15:09:47 knoaman
* PSVI: process 'final' information
*
@@ -182,12 +185,10 @@
XSConstants::DERIVATION_TYPE XSComplexTypeDefinition::getDerivationMethod() const
{
switch(fComplexTypeInfo->getDerivedBy()) {
- case SchemaSymbols::XSD_RESTRICTION:
- return XSConstants::DERIVATION_RESTRICTION;
case SchemaSymbols::XSD_EXTENSION:
return XSConstants::DERIVATION_EXTENSION;
default:
- return XSConstants::DERIVATION_NONE;
+ return XSConstants::DERIVATION_RESTRICTION;
}
}
1.8 +15 -1 xml-xerces/c/src/xercesc/framework/psvi/XSAttributeDeclaration.hpp
Index: XSAttributeDeclaration.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSAttributeDeclaration.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSAttributeDeclaration.hpp 1 Dec 2003 23:23:26 -0000 1.7
+++ XSAttributeDeclaration.hpp 24 Dec 2003 17:42:02 -0000 1.8
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.8 2003/12/24 17:42:02 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.7 2003/12/01 23:23:26 neilg
* fix for bug 25118; thanks to Jeroen Witmond
*
@@ -229,6 +232,9 @@
private:
+ void setEnclosingCTDefinition(XSComplexTypeDefinition* const toSet);
+ friend class XSObjectFactory;
+
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
@@ -274,6 +280,14 @@
inline XSComplexTypeDefinition *XSAttributeDeclaration::getEnclosingCTDefinition()
{
return fEnclosingCTDefinition;
+}
+
+inline void XSAttributeDeclaration::setEnclosingCTDefinition
+(
+ XSComplexTypeDefinition* const toSet
+)
+{
+ fEnclosingCTDefinition = toSet;
}
XERCES_CPP_NAMESPACE_END
1.6 +5 -0 xml-xerces/c/src/xercesc/internal/XSObjectFactory.hpp
Index: XSObjectFactory.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XSObjectFactory.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSObjectFactory.hpp 17 Dec 2003 20:50:35 -0000 1.5
+++ XSObjectFactory.hpp 24 Dec 2003 17:42:02 -0000 1.6
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.6 2003/12/24 17:42:02 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.5 2003/12/17 20:50:35 knoaman
* PSVI: fix for annotation of attributes in attributeGroup/derived types
*
@@ -139,12 +142,14 @@
(
SchemaAttDef* const attDef
, XSModel* const xsModel
+ , XSComplexTypeDefinition* const enclosingTypeDef = 0
);
XSSimpleTypeDefinition* addOrFind
(
DatatypeValidator* const validator
, XSModel* const xsModel
+ , bool isAnySimpleType = false
);
XSElementDeclaration* addOrFind
1.13 +104 -43 xml-xerces/c/src/xercesc/internal/XSObjectFactory.cpp
Index: XSObjectFactory.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XSObjectFactory.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XSObjectFactory.cpp 17 Dec 2003 20:50:35 -0000 1.12
+++ XSObjectFactory.cpp 24 Dec 2003 17:42:02 -0000 1.13
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.13 2003/12/24 17:42:02 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.12 2003/12/17 20:50:35 knoaman
* PSVI: fix for annotation of attributes in attributeGroup/derived types
*
@@ -318,32 +321,36 @@
return 0;
}
-XSAttributeDeclaration* XSObjectFactory::addOrFind(SchemaAttDef* const attDef,
- XSModel* const xsModel)
+XSAttributeDeclaration*
+XSObjectFactory::addOrFind(SchemaAttDef* const attDef,
+ XSModel* const xsModel,
+ XSComplexTypeDefinition* const enclosingTypeDef)
{
XSAttributeDeclaration* xsObj = (XSAttributeDeclaration*) getObjectFromMap(attDef, xsModel);
- if (!xsObj)
+
+ if (xsObj)
+ {
+ if (xsObj->getScope() == XSConstants::SCOPE_LOCAL
+ && xsObj->getEnclosingCTDefinition() == 0
+ && enclosingTypeDef)
+ xsObj->setEnclosingCTDefinition(enclosingTypeDef);
+ }
+ else
{
XSSimpleTypeDefinition* xsType = 0;
if (attDef->getDatatypeValidator())
xsType = addOrFind(attDef->getDatatypeValidator(), xsModel);
- // need grammar to determine if scope is global:
-
XSConstants::SCOPE scope = XSConstants::SCOPE_ABSENT;
XSComplexTypeDefinition* enclosingCTDefinition = 0;
- XSNamespaceItem* namespaceItem = xsModel->getNamespaceItem(xsModel->getURIStringPool()->getValueForId(attDef->getAttName()->getURI()));
- if (namespaceItem)
+
+ if (attDef->getPSVIScope() == PSVIDefs::SCP_GLOBAL)
+ scope = XSConstants::SCOPE_GLOBAL;
+ else if (attDef->getPSVIScope() == PSVIDefs::SCP_LOCAL)
{
- // REVISIT: what if local name and global name are the same???
- if (namespaceItem->getSchemaGrammar()->getAttributeDeclRegistry()->get(attDef))
- scope = XSConstants::SCOPE_GLOBAL;
- else if (attDef->getEnclosingCT())
- {
- scope = XSConstants::SCOPE_LOCAL;
- enclosingCTDefinition = addOrFind(attDef->getEnclosingCT(), xsModel);
- }
- }
+ scope = XSConstants::SCOPE_LOCAL;
+ enclosingCTDefinition = enclosingTypeDef;
+ }
xsObj = new (fMemoryManager) XSAttributeDeclaration
(
@@ -363,25 +370,23 @@
XSSimpleTypeDefinition*
XSObjectFactory::addOrFind(DatatypeValidator* const validator,
- XSModel* const xsModel)
+ XSModel* const xsModel,
+ bool isAnySimpleType)
{
XSSimpleTypeDefinition* xsObj = (XSSimpleTypeDefinition*) getObjectFromMap(validator, xsModel);
-
if (!xsObj)
{
XSSimpleTypeDefinition* baseType = 0;
XSSimpleTypeDefinitionList* memberTypes = 0;
XSSimpleTypeDefinition* primitiveOrItemType = 0;
XSSimpleTypeDefinition::VARIETY typeVariety = XSSimpleTypeDefinition::VARIETY_ATOMIC;
+ bool primitiveTypeSelf = false;
- // compute fBaseType
- DatatypeValidator* baseDV = validator->getBaseValidator();
- if (baseDV)
- baseType = addOrFind(baseDV, xsModel);
-
//REVISIT: the getFixed method is protected so added friend XSObjectFactory
// to DatatypeValidator class...
DatatypeValidator::ValidatorType dvType = validator->getType();
+ DatatypeValidator* baseDV = validator->getBaseValidator();
+
if (dvType == DatatypeValidator::Union)
{
typeVariety = XSSimpleTypeDefinition::VARIETY_UNION;
@@ -393,26 +398,53 @@
for (unsigned int i=0; i<size; i++)
memberTypes->addElement(addOrFind(membersDV->elementAt(i), xsModel));
}
+
+ if (baseDV)
+ {
+ baseType = addOrFind(baseDV, xsModel);
+ }
+ else
+ {
+ baseType = (XSSimpleTypeDefinition*) xsModel->getTypeDefinition
+ (
+ SchemaSymbols::fgDT_ANYSIMPLETYPE
+ , SchemaSymbols::fgURI_SCHEMAFORSCHEMA
+ );
+ }
}
else if (dvType == DatatypeValidator::List)
{
typeVariety = XSSimpleTypeDefinition::VARIETY_LIST;
-
- while (baseDV && (baseDV->getType() == DatatypeValidator::List))
+ if (baseDV->getType() == DatatypeValidator::List)
{
- addOrFind(baseDV, xsModel);
- baseDV = baseDV->getBaseValidator();
+ baseType = addOrFind(baseDV, xsModel);
+ primitiveOrItemType = baseType->getItemType();
}
- if (baseDV)
+ else
+ {
+ baseType = (XSSimpleTypeDefinition*) xsModel->getTypeDefinition
+ (
+ SchemaSymbols::fgDT_ANYSIMPLETYPE
+ , SchemaSymbols::fgURI_SCHEMAFORSCHEMA
+ );
primitiveOrItemType = addOrFind(baseDV, xsModel);
+ }
}
- else
+ else if (!isAnySimpleType)
{
- // REVISIT: assume ATOMIC but what about VARIETY_ABSENT?
- while (baseDV)
+ if (baseDV)
{
- primitiveOrItemType = addOrFind(baseDV, xsModel);
- baseDV = baseDV->getBaseValidator();
+ baseType = addOrFind(baseDV, xsModel);
+ primitiveOrItemType = baseType->getPrimitiveType();
+ }
+ else // built-in
+ {
+ baseType = (XSSimpleTypeDefinition*) xsModel->getTypeDefinition
+ (
+ SchemaSymbols::fgDT_ANYSIMPLETYPE
+ , SchemaSymbols::fgURI_SCHEMAFORSCHEMA
+ );
+ primitiveTypeSelf = true;
}
}
@@ -429,6 +461,9 @@
);
putObjectInMap(validator, xsObj, xsModel);
+ if (primitiveTypeSelf)
+ xsObj->setPrimitiveType(xsObj);
+
// process facets
if (validator->getFacetsDefined())
processFacets(validator, xsModel, xsObj);
@@ -443,7 +478,12 @@
XSComplexTypeDefinition* const enclosingTypeDef)
{
XSElementDeclaration* xsObj = (XSElementDeclaration*) getObjectFromMap(elemDecl, xsModel);
- if (!xsObj)
+ if (xsObj)
+ {
+ if (!xsObj->getEnclosingCTDefinition() && enclosingTypeDef)
+ xsObj->setEnclosingCTDefinition(enclosingTypeDef);
+ }
+ else
{
XSElementDeclaration* xsSubElem = 0;
XSTypeDefinition* xsType = 0;
@@ -491,10 +531,9 @@
}
XSConstants::SCOPE elemScope = XSConstants::SCOPE_ABSENT;
-
- if (enclosingTypeDef)
+ if (elemDecl->getPSVIScope() == PSVIDefs::SCP_LOCAL)
elemScope = XSConstants::SCOPE_LOCAL;
- else if (elemDecl->getEnclosingScope() == Grammar::TOP_LEVEL_SCOPE)
+ else if (elemDecl->getPSVIScope() == PSVIDefs::SCP_GLOBAL)
elemScope = XSConstants::SCOPE_GLOBAL;
xsObj = new (fMemoryManager) XSElementDeclaration
@@ -516,6 +555,15 @@
xsType = addOrFind(elemDecl->getComplexTypeInfo(), xsModel);
xsObj->setTypeDefinition(xsType);
}
+ else if (!xsType)
+ {
+ xsType = xsModel->getTypeDefinition
+ (
+ SchemaSymbols::fgATTVAL_ANYTYPE
+ , SchemaSymbols::fgURI_SCHEMAFORSCHEMA
+ );
+ xsObj->setTypeDefinition(xsType);
+ }
}
return xsObj;
@@ -553,10 +601,15 @@
}
// compute fBase
- if (typeInfo->getBaseComplexTypeInfo())
+ bool isAnyType = false;
+ if (typeInfo->getBaseComplexTypeInfo() == typeInfo) // case of anyType
+ isAnyType = true;
+ else if (typeInfo->getBaseComplexTypeInfo())
xsBaseType = addOrFind(typeInfo->getBaseComplexTypeInfo(), xsModel);
else if (typeInfo->getBaseDatatypeValidator())
xsBaseType = addOrFind(typeInfo->getBaseDatatypeValidator(), xsModel);
+ else // base is anyType
+ xsBaseType = xsModel->getTypeDefinition(SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
// compute particle
ContentSpecNode* contentSpec = typeInfo->getContentSpec();
@@ -576,6 +629,9 @@
, fMemoryManager
);
putObjectInMap(typeInfo, xsObj, xsModel);
+
+ if (isAnyType)
+ xsObj->setBaseType(xsObj);
if (typeInfo->hasAttDefs())
{
@@ -589,7 +645,7 @@
if (attDef.getBaseAttDecl())
xsAttDecl = addOrFind(attDef.getBaseAttDecl(), xsModel);
else
- xsAttDecl = addOrFind(&attDef, xsModel);
+ xsAttDecl = addOrFind(&attDef, xsModel, xsObj);
XSAttributeUse* attUse = createXSAttributeUse(xsAttDecl, xsModel);
xsAttList->addElement(attUse);
@@ -603,7 +659,8 @@
{
SchemaElementDecl* elemDecl = typeInfo->elementAt(j);
- if (elemDecl->getEnclosingScope() == typeInfo->getScopeDefined())
+ if (elemDecl->getEnclosingScope() == typeInfo->getScopeDefined()
+ && elemDecl->getPSVIScope() == PSVIDefs::SCP_LOCAL)
addOrFind(elemDecl, xsModel, xsObj);
}
}
@@ -806,9 +863,13 @@
XSAnnotation* annot = 0;
for (unsigned int i=0; i<namespaceItemList->size(); i++)
{
- annot = namespaceItemList->elementAt(i)->getSchemaGrammar()->getAnnotation(key);
- if (annot)
- return annot;
+ XSNamespaceItem* nsItem = namespaceItemList->elementAt(i);
+ if (nsItem->fGrammar)
+ {
+ annot = nsItem->fGrammar->getAnnotation(key);
+ if (annot)
+ return annot;
+ }
}
if (xsModel->fParent)
1.104 +22 -18 xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp
Index: TraverseSchema.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -r1.103 -r1.104
--- TraverseSchema.cpp 24 Dec 2003 15:24:16 -0000 1.103
+++ TraverseSchema.cpp 24 Dec 2003 17:42:02 -0000 1.104
@@ -390,7 +390,7 @@
fTargetNSURIString = fSchemaGrammar->getTargetNamespace();
fTargetNSURI = fURIStringPool->addOrFind(fTargetNSURIString);
- XMLSchemaDescription* gramDesc = (XMLSchemaDescription*) fSchemaGrammar->getGrammarDescription();
+ XMLSchemaDescription* gramDesc = (XMLSchemaDescription*) fSchemaGrammar->getGrammarDescription();
gramDesc->setTargetNamespace(fTargetNSURIString);
fGrammarResolver->putGrammar(fSchemaGrammar);
@@ -2396,24 +2396,22 @@
if (!janAnnot.isDataNull())
fSchemaGrammar->putAnnotation(attDef, janAnnot.release());
- if (topLevel) {
+ if (topLevel)
+ {
fAttributeDeclRegistry->put((void*) fStringPool->getValueForId(fStringPool->addOrFind(name)), attDef);
+ attDef->setPSVIScope(PSVIDefs::SCP_GLOBAL);
}
- else {
-
- bool toClone = false;
-
- if (typeInfo) {
- toClone = true;
+ else
+ {
+ if (typeInfo)
+ {
typeInfo->addAttDef(attDef);
if (!fCurrentAttGroupInfo)
- {
- attDef->setEnclosingCT(typeInfo);
- }
+ attDef->setPSVIScope(PSVIDefs::SCP_LOCAL);
}
if (fCurrentAttGroupInfo) {
- fCurrentAttGroupInfo->addAttDef(attDef, toClone);
+ fCurrentAttGroupInfo->addAttDef(attDef, (typeInfo != 0));
}
}
}
@@ -2505,14 +2503,16 @@
if (!janAnnot.isDataNull())
fSchemaGrammar->putAnnotation(elemDecl, janAnnot.release());
- if (fCurrentGroupInfo &&
- elemDecl->getEnclosingScope() == fCurrentGroupInfo->getScope()) {
- fCurrentGroupInfo->addElement(elemDecl);
- }
-
if (fCurrentComplexType &&
elemDecl->getEnclosingScope() == fCurrentComplexType->getScopeDefined()) {
fCurrentComplexType->addElement(elemDecl);
+ elemDecl->setPSVIScope(PSVIDefs::SCP_LOCAL);
+ }
+
+ if (fCurrentGroupInfo &&
+ elemDecl->getEnclosingScope() == fCurrentGroupInfo->getScope()) {
+ fCurrentGroupInfo->addElement(elemDecl);
+ elemDecl->setPSVIScope(PSVIDefs::SCP_ABSENT);
}
}
@@ -5387,6 +5387,9 @@
elemDecl->setCreateReason(XMLElementDecl::Declared);
+ if (topLevel)
+ elemDecl->setPSVIScope(PSVIDefs::SCP_GLOBAL);
+
// process attributes
processElemDeclAttrs(elem, elemDecl, valConstraint, topLevel);
@@ -5544,6 +5547,7 @@
0, fGrammarPoolMemoryManager);
attDef->setBaseAttDecl(refAttDef);
+ attDef->setPSVIScope(PSVIDefs::SCP_GLOBAL);
if (refAttDefType == XMLAttDef::Fixed) {
if (required && !invalidAttUse) {
1.19 +17 -1 xml-xerces/c/src/xercesc/validators/schema/SchemaElementDecl.hpp
Index: SchemaElementDecl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaElementDecl.hpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- SchemaElementDecl.hpp 12 Dec 2003 18:36:37 -0000 1.18
+++ SchemaElementDecl.hpp 24 Dec 2003 17:42:03 -0000 1.19
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.19 2003/12/24 17:42:03 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.18 2003/12/12 18:36:37 peiyongz
* getObjectType()
*
@@ -207,7 +210,6 @@
, ModelTypes_Count
};
-
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
@@ -266,6 +268,7 @@
const SchemaAttDef* getAttWildCard() const;
SchemaAttDef* getAttWildCard();
ModelTypes getModelType() const;
+ PSVIDefs::PSVIScope getPSVIScope() const;
DatatypeValidator* getDatatypeValidator() const;
int getEnclosingScope() const;
int getFinalSet() const;
@@ -381,6 +384,7 @@
// -----------------------------------------------------------------------
void setElemId(unsigned int elemId);
void setModelType(const SchemaElementDecl::ModelTypes toSet);
+ void setPSVIScope(const PSVIDefs::PSVIScope toSet);
void setDatatypeValidator(DatatypeValidator* newDatatypeValidator);
void setEnclosingScope(const int enclosingScope);
void setFinalSet(const int finalSet);
@@ -509,6 +513,7 @@
// -----------------------------------------------------------------------
ModelTypes fModelType;
+ PSVIDefs::PSVIScope fPSVIScope;
DatatypeValidator* fDatatypeValidator;
int fEnclosingScope;
int fFinalSet;
@@ -584,6 +589,11 @@
return fModelType;
}
+inline PSVIDefs::PSVIScope SchemaElementDecl::getPSVIScope() const
+{
+ return fPSVIScope;
+}
+
inline DatatypeValidator* SchemaElementDecl::getDatatypeValidator() const
{
@@ -813,6 +823,12 @@
SchemaElementDecl::setModelType(const SchemaElementDecl::ModelTypes toSet)
{
fModelType = toSet;
+}
+
+inline void
+SchemaElementDecl::setPSVIScope(const PSVIDefs::PSVIScope toSet)
+{
+ fPSVIScope = toSet;
}
inline void SchemaElementDecl::setDatatypeValidator(DatatypeValidator* newDatatypeValidator)
1.18 +6 -0 xml-xerces/c/src/xercesc/validators/schema/SchemaElementDecl.cpp
Index: SchemaElementDecl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaElementDecl.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- SchemaElementDecl.cpp 17 Dec 2003 00:18:40 -0000 1.17
+++ SchemaElementDecl.cpp 24 Dec 2003 17:42:03 -0000 1.18
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.18 2003/12/24 17:42:03 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.17 2003/12/17 00:18:40 cargilld
* Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
*
@@ -183,6 +186,7 @@
SchemaElementDecl::SchemaElementDecl(MemoryManager* const manager) :
XMLElementDecl(manager)
, fModelType(Any)
+ , fPSVIScope(PSVIDefs::SCP_ABSENT)
, fDatatypeValidator(0)
, fEnclosingScope(Grammar::TOP_LEVEL_SCOPE)
, fBlockSet(0)
@@ -212,6 +216,7 @@
, MemoryManager* const manager) :
XMLElementDecl(manager)
, fModelType(type)
+ , fPSVIScope(PSVIDefs::SCP_ABSENT)
, fDatatypeValidator(0)
, fEnclosingScope(enclosingScope)
, fBlockSet(0)
@@ -240,6 +245,7 @@
, MemoryManager* const manager) :
XMLElementDecl(manager)
, fModelType(type)
+ , fPSVIScope(PSVIDefs::SCP_ABSENT)
, fDatatypeValidator(0)
, fEnclosingScope(enclosingScope)
, fBlockSet(0)
1.11 +23 -5 xml-xerces/c/src/xercesc/validators/schema/SchemaAttDef.hpp
Index: SchemaAttDef.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaAttDef.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- SchemaAttDef.hpp 17 Dec 2003 20:50:35 -0000 1.10
+++ SchemaAttDef.hpp 24 Dec 2003 17:42:03 -0000 1.11
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.11 2003/12/24 17:42:03 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.10 2003/12/17 20:50:35 knoaman
* PSVI: fix for annotation of attributes in attributeGroup/derived types
*
@@ -264,9 +267,14 @@
QName* getAttName() const;
DatatypeValidator* getDatatypeValidator() const;
ValueVectorOf<unsigned int>* getNamespaceList() const;
- ComplexTypeInfo* getEnclosingCT() const;
const SchemaAttDef* getBaseAttDecl() const;
SchemaAttDef* getBaseAttDecl();
+ PSVIDefs::PSVIScope getPSVIScope() const;
+
+ /*
+ * @deprecated
+ */
+ ComplexTypeInfo* getEnclosingCT() const;
// -----------------------------------------------------------------------
// Setter methods
@@ -281,6 +289,7 @@
void setDatatypeValidator(DatatypeValidator* newDatatypeValidator);
void setAnyDatatypeValidator(DatatypeValidator* newDatatypeValidator);
void setBaseAttDecl(SchemaAttDef* const attDef);
+ void setPSVIScope(const PSVIDefs::PSVIScope toSet);
/*
* @deprecated
@@ -350,7 +359,7 @@
ValueVectorOf<unsigned int>* fNamespaceList;
PSVIDefs::Validity fValidity;
PSVIDefs::Validation fValidation;
- ComplexTypeInfo* fEnclosingCT;
+ PSVIDefs::PSVIScope fPSVIScope;
SchemaAttDef* fBaseAttDecl;
};
@@ -486,7 +495,7 @@
inline ComplexTypeInfo* SchemaAttDef::getEnclosingCT() const
{
- return fEnclosingCT;
+ return 0;
}
inline SchemaAttDef* SchemaAttDef::getBaseAttDecl()
@@ -499,6 +508,11 @@
return fBaseAttDecl;
}
+inline PSVIDefs::PSVIScope SchemaAttDef::getPSVIScope() const
+{
+ return fPSVIScope;
+}
+
// ---------------------------------------------------------------------------
// SchemaAttDef: Setter methods
// ---------------------------------------------------------------------------
@@ -556,14 +570,18 @@
fValidation = PSVIDefs::NONE;
}
-inline void SchemaAttDef::setEnclosingCT(ComplexTypeInfo* complexTypeInfo)
+inline void SchemaAttDef::setEnclosingCT(ComplexTypeInfo*)
{
- fEnclosingCT = complexTypeInfo;
}
inline void SchemaAttDef::setBaseAttDecl(SchemaAttDef* const attDef)
{
fBaseAttDecl = attDef;
+}
+
+inline void SchemaAttDef::setPSVIScope(const PSVIDefs::PSVIScope toSet)
+{
+ fPSVIScope = toSet;
}
XERCES_CPP_NAMESPACE_END
1.12 +8 -7 xml-xerces/c/src/xercesc/validators/schema/SchemaAttDef.cpp
Index: SchemaAttDef.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaAttDef.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- SchemaAttDef.cpp 17 Dec 2003 20:50:35 -0000 1.11
+++ SchemaAttDef.cpp 24 Dec 2003 17:42:03 -0000 1.12
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.12 2003/12/24 17:42:03 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.11 2003/12/17 20:50:35 knoaman
* PSVI: fix for annotation of attributes in attributeGroup/derived types
*
@@ -137,7 +140,7 @@
, fNamespaceList(0)
, fValidity(PSVIDefs::UNKNOWN)
, fValidation(PSVIDefs::NONE)
- , fEnclosingCT(0)
+ , fPSVIScope(PSVIDefs::SCP_ABSENT)
, fBaseAttDecl(0)
{
}
@@ -156,7 +159,7 @@
, fNamespaceList(0)
, fValidity(PSVIDefs::UNKNOWN)
, fValidation(PSVIDefs::NONE)
- , fEnclosingCT(0)
+ , fPSVIScope(PSVIDefs::SCP_ABSENT)
, fBaseAttDecl(0)
{
fAttName = new (manager) QName(prefix, localPart, uriId, manager);
@@ -179,7 +182,7 @@
, fNamespaceList(0)
, fValidity(PSVIDefs::UNKNOWN)
, fValidation(PSVIDefs::NONE)
- , fEnclosingCT(0)
+ , fPSVIScope(PSVIDefs::SCP_ABSENT)
, fBaseAttDecl(0)
{
fAttName = new (manager) QName(prefix, localPart, uriId, manager);
@@ -198,7 +201,7 @@
, fNamespaceList(0)
, fValidity(other->fValidity)
, fValidation(other->fValidation)
- , fEnclosingCT(other->fEnclosingCT)
+ , fPSVIScope(other->fPSVIScope)
, fBaseAttDecl(other->fBaseAttDecl)
{
QName* otherName = other->getAttName();
@@ -254,7 +257,6 @@
serEng<<(int)fValidity;
serEng<<(int)fValidation;
- serEng<<fEnclosingCT;
serEng<<fBaseAttDecl;
}
else
@@ -277,8 +279,7 @@
serEng>>i;
fValidation = (PSVIDefs::Validation)i;
-
- serEng>>fEnclosingCT;
+
serEng>>fBaseAttDecl;
}
}
1.2 +6 -1 xml-xerces/c/src/xercesc/validators/schema/PSVIDefs.hpp
Index: PSVIDefs.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/PSVIDefs.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PSVIDefs.hpp 29 Jan 2003 19:47:42 -0000 1.1
+++ PSVIDefs.hpp 24 Dec 2003 17:42:03 -0000 1.2
@@ -79,7 +79,12 @@
COMPLEX = 2
};
-
+ enum PSVIScope
+ {
+ SCP_ABSENT // declared in group/attribute group
+ , SCP_GLOBAL // global decalarion or ref
+ , SCP_LOCAL // local declaration
+ };
};
XERCES_CPP_NAMESPACE_END
1.19 +15 -1 xml-xerces/c/src/xercesc/validators/schema/ComplexTypeInfo.hpp
Index: ComplexTypeInfo.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/ComplexTypeInfo.hpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- ComplexTypeInfo.hpp 17 Dec 2003 00:18:40 -0000 1.18
+++ ComplexTypeInfo.hpp 24 Dec 2003 17:42:03 -0000 1.19
@@ -192,6 +192,18 @@
, XMLValidator* const pValidator
) ;
+ /**
+ * Return a singleton that represents 'anyType'
+ *
+ * @param emptyNSId the uri id of the empty namespace
+ */
+ static ComplexTypeInfo* getAnyType(unsigned int emptyNSId);
+
+ /**
+ * Notification that lazy data has been deleted
+ */
+ static void reinitAnyType();
+
/***
* Support for Serialization/De-serialization
***/
@@ -249,6 +261,8 @@
unsigned int fContentSpecOrgURISize;
XSDLocator* fLocator;
MemoryManager* fMemoryManager;
+
+ static ComplexTypeInfo* fAnyType;
};
// ---------------------------------------------------------------------------
1.23 +111 -1 xml-xerces/c/src/xercesc/validators/schema/ComplexTypeInfo.cpp
Index: ComplexTypeInfo.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/ComplexTypeInfo.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- ComplexTypeInfo.cpp 17 Dec 2003 00:18:40 -0000 1.22
+++ ComplexTypeInfo.cpp 24 Dec 2003 17:42:03 -0000 1.23
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.23 2003/12/24 17:42:03 knoaman
+ * Misc. PSVI updates
+ *
* Revision 1.22 2003/12/17 00:18:40 cargilld
* Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
*
@@ -218,12 +221,118 @@
#include <xercesc/validators/common/MixedContentModel.hpp>
#include <xercesc/validators/common/SimpleContentModel.hpp>
#include <xercesc/validators/schema/XSDLocator.hpp>
-
#include <xercesc/internal/XTemplateSerializer.hpp>
+#include <xercesc/util/XMLRegisterCleanup.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
+// Local static data
+// ---------------------------------------------------------------------------
+static bool sAnyTypeMutexRegistered = false;
+static XMLMutex* sAnyTypeMutex = 0;
+static XMLRegisterCleanup anyTypeCleanup;
+
+
+// ---------------------------------------------------------------------------
+// ComplexTypeInfo: Static member data
+// ---------------------------------------------------------------------------
+ComplexTypeInfo* ComplexTypeInfo::fAnyType = 0;
+
+
+// ---------------------------------------------------------------------------
+// ComplexTypeInfo: Static meber methods
+// ---------------------------------------------------------------------------
+void ComplexTypeInfo::reinitAnyType() {
+
+ delete fAnyType;
+ fAnyType = 0;
+
+ // delete local static data
+ delete sAnyTypeMutex;
+ sAnyTypeMutex = 0;
+ sAnyTypeMutexRegistered = false;
+}
+
+ComplexTypeInfo* ComplexTypeInfo::getAnyType(unsigned int emptyNSId)
+{
+ if (!sAnyTypeMutexRegistered)
+ {
+ XMLMutex* tmpMutex = new XMLMutex;
+ if (XMLPlatformUtils::compareAndSwap((void**)&sAnyTypeMutex, tmpMutex, 0))
+ {
+ // Someone beat us to it, so let's clean up ours
+ delete tmpMutex;
+ }
+
+ // Now lock it and try to register it
+ XMLMutexLock lock(sAnyTypeMutex);
+
+ // If we got here first, then register it and set the registered flag
+ if (!sAnyTypeMutexRegistered)
+ {
+ // create type name
+ XMLCh typeName[128];
+ unsigned int nsLen = XMLString::stringLen(
+ SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
+
+ XMLString::copyString(
+ typeName, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
+ typeName[nsLen] = chComma;
+ XMLString::copyString(
+ typeName + nsLen + 1, SchemaSymbols::fgATTVAL_ANYTYPE);
+
+ // Create and initialize 'anyType'
+ fAnyType = new ComplexTypeInfo();
+
+ ContentSpecNode* term = new ContentSpecNode
+ (
+ new QName
+ (
+ XMLUni::fgZeroLenString
+ , XMLUni::fgZeroLenString
+ , emptyNSId
+ )
+ , false
+ );
+ term->setType(ContentSpecNode::Any_Lax);
+ term->setMinOccurs(0);
+ term->setMaxOccurs(SchemaSymbols::XSD_UNBOUNDED);
+
+ ContentSpecNode* particle = new ContentSpecNode
+ (
+ ContentSpecNode::ModelGroupSequence
+ , term
+ , 0
+ );
+
+ SchemaAttDef* attWildCard = new SchemaAttDef
+ (
+ XMLUni::fgZeroLenString
+ , XMLUni::fgZeroLenString
+ , emptyNSId
+ , XMLAttDef::Any_Any
+ , XMLAttDef::ProcessContents_Lax
+ );
+
+ fAnyType->setTypeName(typeName);
+ fAnyType->setBaseComplexTypeInfo(fAnyType);
+ fAnyType->setDerivedBy(SchemaSymbols::XSD_RESTRICTION);
+ fAnyType->setContentType(SchemaElementDecl::Mixed_Complex);
+ fAnyType->setContentSpec(particle);
+ fAnyType->setAttWildCard(attWildCard);
+
+ // register cleanup method
+ anyTypeCleanup.registerCleanup(reinitAnyType);
+ sAnyTypeMutexRegistered = true;
+ }
+ }
+
+ return fAnyType;
+}
+
+
+// ---------------------------------------------------------------------------
// ComplexTypeInfo: Constructors and Destructor
// ---------------------------------------------------------------------------
ComplexTypeInfo::ComplexTypeInfo(MemoryManager* const manager)
@@ -1043,6 +1152,7 @@
fUniqueURI = 0;
}
}
+
XERCES_CPP_NAMESPACE_END
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org