You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2003/11/21 23:34:46 UTC
cvs commit: xml-xerces/c/src/xercesc/internal XSObjectFactory.cpp
neilg 2003/11/21 14:34:46
Modified: c/src/xercesc/framework/psvi PSVIElement.cpp PSVIElement.hpp
PSVIItem.cpp PSVIItem.hpp
XSAttributeDeclaration.cpp
XSAttributeDeclaration.hpp
XSAttributeGroupDefinition.cpp
XSAttributeGroupDefinition.hpp XSModel.cpp
XSModel.hpp XSNamespaceItem.cpp XSNamespaceItem.hpp
XSNotationDeclaration.cpp
c/src/xercesc/framework XMLGrammarPool.hpp
XMLNotationDecl.cpp XMLNotationDecl.hpp
c/src/xercesc/validators/schema SchemaAttDef.cpp
SchemaAttDef.hpp SchemaElementDecl.hpp
TraverseSchema.cpp
c/src/xercesc/internal XSObjectFactory.cpp
Log:
More schema component model implementation, thanks to David Cargill.
In particular, this cleans up and completes the XSModel, XSNamespaceItem,
XSAttributeDeclaration and XSAttributeGroup implementations.
Revision Changes Path
1.3 +49 -2 xml-xerces/c/src/xercesc/framework/psvi/PSVIElement.cpp
Index: PSVIElement.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/PSVIElement.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PSVIElement.cpp 6 Nov 2003 21:50:33 -0000 1.2
+++ PSVIElement.cpp 21 Nov 2003 22:34:45 -0000 1.3
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.3 2003/11/21 22:34:45 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.2 2003/11/06 21:50:33 neilg
* fix compilation errors under gcc 3.3.
*
@@ -65,15 +70,59 @@
*/
#include <xercesc/framework/psvi/PSVIElement.hpp>
+#include <xercesc/framework/psvi/XSElementDeclaration.hpp>
+#include <xercesc/framework/psvi/XSComplexTypeDefinition.hpp>
+#include <xercesc/framework/psvi/XSSimpleTypeDefinition.hpp>
XERCES_CPP_NAMESPACE_BEGIN
-PSVIElement::PSVIElement( MemoryManager* const manager ):
+PSVIElement::PSVIElement(MemoryManager* const manager ):
PSVIItem(manager),
fElementDecl(0),
fNotationDecl(0),
fSchemaInfo(0)
{
+}
+
+XSTypeDefinition* PSVIElement::getTypeDefinition()
+{
+ return fElementDecl->getTypeDefinition();
+}
+
+ /**
+ * If and only if that type definition is a simple type definition
+ * with {variety} union, or a complex type definition whose {content type}
+ * is a simple type definition with {variety} union,
+
+ * then an item isomorphic
+ * to that member of the union's {member type definitions} which actually
+ * validated the element item's normalized value.
+ *
+ * @return a simple type declaration
+ */
+XSSimpleTypeDefinition* PSVIElement::getMemberTypeDefinition()
+{
+ XSTypeDefinition* typeDef = fElementDecl->getTypeDefinition();
+ if (typeDef->getTypeCategory() == XSTypeDefinition::COMPLEX_TYPE)
+ {
+ if (((XSComplexTypeDefinition*)typeDef)->getContentType() == XSComplexTypeDefinition::CONTENTTYPE_SIMPLE)
+ {
+ typeDef = ((XSComplexTypeDefinition*)typeDef)->getSimpleType();
+ if (((XSSimpleTypeDefinition*)typeDef)->getVariety() == XSSimpleTypeDefinition::VARIETY_UNION)
+ {
+
+ }
+ }
+ }
+ else
+ {
+ // Simple Type...
+ if (((XSSimpleTypeDefinition*)typeDef)->getVariety() == XSSimpleTypeDefinition::VARIETY_UNION)
+ {
+
+ }
+ }
+ return 0;
}
XERCES_CPP_NAMESPACE_END
1.4 +5 -12 xml-xerces/c/src/xercesc/framework/psvi/PSVIElement.hpp
Index: PSVIElement.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/PSVIElement.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PSVIElement.hpp 6 Nov 2003 21:50:33 -0000 1.3
+++ PSVIElement.hpp 21 Nov 2003 22:34:45 -0000 1.4
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.4 2003/11/21 22:34:45 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.3 2003/11/06 21:50:33 neilg
* fix compilation errors under gcc 3.3.
*
@@ -147,7 +152,7 @@
/**
* If and only if that type definition is a simple type definition
* with {variety} union, or a complex type definition whose {content type}
- * is a simple thype definition with {variety} union, then an item isomorphic
+ * is a simple type definition with {variety} union, then an item isomorphic
* to that member of the union's {member type definitions} which actually
* validated the element item's normalized value.
*
@@ -201,16 +206,6 @@
inline XSModel* PSVIElement::getSchemaInformation()
{
return fSchemaInfo;
-}
-
-inline XSTypeDefinition* PSVIElement::getTypeDefinition()
-{
- return fType;
-}
-
-inline XSSimpleTypeDefinition* PSVIElement::getMemberTypeDefinition()
-{
- return fMemberType;
}
XERCES_CPP_NAMESPACE_END
1.3 +13 -0 xml-xerces/c/src/xercesc/framework/psvi/PSVIItem.cpp
Index: PSVIItem.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/PSVIItem.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PSVIItem.cpp 17 Sep 2003 17:45:37 -0000 1.2
+++ PSVIItem.cpp 21 Nov 2003 22:34:45 -0000 1.3
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.3 2003/11/21 22:34:45 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.2 2003/09/17 17:45:37 neilg
* remove spurious inlines; hopefully this will make Solaris/AIX compilers happy.
*
@@ -127,6 +132,16 @@
inline PSVIItem::ASSESSMENT_TYPE PSVIItem::getValidationAttempted() const
{
return fAssessmentType;
+}
+
+void PSVIItem::setValidationAttempted(PSVIItem::ASSESSMENT_TYPE attemptType)
+{
+ fAssessmentType = attemptType;
+}
+
+void PSVIItem::setValidity(PSVIItem::VALIDITY_STATE validity)
+{
+ fValidityState = validity;
}
XERCES_CPP_NAMESPACE_END
1.3 +17 -14 xml-xerces/c/src/xercesc/framework/psvi/PSVIItem.hpp
Index: PSVIItem.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/PSVIItem.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PSVIItem.hpp 6 Nov 2003 15:30:04 -0000 1.2
+++ PSVIItem.hpp 21 Nov 2003 22:34:45 -0000 1.3
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.3 2003/11/21 22:34:45 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.2 2003/11/06 15:30:04 neilg
* 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.
*
@@ -132,7 +137,7 @@
*
* @param manager The configurable memory manager
*/
- PSVIItem( MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
+ PSVIItem(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
//@};
@@ -241,8 +246,10 @@
//@{
- /*
- / reset the object
+ void setValidationAttempted(PSVIItem::ASSESSMENT_TYPE attemptType);
+ void setValidity(PSVIItem::VALIDITY_STATE validity);
+
+ /** reset the object
* @param validationContext: corresponds to schema validation context property
* @param normalizedValue: corresponds to schema normalized value property
* @param validityState: state of item's validity
@@ -286,17 +293,15 @@
// Type definition that validated this item
// fMemberType
// If fType is a union type, the member type that validated this item
- const MemoryManager *fMemoryManager;
- const XMLCh* fValidationContext;
- const XMLCh* fNormalizedValue;
- const XMLCh* fDefaultValue;
- VALIDITY_STATE fValidityState;
- ASSESSMENT_TYPE fAssessmentType;
- bool fIsSpecified;
- XSTypeDefinition * fType;
- XSSimpleTypeDefinition * fMemberType;
-
-
+ MemoryManager* const fMemoryManager;
+ const XMLCh* fValidationContext;
+ const XMLCh* fNormalizedValue;
+ const XMLCh* fDefaultValue;
+ VALIDITY_STATE fValidityState;
+ ASSESSMENT_TYPE fAssessmentType;
+ bool fIsSpecified;
+ XSTypeDefinition* fType;
+ XSSimpleTypeDefinition* fMemberType;
};
inline PSVIItem::~PSVIItem() {}
1.7 +7 -16 xml-xerces/c/src/xercesc/framework/psvi/XSAttributeDeclaration.cpp
Index: XSAttributeDeclaration.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSAttributeDeclaration.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XSAttributeDeclaration.cpp 21 Nov 2003 17:19:30 -0000 1.6
+++ XSAttributeDeclaration.cpp 21 Nov 2003 22:34:45 -0000 1.7
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.7 2003/11/21 22:34:45 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.6 2003/11/21 17:19:30 knoaman
* PSVI update.
*
@@ -95,11 +100,15 @@
XSSimpleTypeDefinition* const typeDef,
XSAnnotation* const annot,
XSModel* const xsModel,
+ XSConstants::SCOPE scope,
+ XSComplexTypeDefinition* enclosingCTDefinition,
MemoryManager * const manager)
: XSObject(XSConstants::ATTRIBUTE_DECLARATION, xsModel, manager)
, fAttDef(attDef)
, fTypeDefinition(typeDef)
, fAnnotation(annot)
+ , fScope(scope)
+ , fEnclosingCTDefinition(enclosingCTDefinition)
{
}
@@ -131,25 +140,9 @@
return fId;
}
-
// ---------------------------------------------------------------------------
// XSAttributeDeclaration: access methods
// ---------------------------------------------------------------------------
-XSConstants::SCOPE XSAttributeDeclaration::getScope() const
-{
- // REVISIT: review... what about SCOPE_ABSENT?
- // Using just:
- // if (getNamespaceItem()->getSchemaGrammar()->getAttributeDeclRegistry()->get(fAttDef))
- // give class conversion error...
- if (((XSAttributeDeclaration*) this)->getNamespaceItem()->getSchemaGrammar()->getAttributeDeclRegistry()->get(fAttDef))
- return XSConstants::SCOPE_GLOBAL;
- return XSConstants::SCOPE_LOCAL;
-}
-
-XSComplexTypeDefinition *XSAttributeDeclaration::getEnclosingCTDefinition()
-{
- return 0;
-}
XSConstants::VALUE_CONSTRAINT XSAttributeDeclaration::getConstraintType() const
{
1.6 +15 -0 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSAttributeDeclaration.hpp 21 Nov 2003 17:19:30 -0000 1.5
+++ XSAttributeDeclaration.hpp 21 Nov 2003 22:34:45 -0000 1.6
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.6 2003/11/21 22:34:45 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.5 2003/11/21 17:19:30 knoaman
* PSVI update.
*
@@ -116,6 +121,8 @@
, XSSimpleTypeDefinition* const typeDef
, XSAnnotation* const annot
, XSModel* const xsModel
+ , XSConstants::SCOPE scope
+ , XSComplexTypeDefinition* enclosingCTDefinition
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
@@ -228,6 +235,8 @@
XSSimpleTypeDefinition* fTypeDefinition;
XSAnnotation* fAnnotation;
unsigned int fId;
+ XSConstants::SCOPE fScope;
+ XSComplexTypeDefinition* fEnclosingCTDefinition;
};
// ---------------------------------------------------------------------------
@@ -248,7 +257,15 @@
return fAnnotation;
}
+inline XSConstants::SCOPE XSAttributeDeclaration::getScope() const
+{
+ return fScope;
+}
+inline XSComplexTypeDefinition *XSAttributeDeclaration::getEnclosingCTDefinition()
+{
+ return fEnclosingCTDefinition;
+}
XERCES_CPP_NAMESPACE_END
1.6 +20 -0 xml-xerces/c/src/xercesc/framework/psvi/XSAttributeGroupDefinition.cpp
Index: XSAttributeGroupDefinition.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSAttributeGroupDefinition.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSAttributeGroupDefinition.cpp 21 Nov 2003 17:19:30 -0000 1.5
+++ XSAttributeGroupDefinition.cpp 21 Nov 2003 22:34:45 -0000 1.6
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.6 2003/11/21 22:34:45 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.5 2003/11/21 17:19:30 knoaman
* PSVI update.
*
@@ -79,6 +84,7 @@
#include <xercesc/framework/psvi/XSAttributeGroupDefinition.hpp>
#include <xercesc/framework/psvi/XSAttributeUse.hpp>
#include <xercesc/validators/schema/XercesAttGroupInfo.hpp>
+#include <xercesc/framework/psvi/XSModel.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -108,6 +114,22 @@
delete fXSAttributeUseList;
// don't delete fXSWildcard - deleted by XSModel
+}
+
+// XSObject methods
+const XMLCh *XSAttributeGroupDefinition::getName()
+{
+ return fXSModel->getURIStringPool()->getValueForId(fXercesAttGroupInfo->getNameId());
+}
+
+const XMLCh *XSAttributeGroupDefinition::getNamespace()
+{
+ return fXSModel->getURIStringPool()->getValueForId(fXercesAttGroupInfo->getNamespaceId());
+}
+
+XSNamespaceItem *XSAttributeGroupDefinition::getNamespaceItem()
+{
+ return fXSModel->getNamespaceItem(getNamespace());
}
1.6 +28 -0 xml-xerces/c/src/xercesc/framework/psvi/XSAttributeGroupDefinition.hpp
Index: XSAttributeGroupDefinition.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSAttributeGroupDefinition.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSAttributeGroupDefinition.hpp 21 Nov 2003 17:19:30 -0000 1.5
+++ XSAttributeGroupDefinition.hpp 21 Nov 2003 22:34:45 -0000 1.6
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.6 2003/11/21 22:34:45 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.5 2003/11/21 17:19:30 knoaman
* PSVI update.
*
@@ -125,6 +130,31 @@
/** @name Destructor */
//@{
~XSAttributeGroupDefinition();
+ //@}
+
+ //---------------------
+ /** @name overridden XSObject methods */
+ //@{
+
+ /**
+ * The name of type <code>NCName</code> of this declaration as defined in
+ * XML Namespaces.
+ */
+ const XMLCh* getName();
+
+ /**
+ * The [target namespace] of this object, or <code>null</code> if it is
+ * unspecified.
+ */
+ const XMLCh* getNamespace();
+
+ /**
+ * A namespace schema information item corresponding to the target
+ * namespace of the component, if it's globally declared; or null
+ * otherwise.
+ */
+ XSNamespaceItem* getNamespaceItem();
+
//@}
//---------------------
1.8 +343 -155 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSModel.cpp 21 Nov 2003 17:25:09 -0000 1.7
+++ XSModel.cpp 21 Nov 2003 22:34:45 -0000 1.8
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.8 2003/11/21 22:34:45 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.7 2003/11/21 17:25:09 knoaman
* Use XSObjectFactory to create various components.
*
@@ -86,7 +91,9 @@
#include <xercesc/framework/psvi/XSNamespaceItem.hpp>
#include <xercesc/internal/XMLGrammarPoolImpl.hpp>
#include <xercesc/validators/schema/SchemaGrammar.hpp>
+#include <xercesc/validators/common/GrammarResolver.hpp>
#include <xercesc/validators/schema/XercesAttGroupInfo.hpp>
+#include <xercesc/validators/schema/XercesGroupInfo.hpp>
#include <xercesc/internal/XSObjectFactory.hpp>
#include <xercesc/framework/psvi/XSAttributeDeclaration.hpp>
#include <xercesc/framework/psvi/XSElementDeclaration.hpp>
@@ -94,9 +101,145 @@
#include <xercesc/framework/psvi/XSNotationDeclaration.hpp>
#include <xercesc/framework/psvi/XSAnnotation.hpp>
#include <xercesc/framework/psvi/XSComplexTypeDefinition.hpp>
+#include <xercesc/framework/psvi/XSModelGroupDefinition.hpp>
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());
+ 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());
+
+ 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...
+ RefHashTableOfEnumerator<DatatypeValidator> simpleUserEnum = RefHashTableOfEnumerator<DatatypeValidator> (namespaceItem->getSchemaGrammar()->getDatatypeRegistry()->getUserDefinedRegistry());
+ 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());
+ 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());
+ 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...
+ // REVISIT: how to see if a model group definition is global or local?
+ RefHashTableOfEnumerator<XercesGroupInfo> modelGroupEnum = RefHashTableOfEnumerator<XercesGroupInfo> (namespaceItem->getSchemaGrammar()->getGroupInfoRegistry());
+ 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())
+ {
+ // REVISIT: do we need to store mapping between XMLNotationDecl objects and
+ // XSNotationDeclaration objects? PSVIElement may need it to
+ // get the XSNotationDecl...
+ 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
*
@@ -114,6 +257,10 @@
, fXSAnnotationList(0)
, fHashNamespace(0)
, fObjFactory(0)
+ , fDeleteNamespace(0)
+ , fParent(0)
+ , fDeleteParent(false)
+ , fAddedBuiltinDatatypeValidators(false)
{
fURIStringPool = grammarPool->getURIStringPool();
fObjFactory = new XSObjectFactory(manager);
@@ -132,9 +279,9 @@
case XSConstants::NOTATION_DECLARATION:
fComponentMap[i] = new (fMemoryManager) XSNamedMap<XSObject>
(
- 15, // size
+ 29, // size
29, // modulus
- grammarPool->getURIStringPool(),
+ fURIStringPool,
false, // adoptElems
fMemoryManager
);
@@ -154,11 +301,12 @@
}
// Revisit: size of vector
- fNamespaceStringList = new (manager) RefArrayVectorOf <XMLCh>(10, true, manager);
- fXSNamespaceItemList = new (manager) RefVectorOf <XSNamespaceItem>(10, true, manager);
- fXSAnnotationList = new (manager) RefVectorOf <XSAnnotation> (10, false, manager);
-
- fHashNamespace = new (manager) RefHashTableOf<XSNamespaceItem> (29, false, manager);
+ fNamespaceStringList = new (manager) RefArrayVectorOf <XMLCh>(10, true, manager);
+ fXSNamespaceItemList = new (manager) RefVectorOf <XSNamespaceItem>(10, true, manager);
+ fXSAnnotationList = new (manager) RefVectorOf <XSAnnotation> (10, false, manager);
+ fElementDeclarationVector = new (manager) RefVectorOf<XSElementDeclaration> (10, false, manager);
+ fAttributeDeclarationVector = new (manager) RefVectorOf<XSAttributeDeclaration> (10, false, manager);
+ fHashNamespace = new (manager) RefHashTableOf<XSNamespaceItem> (29, false, manager);
// 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
@@ -185,152 +333,22 @@
// Now loop through all of the NamespaceItem's
unsigned int numberOfNamespaces = fXSNamespaceItemList->size();
for (unsigned int j=0; j<numberOfNamespaces; j++)
- {
- XSNamespaceItem* namespaceItem = fXSNamespaceItemList->elementAt(j);
-
- // 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());
- while (simpleEnum.hasMoreElements())
- {
- // REVISIT
- DatatypeValidator& curSimple = simpleEnum.nextElement();
- XSSimpleTypeDefinition* xsSimple = fObjFactory->addOrFind(&curSimple, this);
-
- if (j == 0)
- 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 BuiltIn loop
-
- // Loop through top-level attribute declarations in the grammar...
- RefHashTableOfEnumerator<XMLAttDef> attrEnum = RefHashTableOfEnumerator<XMLAttDef> (namespaceItem->getSchemaGrammar()->getAttributeDeclRegistry());
-
- 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...
- RefHashTableOfEnumerator<DatatypeValidator> simpleUserEnum = RefHashTableOfEnumerator<DatatypeValidator> (namespaceItem->getSchemaGrammar()->getDatatypeRegistry()->getUserDefinedRegistry());
- 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());
- 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());
- while (attrGroupEnum.hasMoreElements())
- {
- XercesAttGroupInfo& curAttrGroup = attrGroupEnum.nextElement();
-
- // NOTE: There is no need to store the mapping between XercesAttGroupInfo
- // objects and XSAttributeGroupDefinition objects
- 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...
- // REVISIT: need XSModelGroupDefinition to be completed...
- // REVISIT: how to see if a model group definition is global or local?
- // end of model group loop
-
- // Loop through notations in the grammar...
- // REVISIT: added getNotationEnumerator to SchemaGrammar... make friend instead?
- NameIdPoolEnumerator<XMLNotationDecl> notationEnum = namespaceItem->getSchemaGrammar()->getNotationEnumerator();
- while (notationEnum.hasMoreElements())
- {
- // REVISIT: do we need to store mapping between XMLNotationDecl objects and
- // XSNotationDeclaration objects? PSVIElement may need it to
- // get the XSNotationDecl...
- 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
+ {
+ 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
+ * Grammar(s) from the GrammarResolver
*
* @param baseModel the XSModel upon which this one is based
- * @param grammar the newly-created grammar whose components are to be merged
- * @param manager The configurable memory manager
+ * @param grammarResolver the grammar(s) whose components are to be merged
+ * @param manager The configurable memory manager
*/
XSModel::XSModel( XSModel *baseModel
- , Grammar *grammar
+ , GrammarResolver *grammarResolver
, MemoryManager* const manager)
: fMemoryManager(manager)
, fNamespaceStringList(0)
@@ -340,15 +358,140 @@
, fURIStringPool(0)
, fXSAnnotationList(0)
, fHashNamespace(0)
+ , fParent(baseModel)
, fObjFactory(0)
+ , fDeleteNamespace(0)
+ , fDeleteParent(true)
+ , fAddedBuiltinDatatypeValidators(false)
{
+ fURIStringPool = grammarResolver->getStringPool();
+ fObjFactory = new XSObjectFactory(manager);
+
+ unsigned int i;
+ // Populate XSNamedMaps by going through the components
+ for (i=0; i<XSConstants::MULTIVALUE_FACET; i++)
+ {
+ // REVISIT: what size & modulus
+ 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>
+ (
+ 29, // size
+ 29, // modulus
+ fURIStringPool,
+ false, // adoptElems
+ fMemoryManager
+ );
+ break;
+ default:
+ // ATTRIBUTE_USE
+ // MODEL_GROUP
+ // PARTICLE
+ // IDENTITY_CONSTRAINT
+ // WILDCARD
+ // ANNOTATION
+ // FACET
+ // MULTIVALUE
+ fComponentMap[i] = 0;
+ break;
+ }
+ }
+
+ // Revisit: size of vector
+ fNamespaceStringList = new (manager) RefArrayVectorOf <XMLCh>(10, true, manager);
+ fXSNamespaceItemList = new (manager) RefVectorOf <XSNamespaceItem>(10, false, manager);
+ fDeleteNamespace = new (manager) RefVectorOf <XSNamespaceItem>(10, true, manager);
+ fXSAnnotationList = new (manager) RefVectorOf <XSAnnotation> (10, false, manager);
+ fElementDeclarationVector = new (manager) RefVectorOf<XSElementDeclaration> (10, false, manager);
+ fAttributeDeclarationVector = new (manager) RefVectorOf<XSAttributeDeclaration> (10, false, manager);
+ fHashNamespace = new (manager) RefHashTableOf<XSNamespaceItem> (29, false, manager);
+
+ if (fParent)
+ {
+ if (fParent->fAddedBuiltinDatatypeValidators)
+ fAddedBuiltinDatatypeValidators = 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 = fXSNamespaceItemList->elementAt(i);
+ fXSNamespaceItemList->addElement(namespaceItem);
+
+ XMLCh* NameSpace = XMLString::replicate(namespaceItem->getSchemaNamespace(), manager);
+ fNamespaceStringList->addElement(NameSpace);
+ }
+
+ for (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:
+ for (unsigned int j=0; j<fParent->fComponentMap[i]->getLength(); j++)
+ {
+ XSObject* copyObj = fParent->fComponentMap[i]->item(j);
+ fComponentMap[i]->addElement(copyObj,
+ copyObj->getName(),
+ copyObj->getNamespace());
+ }
+ break;
+ }
+ }
+
+ for (i=0; i<fParent->fElementDeclarationVector->size(); i++)
+ {
+ fElementDeclarationVector->addElement(fParent->fElementDeclarationVector->elementAt(i));
+ }
+ for (i=0; i<fParent->fAttributeDeclarationVector->size(); i++)
+ {
+ fAttributeDeclarationVector->addElement(fParent->fAttributeDeclarationVector->elementAt(i));
+ }
+ for (i=0; i<fParent->fXSAnnotationList->size(); i++)
+ {
+ fXSAnnotationList->addElement(fParent->fXSAnnotationList->elementAt(i));
+ }
+
+ } // end of copying parent info
+
+ // Now add information from the new grammars but first create the
+ // 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++)
+ {
+ XMLCh* NameSpace = XMLString::replicate(grammarsToAdd->elementAt(i)->getTargetNamespace(), manager);
+ fNamespaceStringList->addElement(NameSpace);
+
+ XSNamespaceItem* namespaceItem = new XSNamespaceItem(this, grammarsToAdd->elementAt(i), manager);
+ fXSNamespaceItemList->addElement(namespaceItem);
+
+ fHashNamespace->put(NameSpace, namespaceItem);
+
+ fDeleteNamespace->addElement(namespaceItem);
+ }
+
+ // 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()
{
for (unsigned int i=0; i<XSConstants::MULTIVALUE_FACET; i++)
- {
- // REVISIT: what size & modulus
+ {
switch (i+1)
{
case XSConstants::ATTRIBUTE_DECLARATION:
@@ -358,8 +501,7 @@
case XSConstants::MODEL_GROUP_DEFINITION:
case XSConstants::NOTATION_DECLARATION:
delete fComponentMap[i];
- break;
-
+ break;
}
}
@@ -368,6 +510,14 @@
delete fXSAnnotationList;
delete fHashNamespace;
delete fObjFactory;
+ delete fElementDeclarationVector;
+ delete fAttributeDeclarationVector;
+
+ if (fDeleteNamespace)
+ delete fDeleteNamespace;
+
+ if (fDeleteParent && fParent && fParent->fDeleteParent)
+ delete fParent;
}
@@ -404,7 +554,12 @@
XSNamedMap <XSObject> *XSModel::getComponentsByNamespace(XSConstants::COMPONENT_TYPE objectType,
const XMLCh *compNamespace)
{
- XSNamespaceItem* namespaceItem = fHashNamespace->get(compNamespace);
+ XSNamespaceItem* namespaceItem;
+ if (compNamespace)
+ namespaceItem = getNamespaceItem(compNamespace);
+ else
+ namespaceItem = getNamespaceItem(emptyString);
+
if (namespaceItem)
namespaceItem->getComponents(objectType);
@@ -429,7 +584,12 @@
XSElementDeclaration *XSModel::getElementDeclaration(const XMLCh *name
, const XMLCh *compNamespace)
{
- XSNamespaceItem* namespaceItem = fHashNamespace->get(compNamespace);
+ XSNamespaceItem* namespaceItem;
+ if (compNamespace)
+ namespaceItem = getNamespaceItem(compNamespace);
+ else
+ namespaceItem = getNamespaceItem(emptyString);
+
if (namespaceItem)
namespaceItem->getElementDeclaration(name);
@@ -446,7 +606,12 @@
XSAttributeDeclaration *XSModel::getAttributeDeclaration(const XMLCh *name
, const XMLCh *compNamespace)
{
- XSNamespaceItem* namespaceItem = fHashNamespace->get(compNamespace);
+ XSNamespaceItem* namespaceItem;
+ if (compNamespace)
+ namespaceItem = getNamespaceItem(compNamespace);
+ else
+ namespaceItem = getNamespaceItem(emptyString);
+
if (namespaceItem)
namespaceItem->getAttributeDeclaration(name);
@@ -464,7 +629,12 @@
XSTypeDefinition *XSModel::getTypeDefinition(const XMLCh *name
, const XMLCh *compNamespace)
{
- XSNamespaceItem* namespaceItem = fHashNamespace->get(compNamespace);
+ XSNamespaceItem* namespaceItem;
+ if (compNamespace)
+ namespaceItem = getNamespaceItem(compNamespace);
+ else
+ namespaceItem = getNamespaceItem(emptyString);
+
if (namespaceItem)
namespaceItem->getTypeDefinition(name);
@@ -481,7 +651,12 @@
XSAttributeGroupDefinition *XSModel::getAttributeGroup(const XMLCh *name
, const XMLCh *compNamespace)
{
- XSNamespaceItem* namespaceItem = fHashNamespace->get(compNamespace);
+ XSNamespaceItem* namespaceItem;
+ if (compNamespace)
+ namespaceItem = getNamespaceItem(compNamespace);
+ else
+ namespaceItem = getNamespaceItem(emptyString);
+
if (namespaceItem)
namespaceItem->getAttributeGroup(name);
@@ -498,7 +673,12 @@
XSModelGroupDefinition *XSModel::getModelGroupDefinition(const XMLCh *name
, const XMLCh *compNamespace)
{
- XSNamespaceItem* namespaceItem = fHashNamespace->get(compNamespace);
+ XSNamespaceItem* namespaceItem;
+ if (compNamespace)
+ namespaceItem = getNamespaceItem(compNamespace);
+ else
+ namespaceItem = getNamespaceItem(emptyString);
+
if (namespaceItem)
namespaceItem->getModelGroupDefinition(name);
@@ -515,7 +695,12 @@
XSNotationDeclaration *XSModel::getNotationDeclaration(const XMLCh *name
, const XMLCh *compNamespace)
{
- XSNamespaceItem* namespaceItem = fHashNamespace->get(compNamespace);
+ XSNamespaceItem* namespaceItem;
+ if (compNamespace)
+ namespaceItem = getNamespaceItem(compNamespace);
+ else
+ namespaceItem = getNamespaceItem(emptyString);
+
if (namespaceItem)
namespaceItem->getNotationDeclaration(name);
@@ -550,7 +735,12 @@
XSNamespaceItem* XSModel::getNamespaceItem(const XMLCh* const key)
{
- return fHashNamespace->get(key);
+ XSNamespaceItem* xsName = fHashNamespace->get(key);
+ if (xsName)
+ return xsName;
+ if (fParent)
+ return fParent->getNamespaceItem(key);
+ return 0;
}
1.8 +18 -13 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSModel.hpp 21 Nov 2003 17:25:09 -0000 1.7
+++ XSModel.hpp 21 Nov 2003 22:34:45 -0000 1.8
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.8 2003/11/21 22:34:45 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.7 2003/11/21 17:25:09 knoaman
* Use XSObjectFactory to create various components.
*
@@ -131,7 +136,7 @@
/**
* 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
+ * @param manager The configurable memory manager
*/
XSModel( XMLGrammarPool *grammarPool
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
@@ -139,14 +144,14 @@
/**
* The constructor to be used when the XSModel must represent all
* components in the union of an existing XSModel and a newly-created
- * Grammar
+ * Grammar(s) from the GrammarResolver
*
* @param baseModel the XSModel upon which this one is based
- * @param grammar the newly-created grammar whose components are to be merged
- * @param manager The configurable memory manager
+ * @param grammarResolver the grammar(s) whose components are to be merged
+ * @param manager The configurable memory manager
*/
XSModel( XSModel *baseModel
- , Grammar *grammar
+ , GrammarResolver *grammarResolver
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
//@};
@@ -296,6 +301,8 @@
//@}
private:
+ // Local Functions:
+ void addGrammarToXSModel(XSNamespaceItem* namespaceItem);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
@@ -304,7 +311,7 @@
XSModel & operator=(const XSModel &);
protected:
- friend class PSVIUtil;
+ friend class XSObjectFactory;
// -----------------------------------------------------------------------
// data members
@@ -328,22 +335,24 @@
MODEL_GROUP_DEFINITION = 6,
MODEL_GROUP = 7, no
PARTICLE = 8, no
- WILDCARD = 9,
+ WILDCARD = 9, no
IDENTITY_CONSTRAINT = 10, no
NOTATION_DECLARATION = 11,
- ANNOTATION = 12,
+ ANNOTATION = 12, no
FACET = 13, no
MULTIVALUE_FACET = 14 no
*/
XSNamedMap<XSObject>* fComponentMap[XSConstants::MULTIVALUE_FACET];
- // the mapping of Xerces Object to XS Objects
- // facets, mulitvaluefacets and xsattributegroupdefinitions are not stored in the
- // the mapping
XMLStringPool* fURIStringPool;
XSAnnotationList* fXSAnnotationList;
RefHashTableOf<XSNamespaceItem>* fHashNamespace;
XSObjectFactory* fObjFactory;
+ RefVectorOf<XSNamespaceItem>* fDeleteNamespace;
+
+ XSModel* fParent;
+ bool fDeleteParent;
+ bool fAddedBuiltinDatatypeValidators;
};
inline XMLStringPool* XSModel::getURIStringPool()
@@ -360,8 +369,6 @@
{
return fXSNamespaceItemList;
}
-
-
XERCES_CPP_NAMESPACE_END
1.6 +22 -8 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSNamespaceItem.cpp 21 Nov 2003 17:34:04 -0000 1.5
+++ XSNamespaceItem.cpp 21 Nov 2003 22:34:45 -0000 1.6
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.6 2003/11/21 22:34:45 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.5 2003/11/21 17:34:04 knoaman
* PSVI update
*
@@ -94,7 +99,6 @@
, fGrammar(grammar)
, fXSModel(xsModel)
, fXSAnnotationList(0)
-
{
// Populate XSNamedMaps by going through the components
for (unsigned int i=0; i<XSConstants::MULTIVALUE_FACET; i++)
@@ -110,7 +114,7 @@
case XSConstants::NOTATION_DECLARATION:
fComponentMap[i] = new (fMemoryManager) XSNamedMap<XSObject>
(
- 15, // size
+ 29, // size
29, // modulus
fXSModel->getURIStringPool(),
false, // adoptElems
@@ -178,32 +182,44 @@
XSElementDeclaration *XSNamespaceItem::getElementDeclaration(const XMLCh *name)
{
- return (XSElementDeclaration*) fHashMap[XSConstants::ELEMENT_DECLARATION -1]->get(name);
+ if (name)
+ return (XSElementDeclaration*) fHashMap[XSConstants::ELEMENT_DECLARATION -1]->get(name);
+ return 0;
}
XSAttributeDeclaration *XSNamespaceItem::getAttributeDeclaration(const XMLCh *name)
{
- return (XSAttributeDeclaration*) fHashMap[XSConstants::ATTRIBUTE_DECLARATION -1]->get(name);
+ if (name)
+ return (XSAttributeDeclaration*) fHashMap[XSConstants::ATTRIBUTE_DECLARATION -1]->get(name);
+ return 0;
}
XSTypeDefinition *XSNamespaceItem::getTypeDefinition(const XMLCh *name)
{
- return (XSTypeDefinition*) fHashMap[XSConstants::TYPE_DEFINITION -1]->get(name);
+ if (name)
+ return (XSTypeDefinition*) fHashMap[XSConstants::TYPE_DEFINITION -1]->get(name);
+ return 0;
}
XSAttributeGroupDefinition *XSNamespaceItem::getAttributeGroup(const XMLCh *name)
{
- return (XSAttributeGroupDefinition*) fHashMap[XSConstants::ATTRIBUTE_GROUP_DEFINITION -1]->get(name);
+ if (name)
+ return (XSAttributeGroupDefinition*) fHashMap[XSConstants::ATTRIBUTE_GROUP_DEFINITION -1]->get(name);
+ return 0;
}
XSModelGroupDefinition *XSNamespaceItem::getModelGroupDefinition(const XMLCh *name)
{
- return (XSModelGroupDefinition*) fHashMap[XSConstants::MODEL_GROUP_DEFINITION -1]->get(name);
+ if (name)
+ return (XSModelGroupDefinition*) fHashMap[XSConstants::MODEL_GROUP_DEFINITION -1]->get(name);
+ return 0;
}
XSNotationDeclaration *XSNamespaceItem::getNotationDeclaration(const XMLCh *name)
{
- return (XSNotationDeclaration*) fHashMap[XSConstants::NOTATION_DECLARATION -1]->get(name);
+ if (name)
+ return (XSNotationDeclaration*) fHashMap[XSConstants::NOTATION_DECLARATION -1]->get(name);
+ return 0;
}
StringList *XSNamespaceItem::getDocumentLocations()
1.6 +13 -9 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSNamespaceItem.hpp 21 Nov 2003 17:34:04 -0000 1.5
+++ XSNamespaceItem.hpp 21 Nov 2003 22:34:45 -0000 1.6
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.6 2003/11/21 22:34:45 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.5 2003/11/21 17:34:04 knoaman
* PSVI update
*
@@ -246,21 +251,22 @@
SchemaGrammar* fGrammar;
XSModel* fXSModel;
- /* Need a XSNamedMap for each component
+ /* Need a XSNamedMap for each component top-level?
+ that is top level.
ATTRIBUTE_DECLARATION = 1,
ELEMENT_DECLARATION = 2,
TYPE_DEFINITION = 3,
ATTRIBUTE_USE = 4, no
ATTRIBUTE_GROUP_DEFINITION= 5,
- MODEL_GROUP_DEFINITION = 6, yes - no
- MODEL_GROUP = 7, no - yes (just one of these)
- PARTICLE = 8, no
- WILDCARD = 9,
- IDENTITY_CONSTRAINT = 10, never return
+ MODEL_GROUP_DEFINITION = 6,
+ MODEL_GROUP = 7, no
+ PARTICLE = 8, no
+ WILDCARD = 9, no
+ IDENTITY_CONSTRAINT = 10, no
NOTATION_DECLARATION = 11,
- ANNOTATION = 12,
- FACET = 13, no
- MULTIVALUE_FACET = 14 no
+ ANNOTATION = 12, no
+ FACET = 13, no
+ MULTIVALUE_FACET = 14 no
*/
XSNamedMap<XSObject>* fComponentMap[XSConstants::MULTIVALUE_FACET];
XSAnnotationList* fXSAnnotationList;
1.7 +5 -1 xml-xerces/c/src/xercesc/framework/psvi/XSNotationDeclaration.cpp
Index: XSNotationDeclaration.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSNotationDeclaration.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XSNotationDeclaration.cpp 21 Nov 2003 17:34:04 -0000 1.6
+++ XSNotationDeclaration.cpp 21 Nov 2003 22:34:45 -0000 1.7
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.7 2003/11/21 22:34:45 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.6 2003/11/21 17:34:04 knoaman
* PSVI update
*
@@ -82,6 +87,7 @@
#include <xercesc/framework/psvi/XSNotationDeclaration.hpp>
#include <xercesc/framework/psvi/XSModel.hpp>
#include <xercesc/framework/XMLNotationDecl.hpp>
+#include <xercesc/framework/psvi/XSModel.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -115,7 +121,7 @@
const XMLCh *XSNotationDeclaration::getNamespace()
{
- return fXMLNotationDecl->getNameSpace();
+ return fXSModel->getURIStringPool()->getValueForId(fXMLNotationDecl->getNameSpaceId());
}
XSNamespaceItem *XSNotationDeclaration::getNamespaceItem()
1.10 +17 -15 xml-xerces/c/src/xercesc/framework/XMLGrammarPool.hpp
Index: XMLGrammarPool.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/XMLGrammarPool.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XMLGrammarPool.hpp 6 Nov 2003 21:53:52 -0000 1.9
+++ XMLGrammarPool.hpp 21 Nov 2003 22:34:45 -0000 1.10
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.10 2003/11/21 22:34:45 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.9 2003/11/06 21:53:52 neilg
* update grammar pool interface so that cacheGrammar(Grammar) can tell the caller whether the grammar was accepted. Also fix some documentation errors.
*
@@ -156,10 +161,10 @@
/**
* orphanGrammar
*
- * grammar removed from the grammar pool and owned by the caller
+ * grammar removed from the grammar pool and owned by the caller
*
- * @param nameSpaceKey: Key sed to search for grammar in the grammar pool
- *
+ * @param nameSpaceKey: Key used to search for grammar in the grammar pool
+ * @return the grammar that was removed from the pool (0 if none)
*/
virtual Grammar* orphanGrammar(const XMLCh* const nameSpaceKey) = 0;
@@ -174,10 +179,10 @@
/**
* clear
*
- * all grammars are removed from the grammar pool and deleted.
- *
+ * all grammars are removed from the grammar pool and deleted.
+ * @return true if the grammar pool was cleared. false if it did not.
*/
- virtual void clear() = 0;
+ virtual bool clear() = 0;
/**
* lockPool
@@ -198,16 +203,10 @@
* One effect, depending on the underlying implementation, is that the grammar pool
* may no longer be thread-safe (even on read operations).
*
+ * For PSVI support any previous XSModel that was produced will be deleted.
*/
virtual void unlockPool() = 0;
- /**
- * setPSVI
- *
- * A flag to indicate that PSVI will be performed on the schema grammars as
- * a PSVIHandler has been set.
- */
- virtual void setPSVI(const bool doPSVI) = 0;
//@}
// -----------------------------------------------------------------------
@@ -250,6 +249,11 @@
* in the grammar pool. If the pool is locked, this should
* be a thread-safe operation. It should return null if and only if
* the pool is empty.
+ *
+ * Calling getXSModel() on an unlocked grammar pool may result in the
+ * creation of a new XSModel with the old XSModel being deleted. The
+ * function will return a different address for the XSModel if it has
+ * changed.
*/
virtual XSModel *getXSModel() = 0;
1.10 +5 -3 xml-xerces/c/src/xercesc/framework/XMLNotationDecl.cpp
Index: XMLNotationDecl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/XMLNotationDecl.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XMLNotationDecl.cpp 6 Nov 2003 15:30:06 -0000 1.9
+++ XMLNotationDecl.cpp 21 Nov 2003 22:34:46 -0000 1.10
@@ -56,6 +56,11 @@
/**
* $Log$
+ * Revision 1.10 2003/11/21 22:34:46 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.9 2003/11/06 15:30:06 neilg
* 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.
*
@@ -113,7 +118,7 @@
, fPublicId(0)
, fSystemId(0)
, fBaseURI(0)
- , fNameSpace(0)
+ , fNameSpaceId(0)
, fMemoryManager(manager)
{
}
@@ -128,7 +133,7 @@
, fPublicId(0)
, fSystemId(0)
, fBaseURI(0)
- , fNameSpace(0)
+ , fNameSpaceId(0)
, fMemoryManager(manager)
{
try
@@ -177,7 +182,6 @@
fMemoryManager->deallocate(fPublicId);
fMemoryManager->deallocate(fSystemId);
fMemoryManager->deallocate(fBaseURI);
- fMemoryManager->deallocate(fNameSpace);
}
/***
1.11 +10 -10 xml-xerces/c/src/xercesc/framework/XMLNotationDecl.hpp
Index: XMLNotationDecl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/XMLNotationDecl.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XMLNotationDecl.hpp 6 Nov 2003 15:30:06 -0000 1.10
+++ XMLNotationDecl.hpp 21 Nov 2003 22:34:46 -0000 1.11
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.11 2003/11/21 22:34:46 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.10 2003/11/06 15:30:06 neilg
* 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.
*
@@ -161,7 +166,7 @@
const XMLCh* getPublicId() const;
const XMLCh* getSystemId() const;
const XMLCh* getBaseURI() const;
- const XMLCh* getNameSpace() const;
+ const unsigned int getNameSpaceId() const;
MemoryManager* getMemoryManager() const;
@@ -176,7 +181,7 @@
void setPublicId(const XMLCh* const newId);
void setSystemId(const XMLCh* const newId);
void setBaseURI(const XMLCh* const newId);
- void setNameSpace(const XMLCh* const newId);
+ void setNameSpaceId(const unsigned int newId);
// -----------------------------------------------------------------------
// Support named collection element semantics
@@ -226,7 +231,7 @@
XMLCh* fPublicId;
XMLCh* fSystemId;
XMLCh* fBaseURI;
- XMLCh* fNameSpace;
+ unsigned int fNameSpaceId;
MemoryManager* fMemoryManager;
};
@@ -244,9 +249,9 @@
return fName;
}
-inline const XMLCh* XMLNotationDecl::getNameSpace() const
+inline const unsigned int XMLNotationDecl::getNameSpaceId() const
{
- return fNameSpace;
+ return fNameSpaceId;
}
inline const XMLCh* XMLNotationDecl::getPublicId() const
@@ -277,12 +282,9 @@
fId = newId;
}
-inline void XMLNotationDecl::setNameSpace(const XMLCh* const newId)
+inline void XMLNotationDecl::setNameSpaceId(const unsigned int newId)
{
- if (fNameSpace)
- fMemoryManager->deallocate(fNameSpace);
-
- fNameSpace = XMLString::replicate(newId, fMemoryManager);
+ fNameSpaceId = newId;
}
inline void XMLNotationDecl::setPublicId(const XMLCh* const newId)
1.9 +7 -0 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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SchemaAttDef.cpp 17 Oct 2003 21:17:12 -0000 1.8
+++ SchemaAttDef.cpp 21 Nov 2003 22:34:46 -0000 1.9
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.9 2003/11/21 22:34:46 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.8 2003/10/17 21:17:12 peiyongz
* using XTemplateSerializer
*
@@ -126,6 +131,7 @@
, fNamespaceList(0)
, fValidity(PSVIDefs::UNKNOWN)
, fValidation(PSVIDefs::NONE)
+ , fEnclosingCT(0)
{
}
@@ -143,6 +149,7 @@
, fNamespaceList(0)
, fValidity(PSVIDefs::UNKNOWN)
, fValidation(PSVIDefs::NONE)
+ , fEnclosingCT(0)
{
fAttName = new (manager) QName(prefix, localPart, uriId, manager);
}
@@ -164,6 +171,7 @@
, fNamespaceList(0)
, fValidity(PSVIDefs::UNKNOWN)
, fValidation(PSVIDefs::NONE)
+ , fEnclosingCT(0)
{
fAttName = new (manager) QName(prefix, localPart, uriId, manager);
}
@@ -181,6 +189,7 @@
, fNamespaceList(0)
, fValidity(other->fValidity)
, fValidation(other->fValidation)
+ , fEnclosingCT(other->fEnclosingCT)
{
QName* otherName = other->getAttName();
fAttName = new (getMemoryManager()) QName(otherName->getPrefix(),
1.8 +18 -3 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SchemaAttDef.hpp 10 Oct 2003 16:25:40 -0000 1.7
+++ SchemaAttDef.hpp 21 Nov 2003 22:34:46 -0000 1.8
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.8 2003/11/21 22:34:46 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.7 2003/10/10 16:25:40 peiyongz
* Implementation of Serialization/Deserialization
*
@@ -105,11 +110,12 @@
#include <xercesc/validators/datatype/DatatypeValidator.hpp>
#include <xercesc/validators/datatype/UnionDatatypeValidator.hpp>
#include <xercesc/validators/schema/PSVIDefs.hpp>
+
XERCES_CPP_NAMESPACE_BEGIN
class DatatypeValidator;
class QName;
-
+class ComplexTypeInfo;
//
// This class is a derivative of the core XMLAttDef class. This class adds
// any Schema specific data members and provides Schema specific implementations
@@ -158,7 +164,7 @@
// ----------------------------------------------------------------------
// Partial implementation of PSVI
// The values these methods return are only accurate until the DOMAttr
- // is created that uses the values. After this a celan up method is called
+ // is created that uses the values. After this a clean up method is called
// and the SchemaAttDef may be used again.
// note that some of this information has dependancies. For example,
// if something is not valid then the information returned by the other
@@ -236,6 +242,7 @@
QName* getAttName() const;
DatatypeValidator* getDatatypeValidator() const;
ValueVectorOf<unsigned int>* getNamespaceList() const;
+ ComplexTypeInfo* getEnclosingCT() const;
// -----------------------------------------------------------------------
// Setter methods
@@ -254,7 +261,7 @@
void resetNamespaceList();
void setValidity(PSVIDefs::Validity valid);
void setValidationAttempted(PSVIDefs::Validation validation);
-
+ void setEnclosingCT(ComplexTypeInfo* complexTypeInfo);
/***
* Support for Serialization/De-serialization
***/
@@ -301,6 +308,7 @@
ValueVectorOf<unsigned int>* fNamespaceList;
PSVIDefs::Validity fValidity;
PSVIDefs::Validation fValidation;
+ ComplexTypeInfo* fEnclosingCT;
};
@@ -433,6 +441,10 @@
return fNamespaceList;
}
+inline ComplexTypeInfo* SchemaAttDef::getEnclosingCT() const
+{
+ return fEnclosingCT;
+}
// ---------------------------------------------------------------------------
// SchemaAttDef: Setter methods
@@ -489,6 +501,11 @@
fMemberTypeValidator = 0;
fValidity = PSVIDefs::UNKNOWN;
fValidation = PSVIDefs::NONE;
+}
+
+inline void SchemaAttDef::setEnclosingCT(ComplexTypeInfo* complexTypeInfo)
+{
+ fEnclosingCT = complexTypeInfo;
}
XERCES_CPP_NAMESPACE_END
1.16 +4 -0 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.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- SchemaElementDecl.hpp 6 Nov 2003 15:30:08 -0000 1.15
+++ SchemaElementDecl.hpp 21 Nov 2003 22:34:46 -0000 1.16
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.16 2003/11/21 22:34:46 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.15 2003/11/06 15:30:08 neilg
* 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.
*
@@ -389,6 +394,7 @@
void updateValidityFromElement(const XMLElementDecl *decl, Grammar::GrammarType eleGrammar);
//called when attribute content of this element was validated
+ // @deprecated; should not be needed in a thread-safe implementation
void updateValidityFromAttribute(const SchemaAttDef *def);
//cleans up inbetween uses of the SchemaElementDecl. Resets xsiType, Validity etc.
1.97 +6 -3 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.96
retrieving revision 1.97
diff -u -r1.96 -r1.97
--- TraverseSchema.cpp 20 Nov 2003 18:00:12 -0000 1.96
+++ TraverseSchema.cpp 21 Nov 2003 22:34:46 -0000 1.97
@@ -2329,9 +2329,12 @@
bool toClone = false;
if (typeInfo) {
-
toClone = true;
typeInfo->addAttDef(attDef);
+ if (!fCurrentAttGroupInfo)
+ {
+ attDef->setEnclosingCT(typeInfo);
+ }
}
if (fCurrentAttGroupInfo) {
@@ -2639,7 +2642,7 @@
0,
fGrammarPoolMemoryManager
);
- decl->setNameSpace(fURIStringPool->getValueForId(fTargetNSURI));
+ decl->setNameSpaceId(fTargetNSURI);
fSchemaGrammar->putNotationDecl(decl);
//we don't really care if something inside <notation> is wrong..
1.2 +33 -4 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSObjectFactory.cpp 21 Nov 2003 17:11:24 -0000 1.1
+++ XSObjectFactory.cpp 21 Nov 2003 22:34:46 -0000 1.2
@@ -56,6 +56,11 @@
/*
* $Log$
+ * Revision 1.2 2003/11/21 22:34:46 neilg
+ * More schema component model implementation, thanks to David Cargill.
+ * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
+ * XSAttributeDeclaration and XSAttributeGroup implementations.
+ *
* Revision 1.1 2003/11/21 17:11:24 knoaman
* Initial revision
*
@@ -288,12 +293,31 @@
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)
+ {
+ // 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);
+ }
+ }
+
xsObj = new (fMemoryManager) XSAttributeDeclaration
(
attDef
, xsType
, getAnnotationFromModel(xsModel, attDef)
, xsModel
+ , scope
+ , enclosingCTDefinition
, fMemoryManager
);
putObjectInMap(attDef, xsObj, xsModel);
@@ -623,16 +647,23 @@
{
annot = namespaceItemList->elementAt(i)->getSchemaGrammar()->getAnnotation(key);
if (annot)
- break;
+ return annot;
}
- return annot;
+ if (xsModel->fParent)
+ return getAnnotationFromModel(xsModel->fParent, key);
+ return 0;
}
XSObject* XSObjectFactory::getObjectFromMap(void* key, XSModel* const xsModel)
{
- return fXercesToXSMap->get(key);
+ XSObject* xsObj = fXercesToXSMap->get(key);
+ if (xsObj)
+ return xsObj;
+ if (xsModel->fParent)
+ return getObjectFromMap(key, xsModel->fParent);
+ return 0;
}
void XSObjectFactory::putObjectInMap(void* key, XSObject* const object, XSModel* const xsModel)
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org