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 2001/11/02 15:13:46 UTC
cvs commit: xml-xerces/c/src/validators/schema GeneralAttributeCheck.cpp GeneralAttributeCheck.hpp Makefile.in SchemaElementDecl.cpp SchemaElementDecl.hpp TraverseSchema.cpp TraverseSchema.hpp XUtil.cpp XUtil.hpp
knoaman 01/11/02 06:13:46
Modified: c/src/validators/schema GeneralAttributeCheck.cpp
GeneralAttributeCheck.hpp Makefile.in
SchemaElementDecl.cpp SchemaElementDecl.hpp
TraverseSchema.cpp TraverseSchema.hpp XUtil.cpp
XUtil.hpp
Log:
Add support for identity constraints.
Revision Changes Path
1.11 +34 -2 xml-xerces/c/src/validators/schema/GeneralAttributeCheck.cpp
Index: GeneralAttributeCheck.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/GeneralAttributeCheck.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- GeneralAttributeCheck.cpp 2001/10/25 15:07:46 1.10
+++ GeneralAttributeCheck.cpp 2001/11/02 14:13:45 1.11
@@ -56,6 +56,9 @@
/*
* $Log: GeneralAttributeCheck.cpp,v $
+ * Revision 1.11 2001/11/02 14:13:45 knoaman
+ * Add support for identity constraints.
+ *
* Revision 1.10 2001/10/25 15:07:46 tng
* Thread safe the static instance.
*
@@ -379,6 +382,12 @@
fAttributes[Att_Version_N] =
new AttributeInfo(SchemaSymbols::fgATT_VERSION, Att_Optional_NoDefault,
0, 0);
+
+ fAttributes[Att_XPath_R] =
+ new AttributeInfo(SchemaSymbols::fgATT_XPATH, Att_Required, 0, DT_String);
+
+ fAttributes[Att_XPath1_R] =
+ new AttributeInfo(SchemaSymbols::fgATT_XPATH, Att_Required, 0, DT_String);
}
void GeneralAttributeCheck::setUpValidators() {
@@ -754,13 +763,35 @@
fElementMap->put((void*) SchemaSymbols::fgELT_DOCUMENTATION, prefixContext, attList);
// element "unique" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_UNIQUE, prefixContext, attList);
+
+ // element "key" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_KEY, prefixContext, attList);
// element "keyref" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ attList->addElement(fAttributes[Att_Refer_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_KEYREF, prefixContext, attList);
// element "selector" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_XPath_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_SELECTOR, prefixContext, attList);
// element "field" - local name
-
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_XPath1_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_FIELD, prefixContext, attList);
}
// ---------------------------------------------------------------------------
@@ -878,6 +909,7 @@
XMLCh* attName = attInfo->getName();
DOMString attValue = elem.getAttribute(attName);
+ DOM_Attr attNode = elem.getAttributeNode(attName);
unsigned int attValueLen = attValue.length();
attNameList.put((void*) attName, 0);
@@ -888,7 +920,7 @@
validate(attName, aBuffer.getRawBuffer(),
attInfo->getValidatorIndex(), schema);
}
- else {
+ else if (attNode == 0) {
if (attInfo->getDefaultOption() == Att_Required) {
schema->reportSchemaError(XMLUni::fgXMLErrDomain,
XMLErrs::AttributeRequired, attName, contextStr, elemName);
1.6 +3 -3 xml-xerces/c/src/validators/schema/GeneralAttributeCheck.hpp
Index: GeneralAttributeCheck.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/GeneralAttributeCheck.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- GeneralAttributeCheck.hpp 2001/10/23 23:14:55 1.5
+++ GeneralAttributeCheck.hpp 2001/11/02 14:13:45 1.6
@@ -55,7 +55,7 @@
*/
/*
- * $Id: GeneralAttributeCheck.hpp,v 1.5 2001/10/23 23:14:55 peiyongz Exp $
+ * $Id: GeneralAttributeCheck.hpp,v 1.6 2001/11/02 14:13:45 knoaman Exp $
*/
#if !defined(GENERALATTRIBUTECHECK_HPP)
@@ -231,8 +231,8 @@
Att_Value_STR_N,
Att_Value_WS_N,
Att_Version_N,
-
- // TO DO - Add XPath
+ Att_XPath_R,
+ Att_XPath1_R,
Att_Count
};
1.18 +11 -1 xml-xerces/c/src/validators/schema/Makefile.in
Index: Makefile.in
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/Makefile.in,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Makefile.in 2001/08/22 11:33:43 1.17
+++ Makefile.in 2001/11/02 14:13:45 1.18
@@ -55,6 +55,9 @@
#
#
# $Log: Makefile.in,v $
+# Revision 1.18 2001/11/02 14:13:45 knoaman
+# Add support for identity constraints.
+#
# Revision 1.17 2001/08/22 11:33:43 tng
# typo: XercesElementWildcard
#
@@ -170,9 +173,13 @@
XercesGroupInfo.$(TO) \
XUtil.$(TO)
-all:: includes $(VALIDATORS_SCHEMA_CPP_OBJECTS)
+all:: includes $(VALIDATORS_SCHEMA_CPP_OBJECTS) identity
includes:: pubheaders $(VALIDATORS_SCHEMA_C_FILES)
+ cd identity ; $(MAKE) $@ ; cd ..
+
+identity::
+ cd identity ; $(MAKE) ; cd ..
pubheaders::
-mkdir -p $(XML_INC_DIR)/$(MODULE)/$(SUBMODULE)
@@ -185,12 +192,15 @@
clean::
@echo "Making clean in $(MODULE)/$(SUBMODULE) ..."
$(RM2) $(addprefix $(XML_OBJ_DIR)/,$(VALIDATORS_SCHEMA_CPP_OBJECTS))
+ cd identity ; $(MAKE) $@ ; cd ..
distclean:: clean
$(RM) Makefile $(DEPFILE)
@echo "Removing all $(MODULE)/$(SUBMODULE) header files ..."
$(RM2) $(addprefix $(XML_INC_DIR)/$(MODULE)/$(SUBMODULE)/,$(VALIDATORS_SCHEMA_CPP_PUBHEADERS))
+ cd identity ; $(MAKE) $@ ; cd ..
install::
-mkdir -p $(PREFIX_INCLUDE)/$(MODULE)/$(SUBMODULE)
$(CP) $(VALIDATORS_SCHEMA_CPP_PUBHEADERS) $(VALIDATORS_SCHEMA_C_FILES) $(PREFIX_INCLUDE)/$(MODULE)/$(SUBMODULE)
+ cd identity ; $(MAKE) $@ ; cd ..
1.17 +8 -0 xml-xerces/c/src/validators/schema/SchemaElementDecl.cpp
Index: SchemaElementDecl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/SchemaElementDecl.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- SchemaElementDecl.cpp 2001/10/11 12:07:39 1.16
+++ SchemaElementDecl.cpp 2001/11/02 14:13:45 1.17
@@ -56,6 +56,9 @@
/*
* $Log: SchemaElementDecl.cpp,v $
+ * Revision 1.17 2001/11/02 14:13:45 knoaman
+ * Add support for identity constraints.
+ *
* Revision 1.16 2001/10/11 12:07:39 tng
* Schema: model type should be based on complextypeinfo if exists.
*
@@ -115,6 +118,7 @@
#include <util/XMLUni.hpp>
#include <validators/schema/SchemaAttDefList.hpp>
#include <validators/schema/SchemaElementDecl.hpp>
+#include <validators/schema/identity/IdentityConstraint.hpp>
// ---------------------------------------------------------------------------
// SchemaElementDecl: Constructors and Destructor
@@ -133,6 +137,7 @@
, fComplexTypeInfo(0)
, fXsiComplexTypeInfo(0)
, fAttDefs(0)
+ , fIdentityConstraints(0)
{
}
@@ -154,6 +159,7 @@
, fComplexTypeInfo(0)
, fXsiComplexTypeInfo(0)
, fAttDefs(0)
+ , fIdentityConstraints(0)
{
setElementName(prefix, localPart, uriId);
}
@@ -174,6 +180,7 @@
, fComplexTypeInfo(0)
, fXsiComplexTypeInfo(0)
, fAttDefs(0)
+ , fIdentityConstraints(0)
{
setElementName(elementName);
}
@@ -184,6 +191,7 @@
delete [] fSubstitutionGroupName;
delete [] fTypeFromAnotherSchemaURI;
delete fAttDefs;
+ delete fIdentityConstraints;
}
1.15 +59 -12 xml-xerces/c/src/validators/schema/SchemaElementDecl.hpp
Index: SchemaElementDecl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/SchemaElementDecl.hpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- SchemaElementDecl.hpp 2001/10/11 12:07:39 1.14
+++ SchemaElementDecl.hpp 2001/11/02 14:13:45 1.15
@@ -56,6 +56,9 @@
/*
* $Log: SchemaElementDecl.hpp,v $
+ * Revision 1.15 2001/11/02 14:13:45 knoaman
+ * Add support for identity constraints.
+ *
* Revision 1.14 2001/10/11 12:07:39 tng
* Schema: model type should be based on complextypeinfo if exists.
*
@@ -111,6 +114,7 @@
class ContentSpecNode;
class SchemaAttDefList;
class DatatypeValidator;
+class IdentityConstraint;
//
// This class is a derivative of the basic element decl. This one implements
@@ -223,6 +227,13 @@
void setComplexTypeInfo(ComplexTypeInfo* const typeInfo);
void setXsiComplexTypeInfo(ComplexTypeInfo* const typeInfo);
+ // -----------------------------------------------------------------------
+ // IC methods
+ // -----------------------------------------------------------------------
+ void addIdentityConstraint(IdentityConstraint* const ic);
+ unsigned int getIdentityConstraintCount() const;
+ IdentityConstraint* getIdentityConstraintAt(unsigned int index) const;
+
private :
// -----------------------------------------------------------------------
// Private data members
@@ -271,20 +282,24 @@
// fXsiComplexTypeInfo
// Temporary store the xsi:type ComplexType here for validation
// If it presents, then it takes precedence than its own fComplexTypeInfo.
+ //
+ // fIdentityConstraints
+ // Store information about an element identity constraints.
// -----------------------------------------------------------------------
- ModelTypes fModelType;
- DatatypeValidator* fDatatypeValidator;
- int fEnclosingScope;
- int fDefinedScope;
- int fFinalSet;
- int fBlockSet;
- int fMiscFlags;
- XMLCh* fDefaultValue;
- XMLCh* fSubstitutionGroupName;
- XMLCh* fTypeFromAnotherSchemaURI;
- ComplexTypeInfo* fComplexTypeInfo;
+ ModelTypes fModelType;
+ DatatypeValidator* fDatatypeValidator;
+ int fEnclosingScope;
+ int fDefinedScope;
+ int fFinalSet;
+ int fBlockSet;
+ int fMiscFlags;
+ XMLCh* fDefaultValue;
+ XMLCh* fSubstitutionGroupName;
+ XMLCh* fTypeFromAnotherSchemaURI;
+ ComplexTypeInfo* fComplexTypeInfo;
RefHash2KeysTableOf<SchemaAttDef>* fAttDefs;
- ComplexTypeInfo* fXsiComplexTypeInfo;
+ ComplexTypeInfo* fXsiComplexTypeInfo;
+ RefVectorOf<IdentityConstraint>* fIdentityConstraints;
};
// ---------------------------------------------------------------------------
@@ -509,6 +524,38 @@
SchemaElementDecl::setXsiComplexTypeInfo(ComplexTypeInfo* const typeInfo)
{
fXsiComplexTypeInfo = typeInfo;
+}
+
+// ---------------------------------------------------------------------------
+// SchemaElementDecl: IC methods
+// ---------------------------------------------------------------------------
+inline void
+SchemaElementDecl::addIdentityConstraint(IdentityConstraint* const ic) {
+
+ if (!fIdentityConstraints) {
+ fIdentityConstraints = new RefVectorOf<IdentityConstraint>(16);
+ }
+
+ fIdentityConstraints->addElement(ic);
+}
+
+inline unsigned int SchemaElementDecl::getIdentityConstraintCount() const {
+
+ if (fIdentityConstraints) {
+ return fIdentityConstraints->size();
+ }
+
+ return 0;
+}
+
+inline IdentityConstraint*
+SchemaElementDecl::getIdentityConstraintAt(unsigned int index) const {
+
+ if (fIdentityConstraints) {
+ return fIdentityConstraints->elementAt(index);
+ }
+
+ return 0;
}
#endif
1.54 +517 -62 xml-xerces/c/src/validators/schema/TraverseSchema.cpp
Index: TraverseSchema.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/TraverseSchema.cpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- TraverseSchema.cpp 2001/10/16 17:01:34 1.53
+++ TraverseSchema.cpp 2001/11/02 14:13:45 1.54
@@ -55,19 +55,22 @@
*/
/*
- * $Id: TraverseSchema.cpp,v 1.53 2001/10/16 17:01:34 knoaman Exp $
+ * $Id: TraverseSchema.cpp,v 1.54 2001/11/02 14:13:45 knoaman Exp $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/TraverseSchema.hpp>
+#include <sax/EntityResolver.hpp>
+#include <validators/schema/identity/IC_Key.hpp>
+#include <validators/schema/identity/IC_KeyRef.hpp>
+#include <validators/schema/identity/IC_Unique.hpp>
+#include <validators/schema/identity/IC_Field.hpp>
+#include <validators/schema/identity/IC_Selector.hpp>
+#include <validators/schema/identity/XercesXPath.hpp>
#include <validators/datatype/DatatypeValidatorFactory.hpp>
-#include <dom/DOM_NamedNodeMap.hpp>
-#include <util/Janitor.hpp>
-#include <util/KVStringPair.hpp>
#include <util/XMLStringTokenizer.hpp>
-#include <util/QName.hpp>
#include <validators/schema/XUtil.hpp>
#include <validators/common/GrammarResolver.hpp>
#include <validators/schema/SchemaGrammar.hpp>
@@ -77,22 +80,18 @@
#include <validators/schema/ComplexTypeInfo.hpp>
#include <validators/schema/NamespaceScope.hpp>
#include <validators/schema/SchemaAttDefList.hpp>
-#include <framework/XMLValidityCodes.hpp>
-#include <framework/XMLErrorCodes.hpp>
#include <internal/XMLScanner.hpp>
#include <internal/XMLInternalErrorHandler.hpp>
-#include <framework/XMLValidator.hpp>
-#include <sax/EntityResolver.hpp>
-#include <sax/InputSource.hpp>
#include <framework/LocalFileInputSource.hpp>
#include <framework/URLInputSource.hpp>
#include <parsers/DOMParser.hpp>
-#include <dom/DOM_DOMException.hpp>
#include <validators/datatype/InvalidDatatypeValueException.hpp>
#include <validators/datatype/InvalidDatatypeFacetException.hpp>
+#include <validators/schema/identity/XPathException.hpp>
#include <validators/schema/GeneralAttributeCheck.hpp>
#include <validators/schema/XercesGroupInfo.hpp>
#include <validators/schema/XercesAttGroupInfo.hpp>
+#include <util/HashPtr.hpp>
// ---------------------------------------------------------------------------
// TraverseSchema: Local declaration
@@ -154,6 +153,28 @@
chDigit_0, chNull
};
+const XMLCh fgForwardSlash[] =
+{
+ chForwardSlash, chNull
+};
+
+const XMLCh fgDot[] =
+{
+ chPeriod, chNull
+};
+
+const XMLCh fgDotForwardSlash[] =
+{
+ chPeriod, chForwardSlash, chNull
+};
+
+const XMLCh* fgIdentityConstraints[] =
+{
+ { SchemaSymbols::fgELT_UNIQUE },
+ { SchemaSymbols::fgELT_KEY },
+ { SchemaSymbols::fgELT_KEYREF }
+};
+
// ---------------------------------------------------------------------------
// TraverseSchema: Constructors and Destructor
// ---------------------------------------------------------------------------
@@ -197,17 +218,20 @@
, fCurrentComplexType(0)
, fCurrentTypeNameStack(0)
, fCurrentGroupStack(0)
+ , fIC_NamespaceDepth(0)
+ , fIC_Elements(0)
, fAttributeCheck(0)
- , fGlobalTypes(0)
- , fGlobalAttributes(0)
- , fGlobalGroups(0)
- , fGlobalAttGroups(0)
+ , fGlobalDeclarations(0)
, fNotationRegistry(0)
, fRedefineComponents(0)
+ , fIdentityConstraintNames(0)
, fSubstitutionGroups(0)
, fValidSubstitutionGroups(0)
, fRefElements(0)
, fRefElemScope(0)
+ , fIC_NodeListNS(0)
+ , fIC_ElementsNS(0)
+ , fIC_NamespaceDepthNS(0)
{
try {
@@ -349,8 +373,26 @@
fScopeCount = 0;
processChildren(schemaRoot);
- // Handle identity constraints
- // TO DO
+ // Handle identity constraints - keyref
+ if (fIC_ElementsNS && fIC_ElementsNS->containsKey(fTargetNSURIString)) {
+
+ fIC_Elements = fIC_ElementsNS->get(fTargetNSURIString);
+ fIC_NamespaceDepth = fIC_NamespaceDepthNS->get(fTargetNSURIString);
+
+ unsigned int icListSize = fIC_Elements->size();
+
+ for (unsigned int i=0; i < icListSize; i++) {
+
+ SchemaElementDecl* curElem = fIC_Elements->elementAt(i);
+ ValueVectorOf<DOM_Element>* icNodes = fIC_NodeListNS->get(curElem);
+ unsigned int icNodesSize = icNodes->size();
+ unsigned int scopeDepth = fIC_NamespaceDepth->elementAt(i);
+
+ for (unsigned int j = 0; j < icNodesSize; j++) {
+ traverseKeyRef(icNodes->elementAt(j), curElem, scopeDepth);
+ }
+ }
+ }
// Element consistency checks - substitution groups
if (fFullConstraintChecking) {
@@ -616,12 +658,20 @@
SchemaGrammar* importedGrammar = 0;
- if (nameSpace) {
+ if (nameSpace) {
+
+ Grammar* aGrammar = fGrammarResolver->getGrammar(nameSpace);
- importedGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(nameSpace);
+ if (aGrammar) {
+
+ if (aGrammar->getGrammarType() == Grammar::SchemaGrammarType) {
- if (importedGrammar) {
- return;
+ importedGrammar = (SchemaGrammar*) aGrammar;
+ return;
+ }
+ else { // empty string namespace
+ //REVISIT
+ }
}
}
@@ -1701,9 +1751,9 @@
const XMLCh* useVal = getElementAttValue(elem, SchemaSymbols::fgATT_USE);
DOM_Element simpleType = checkContent(elem, XUtil::getFirstChildElement(elem), true);
- if(XMLString::stringLen(defaultVal) != 0) {
+ if(defaultVal) {
- if (XMLString::stringLen(fixedVal) != 0) {
+ if (fixedVal) {
fixedVal = 0;
reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttributeDefaultFixedValue);
@@ -1900,10 +1950,9 @@
}
// validate fixed/default values
- const XMLCh* valueToCheck = XMLString::stringLen(defaultVal) ? defaultVal : fixedVal;
+ const XMLCh* valueToCheck = defaultVal ? defaultVal : fixedVal;
- if (attType == XMLAttDef::Simple && dv != 0
- && XMLString::stringLen(valueToCheck) != 0) {
+ if (attType == XMLAttDef::Simple && dv && valueToCheck) {
try {
dv->validate(valueToCheck);
@@ -1932,24 +1981,24 @@
}
else if (required) {
- if (XMLString::stringLen(fixedVal) == 0) {
- attDef->setDefaultType(XMLAttDef::Required);
+ if (fixedVal) {
+ attDef->setDefaultType(XMLAttDef::Required_And_Fixed);
}
else {
- attDef->setDefaultType(XMLAttDef::Required_And_Fixed);
+ attDef->setDefaultType(XMLAttDef::Required);
}
}
else {
- if (XMLString::stringLen(fixedVal) != 0) {
+ if (fixedVal) {
attDef->setDefaultType(XMLAttDef::Fixed);
}
- else if (XMLString::stringLen(defaultVal) != 0) {
+ else if (defaultVal) {
attDef->setDefaultType(XMLAttDef::Default);
}
}
- if (XMLString::stringLen(valueToCheck) != 0) {
+ if (valueToCheck) {
attDef->setValue(valueToCheck);
}
@@ -2369,11 +2418,6 @@
}
}
- // key/keyref/unique processing
- // TO DO
-
-
-
// set element information, but first check for duplicate elements with
// different types.
if (isDuplicate) {
@@ -2394,6 +2438,60 @@
elemDecl->setModelType(contentSpecType);
elemDecl->setContentSpec(contentSpecNode);
elemDecl->setTypeFromAnotherSchemaURI(anotherSchemaURI);
+
+ // key/keyref/unique processing
+ DOM_Element ic = XUtil::getFirstChildElementNS(elem, fgIdentityConstraints,
+ SchemaSymbols::fgURI_SCHEMAFORSCHEMA, 3);
+ ValueVectorOf<DOM_Element>* icNodes = 0;
+
+ while (ic != 0) {
+
+ if ( ic.getLocalName().equals(SchemaSymbols::fgELT_KEY) ) {
+ traverseKey(ic, elemDecl);
+ }
+ else if ( ic.getLocalName().equals(SchemaSymbols::fgELT_UNIQUE) ) {
+ traverseUnique(ic, elemDecl);
+ }
+ else {
+
+ if (!icNodes) {
+ icNodes = new ValueVectorOf<DOM_Element>(8);
+ }
+
+ icNodes->addElement(ic);
+ }
+
+ ic = XUtil::getNextSiblingElementNS(ic, fgIdentityConstraints,
+ SchemaSymbols::fgURI_SCHEMAFORSCHEMA, 3);
+ }
+
+ if (icNodes) {
+
+ if (!fIC_ElementsNS) {
+
+ fIC_ElementsNS = new RefHashTableOf<ElemVector>(13);
+ fIC_NamespaceDepthNS = new RefHashTableOf<ValueVectorOf<unsigned int> >(13);
+ fIC_NodeListNS = new RefHashTableOf<ValueVectorOf<DOM_Element> >(29, true, new HashPtr());
+ }
+
+ if (fIC_ElementsNS->containsKey(fTargetNSURIString)) {
+
+ fIC_Elements = fIC_ElementsNS->get(fTargetNSURIString);
+ fIC_NamespaceDepth = fIC_NamespaceDepthNS->get(fTargetNSURIString);
+ }
+
+ if (!fIC_Elements) {
+
+ fIC_Elements = new ValueVectorOf<SchemaElementDecl*>(8);
+ fIC_NamespaceDepth = new ValueVectorOf<unsigned int>(8);
+ fIC_ElementsNS->put((void*) fTargetNSURIString, fIC_Elements);
+ fIC_NamespaceDepthNS->put((void*) fTargetNSURIString, fIC_NamespaceDepth);
+ }
+
+ fIC_NodeListNS->put(elemDecl, icNodes);
+ fIC_Elements->addElement(elemDecl);
+ fIC_NamespaceDepth->addElement(fSchemaInfo->getNamespaceScopeLevel());
+ }
}
return new QName(elemDecl->getElementName());
@@ -2665,7 +2763,7 @@
const XMLCh* const enumVal = fStringPool->getValueForId(enumValId);
const XMLCh* localPart = getLocalPart(enumVal);
const XMLCh* prefix = getPrefix(enumVal);
- const XMLCh* uriStr = (prefix) ? resolvePrefixToURI(prefix) : fTargetNSURIString;
+ const XMLCh* uriStr = (XMLString::stringLen(prefix)) ? resolvePrefixToURI(prefix) : fTargetNSURIString;
unsigned int uriId = fURIStringPool->addOrFind(uriStr);
if (!fNotationRegistry->containsKey(localPart, uriId)) {
@@ -3482,6 +3580,329 @@
return attDef;
}
+/**
+ * <key
+ * id = ID
+ * name = NCName
+ * Content: (annotation?, (selector, field+))
+ * </key>
+ */
+void TraverseSchema::traverseKey(const DOM_Element& icElem,
+ SchemaElementDecl* const elemDecl) {
+
+ // -----------------------------------------------------------------------
+ // Check Attributes
+ // -----------------------------------------------------------------------
+ unsigned short scope = GeneralAttributeCheck::LocalContext;
+ fAttributeCheck->checkAttributes(icElem, scope, this);
+
+ // -----------------------------------------------------------------------
+ // Create identity constraint
+ // -----------------------------------------------------------------------
+ const XMLCh* name = getElementAttValue(icElem, SchemaSymbols::fgATT_NAME);
+
+ if (!XMLString::stringLen(name)) {
+ return;
+ }
+
+ if (!fIdentityConstraintNames) {
+ fIdentityConstraintNames = new RefHash2KeysTableOf<IdentityConstraint>(29, false);
+ }
+
+ if (fIdentityConstraintNames->containsKey(name, fTargetNSURI)) {
+
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_DuplicateDecl, name);
+ return;
+ }
+
+ IC_Key* icKey = new IC_Key(name, elemDecl->getBaseName());
+ Janitor<IC_Key> janKey(icKey);
+
+ fIdentityConstraintNames->put((void*) name, fTargetNSURI, icKey);
+
+ // -----------------------------------------------------------------------
+ // Get selector and fields
+ // -----------------------------------------------------------------------
+ if (!traverseIdentityConstraint(icKey, icElem)) {
+
+ fIdentityConstraintNames->put((void*) name, fTargetNSURI, 0);
+ return;
+ }
+
+ // -----------------------------------------------------------------------
+ // Add key to element declaration
+ // -----------------------------------------------------------------------
+ elemDecl->addIdentityConstraint(icKey);
+ janKey.orphan();
+}
+
+/**
+ * <unique
+ * id = ID
+ * name = NCName
+ * Content: (annotation?, (selector, field+))
+ * </unique>
+ */
+void TraverseSchema::traverseUnique(const DOM_Element& icElem,
+ SchemaElementDecl* const elemDecl) {
+
+ // -----------------------------------------------------------------------
+ // Check Attributes
+ // -----------------------------------------------------------------------
+ unsigned short scope = GeneralAttributeCheck::LocalContext;
+ fAttributeCheck->checkAttributes(icElem, scope, this);
+
+ // -----------------------------------------------------------------------
+ // Create identity constraint
+ // -----------------------------------------------------------------------
+ const XMLCh* name = getElementAttValue(icElem, SchemaSymbols::fgATT_NAME);
+
+ if (!XMLString::stringLen(name)) {
+ return;
+ }
+
+ if (!fIdentityConstraintNames) {
+ fIdentityConstraintNames = new RefHash2KeysTableOf<IdentityConstraint>(29, false);
+ }
+
+ if (fIdentityConstraintNames->containsKey(name, fTargetNSURI)) {
+
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_DuplicateDecl, name);
+ return;
+ }
+
+ IC_Unique* icUnique = new IC_Unique(name, elemDecl->getBaseName());
+ Janitor<IC_Unique> janUnique(icUnique);
+
+ fIdentityConstraintNames->put((void*) name, fTargetNSURI, icUnique);
+
+ // -----------------------------------------------------------------------
+ // Get selector and fields
+ // -----------------------------------------------------------------------
+ if (!traverseIdentityConstraint(icUnique, icElem)) {
+
+ fIdentityConstraintNames->put((void*) name, fTargetNSURI, 0);
+ return;
+ }
+
+ // -----------------------------------------------------------------------
+ // Add identity cosntraints to element declaration
+ // -----------------------------------------------------------------------
+ elemDecl->addIdentityConstraint(icUnique);
+ janUnique.orphan();
+}
+
+/**
+ * <keyref
+ * id = ID
+ * name = NCName
+ * refer = QName
+ * Content: (annotation?, (selector, field+))
+ * </keyref>
+ */
+void TraverseSchema::traverseKeyRef(const DOM_Element& icElem,
+ SchemaElementDecl* const elemDecl,
+ const unsigned int namespaceDepth) {
+
+ // -----------------------------------------------------------------------
+ // Check Attributes
+ // -----------------------------------------------------------------------
+ unsigned short scope = GeneralAttributeCheck::LocalContext;
+ fAttributeCheck->checkAttributes(icElem, scope, this);
+
+ // -----------------------------------------------------------------------
+ // Verify that key reference "refer" attribute is valid
+ // -----------------------------------------------------------------------
+ const XMLCh* name = getElementAttValue(icElem, SchemaSymbols::fgATT_NAME);
+ const XMLCh* refer = getElementAttValue(icElem, SchemaSymbols::fgATT_REFER);
+
+ if (!XMLString::stringLen(name) || !XMLString::stringLen(refer)) {
+ return;
+ }
+
+ const XMLCh* prefix = getPrefix(refer);
+ const XMLCh* localPart = getLocalPart(refer);
+ const XMLCh* uriStr = resolvePrefixToURI(prefix, namespaceDepth);
+ IdentityConstraint* icKey = (fIdentityConstraintNames)
+ ? fIdentityConstraintNames->get(localPart, fURIStringPool->addOrFind(uriStr)) : 0;
+
+ if (!icKey) {
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_KeyRefReferNotFound, name, localPart);
+ return;
+ }
+
+ // -----------------------------------------------------------------------
+ // Create identity constraint
+ // -----------------------------------------------------------------------
+ if(fIdentityConstraintNames->containsKey(name, fTargetNSURI)) {
+
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_DuplicateDecl, name);
+ return;
+ }
+
+ IC_KeyRef* icKeyRef = new IC_KeyRef(name, elemDecl->getBaseName(), icKey);
+ Janitor<IC_KeyRef> janKeyRef(icKeyRef);
+
+ fIdentityConstraintNames->put((void*) name, fTargetNSURI, icKeyRef);
+
+ // -----------------------------------------------------------------------
+ // Get selector and fields
+ // -----------------------------------------------------------------------
+ if (!traverseIdentityConstraint(icKeyRef, icElem)) {
+
+ fIdentityConstraintNames->put((void*) name, fTargetNSURI, 0);
+ return;
+ }
+
+ // -----------------------------------------------------------------------
+ // Add key reference to element decl
+ // -----------------------------------------------------------------------
+ if (icKeyRef->getFieldCount() != icKey->getFieldCount()) {
+
+ fIdentityConstraintNames->put((void*) name, fTargetNSURI, 0);
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_KeyRefCardinality,
+ name, icKey->getIdentityConstraintName());
+ }
+ else {
+
+ elemDecl->addIdentityConstraint(icKeyRef);
+ janKeyRef.orphan();
+ }
+}
+
+
+bool TraverseSchema::traverseIdentityConstraint(IdentityConstraint* const ic,
+ const DOM_Element& icElem) {
+
+ // -----------------------------------------------------------------------
+ // Check Attributes
+ // -----------------------------------------------------------------------
+ unsigned short scope = GeneralAttributeCheck::LocalContext;
+ fAttributeCheck->checkAttributes(icElem, scope, this);
+
+ // ------------------------------------------------------------------
+ // First, handle any ANNOTATION declaration
+ // ------------------------------------------------------------------
+ DOM_Element elem = XUtil::getFirstChildElement(icElem);
+
+ if (elem == 0) {
+
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_BadContent);
+ return false;
+ }
+
+ elem = checkContent(icElem, elem, false);
+
+ // ------------------------------------------------------------------
+ // Get selector
+ // ------------------------------------------------------------------
+ if (!elem.getLocalName().equals(SchemaSymbols::fgELT_SELECTOR)) {
+
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_BadContent);
+ return false;
+ }
+
+ fAttributeCheck->checkAttributes(elem, scope, this);
+ checkContent(icElem, XUtil::getFirstChildElement(elem), true);
+
+ // ------------------------------------------------------------------
+ // Get xpath attribute
+ // ------------------------------------------------------------------
+ const XMLCh* xpathExpr = getElementAttValue(elem, SchemaSymbols::fgATT_XPATH, true);
+
+ if (!xpathExpr || !XMLString::stringLen(xpathExpr)) {
+
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_XPathExprMissing);
+ return false;
+ }
+
+ if (XMLString::startsWith(xpathExpr, fgForwardSlash)
+ || XMLString::startsWith(xpathExpr, fgDot)) {
+ fBuffer.set(xpathExpr);
+ }
+ else {
+ fBuffer.set(fgDotForwardSlash);
+ fBuffer.append(xpathExpr);
+ }
+
+ // ------------------------------------------------------------------
+ // Parse xpath expression
+ // ------------------------------------------------------------------
+ try {
+
+ XercesXPath* sXPath = new XercesXPath(fBuffer.getRawBuffer(), fStringPool, fNamespaceScope, fEmptyNamespaceURI, true);
+ IC_Selector* icSelector = new IC_Selector(sXPath, ic);
+ ic->setSelector(icSelector);
+ }
+ catch (const XPathException& e) {
+
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, e.getMessage());
+ return false;
+ }
+
+ // ------------------------------------------------------------------
+ // Get fields
+ // ------------------------------------------------------------------
+ elem = XUtil::getNextSiblingElement(elem);
+
+ if (elem == 0) {
+
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_BadContent);
+ return false;
+ }
+
+ while (elem != 0) {
+
+ if (!elem.getLocalName().equals(SchemaSymbols::fgELT_FIELD)) {
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_BadContent);
+ }
+ else {
+ // General Attribute Checking
+ fAttributeCheck->checkAttributes(elem, scope, this);
+ checkContent(icElem, XUtil::getFirstChildElement(elem), true);
+
+ // xpath expression parsing
+ xpathExpr = getElementAttValue(elem, SchemaSymbols::fgATT_XPATH, true);
+
+ if (!xpathExpr || !XMLString::stringLen(xpathExpr)) {
+
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_XPathExprMissing);
+ return false;
+ }
+
+ if (XMLString::startsWith(xpathExpr, fgForwardSlash)
+ || XMLString::startsWith(xpathExpr, fgDot)) {
+ fBuffer.set(xpathExpr);
+ }
+ else {
+
+ fBuffer.set(fgDotForwardSlash);
+ fBuffer.append(xpathExpr);
+ }
+
+ try {
+
+ XercesXPath* fieldXPath = new XercesXPath(fBuffer.getRawBuffer(), fStringPool, fNamespaceScope, fEmptyNamespaceURI);
+ IC_Field* icField = new IC_Field(fieldXPath, ic);
+ ic->addField(icField);
+ }
+ catch (const XPathException& e) {
+
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, e.getMessage());
+ return false;
+ }
+ }
+
+ elem = XUtil::getNextSiblingElement(elem);
+ }
+
+ if (ic->getFieldCount() == 0) {
+ return false;
+ }
+
+ return true;
+}
+
// ---------------------------------------------------------------------------
// TraverseSchema: Helper methods
// ---------------------------------------------------------------------------
@@ -3562,6 +3983,15 @@
DOMString name = child.getLocalName();
const XMLCh* typeName = getElementAttValue(child, SchemaSymbols::fgATT_NAME);
+ int fullNameId = 0;
+
+ if (typeName) {
+
+ fBuffer.set(fTargetNSURIString);
+ fBuffer.append(chComma);
+ fBuffer.append(typeName);
+ fullNameId = fStringPool->addOrFind(fBuffer.getRawBuffer());
+ }
if (name.equals(SchemaSymbols::fgELT_ANNOTATION)) {
traverseAnnotationDecl(child);
@@ -3569,13 +3999,14 @@
else if (name.equals(SchemaSymbols::fgELT_SIMPLETYPE)) {
if (XMLString::stringLen(typeName)) {
- if (fGlobalTypes->containsKey(typeName, fTargetNSURI)) {
+ if (fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_SIMPLETYPE, fullNameId)
+ || fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_COMPLEXTYPE, fullNameId)) {
reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateGlobalType,
SchemaSymbols::fgELT_SIMPLETYPE, typeName, SchemaSymbols::fgELT_COMPLEXTYPE);
continue;
}
else {
- fGlobalTypes->put((void*) typeName, fTargetNSURI, 0);
+ fGlobalDeclarations->put((void*) SchemaSymbols::fgELT_SIMPLETYPE, fullNameId, 0);
}
}
@@ -3584,14 +4015,15 @@
else if (name.equals(SchemaSymbols::fgELT_COMPLEXTYPE)) {
if (XMLString::stringLen(typeName)) {
- if (fGlobalTypes->containsKey(typeName, fTargetNSURI)) {
+ if (fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_SIMPLETYPE, fullNameId)
+ || fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_COMPLEXTYPE, fullNameId)) {
reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateGlobalType,
SchemaSymbols::fgELT_COMPLEXTYPE, typeName, SchemaSymbols::fgELT_SIMPLETYPE);
continue;
}
else {
- fGlobalTypes->put((void*) typeName, fTargetNSURI, 0);
+ fGlobalDeclarations->put((void*) SchemaSymbols::fgELT_COMPLEXTYPE, fullNameId, 0);
}
}
@@ -3599,6 +4031,18 @@
}
else if (name.equals(SchemaSymbols::fgELT_ELEMENT)) {
+ if (XMLString::stringLen(typeName)) {
+ if (fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_ELEMENT, fullNameId)) {
+
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateGlobalDeclaration,
+ SchemaSymbols::fgELT_ELEMENT, typeName);
+ continue;
+ }
+ else {
+ fGlobalDeclarations->put((void*) SchemaSymbols::fgELT_ELEMENT, fullNameId, 0);
+ }
+ }
+
bool toDelete = true;
QName* elmQName = traverseElementDecl(child, toDelete);
delete elmQName;
@@ -3606,13 +4050,13 @@
else if (name.equals(SchemaSymbols::fgELT_ATTRIBUTEGROUP)) {
if (XMLString::stringLen(typeName)) {
- if (fGlobalAttGroups->containsKey(typeName, fTargetNSURI)) {
+ if (fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_ATTRIBUTEGROUP, fullNameId)) {
reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateGlobalDeclaration,
SchemaSymbols::fgELT_ATTRIBUTEGROUP, typeName);
continue;
}
else {
- fGlobalAttGroups->put((void*) typeName, fTargetNSURI, 0);
+ fGlobalDeclarations->put((void*) SchemaSymbols::fgELT_ATTRIBUTEGROUP, fullNameId, 0);
}
}
@@ -3620,16 +4064,16 @@
traverseAttributeGroupDecl(child, 0);
}
}
- else if (name.equals(SchemaSymbols::fgELT_ATTRIBUTE ) ) {
+ else if (name.equals(SchemaSymbols::fgELT_ATTRIBUTE)) {
if (XMLString::stringLen(typeName)) {
- if (fGlobalAttributes->containsKey(typeName, fTargetNSURI)) {
+ if (fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_ATTRIBUTE, fullNameId)) {
reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateAttribute, typeName);
continue;
}
else {
- fGlobalAttributes->put((void*) typeName, fTargetNSURI, 0);
+ fGlobalDeclarations->put((void*) SchemaSymbols::fgELT_ATTRIBUTE, fullNameId, 0);
}
}
@@ -3640,13 +4084,13 @@
else if (name.equals(SchemaSymbols::fgELT_GROUP)) {
if (XMLString::stringLen(typeName)) {
- if (fGlobalGroups->containsKey(typeName, fTargetNSURI)) {
+ if (fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_GROUP, fullNameId)) {
reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateGlobalDeclaration,
SchemaSymbols::fgELT_GROUP, typeName);
continue;
}
else {
- fGlobalGroups->put((void*) typeName, fTargetNSURI, 0);
+ fGlobalDeclarations->put((void*) SchemaSymbols::fgELT_GROUP, fullNameId, 0);
}
}
@@ -3834,6 +4278,20 @@
return uriStr;
}
+const XMLCh* TraverseSchema::resolvePrefixToURI(const XMLCh* const prefix,
+ const unsigned int namespaceDepth) {
+
+ int nameSpaceIndex = fNamespaceScope->getNamespaceForPrefix(prefix, namespaceDepth);
+ const XMLCh* uriStr = fURIStringPool->getValueForId(nameSpaceIndex);
+
+ if (!XMLString::stringLen(uriStr) && XMLString::stringLen(prefix)) {
+ reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::UnresolvedPrefix, prefix);
+ return XMLUni::fgZeroLenString;
+ }
+
+ return uriStr;
+}
+
bool TraverseSchema::isTopLevelComponent(const DOM_Element& elem) {
@@ -4424,7 +4882,7 @@
const XMLCh* nillable = getElementAttValue(elem, SchemaSymbols::fgATT_NILLABLE);
const XMLCh* abstract = getElementAttValue(elem, SchemaSymbols::fgATT_ABSTRACT);
- if (nillable) {
+ if (XMLString::stringLen(nillable)) {
if (!XMLString::compareString(nillable, SchemaSymbols::fgATTVAL_TRUE)
|| !XMLString::compareString(nillable, fgValueOne)) {
@@ -4432,7 +4890,7 @@
}
}
- if (abstract) {
+ if (XMLString::stringLen(abstract)) {
if (!XMLString::compareString(abstract, SchemaSymbols::fgATTVAL_TRUE)
|| !XMLString::compareString(abstract, fgValueOne)) {
@@ -5439,10 +5897,9 @@
const DatatypeValidator* const baseDV,
unsigned int& flags)
{
- const XMLCh* fixedFacet =
- getElementAttValue(elem, SchemaSymbols::fgATT_FIXED);
+ const XMLCh* fixedFacet = getElementAttValue(elem, SchemaSymbols::fgATT_FIXED);
- if (fixedFacet &&
+ if (XMLString::stringLen(fixedFacet) &&
(!XMLString::compareString(fixedFacet, SchemaSymbols::fgATTVAL_TRUE)
|| !XMLString::compareString(fixedFacet, fgValueOne))) {
@@ -6899,10 +7356,7 @@
fAttributeCheck = GeneralAttributeCheck::instance();
fCurrentTypeNameStack = new ValueVectorOf<unsigned int>(8);
fCurrentGroupStack = new ValueVectorOf<unsigned int>(8);
- fGlobalTypes = new RefHash2KeysTableOf<XMLCh>(29, false);
- fGlobalAttributes = new RefHash2KeysTableOf<XMLCh>(13, false);
- fGlobalGroups = new RefHash2KeysTableOf<XMLCh>(13, false);
- fGlobalAttGroups = new RefHash2KeysTableOf<XMLCh>(13, false);
+ fGlobalDeclarations = new RefHash2KeysTableOf<XMLCh>(29, false);
fNotationRegistry = new RefHash2KeysTableOf<XMLCh>(13, false);
fSubstitutionGroups = new RefHash2KeysTableOf<SchemaElementDecl>(29, false);
fSchemaInfoList = new RefHashTableOf<SchemaInfo>(29);
@@ -6913,15 +7367,16 @@
delete fSchemaInfoList;
delete fCurrentTypeNameStack;
delete fCurrentGroupStack;
- delete fGlobalTypes;
- delete fGlobalAttributes;
- delete fGlobalGroups;
- delete fGlobalAttGroups;
+ delete fGlobalDeclarations;
delete fNotationRegistry;
delete fRedefineComponents;
+ delete fIdentityConstraintNames;
delete fSubstitutionGroups;
delete fRefElements;
delete fRefElemScope;
+ delete fIC_ElementsNS;
+ delete fIC_NamespaceDepthNS;
+ delete fIC_NodeListNS;
}
/**
1.25 +72 -49 xml-xerces/c/src/validators/schema/TraverseSchema.hpp
Index: TraverseSchema.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/TraverseSchema.hpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- TraverseSchema.hpp 2001/10/19 15:48:34 1.24
+++ TraverseSchema.hpp 2001/11/02 14:13:45 1.25
@@ -55,7 +55,7 @@
*/
/*
- * $Id: TraverseSchema.hpp,v 1.24 2001/10/19 15:48:34 jberry Exp $
+ * $Id: TraverseSchema.hpp,v 1.25 2001/11/02 14:13:45 knoaman Exp $
*/
#if !defined(TRAVERSESCHEMA_HPP)
@@ -71,6 +71,7 @@
// ---------------------------------------------------------------------------
#include <util/XMLUniDefs.hpp>
#include <dom/DOM_Element.hpp>
+#include <dom/DOM_Attr.hpp>
#include <framework/XMLBuffer.hpp>
#include <validators/schema/SchemaSymbols.hpp>
#include <util/ValueVectorOf.hpp>
@@ -98,6 +99,7 @@
class GeneralAttributeCheck;
class XercesGroupInfo;
class XercesAttGroupInfo;
+class IdentityConstraint;
class VALIDATORS_EXPORT TraverseSchema
@@ -205,6 +207,15 @@
XercesAttGroupInfo* traverseAttributeGroupDeclNS(const XMLCh* const uriStr,
const XMLCh* const name);
SchemaAttDef* traverseAnyAttribute(const DOM_Element& elem);
+ void traverseKey(const DOM_Element& icElem,
+ SchemaElementDecl* const elemDecl);
+ void traverseUnique(const DOM_Element& icElem,
+ SchemaElementDecl* const elemDecl);
+ void traverseKeyRef(const DOM_Element& icElem,
+ SchemaElementDecl* const elemDecl,
+ const unsigned int namespaceDepth);
+ bool traverseIdentityConstraint(IdentityConstraint* const ic,
+ const DOM_Element& icElem);
// -----------------------------------------------------------------------
// Error Reporting methods
@@ -286,6 +297,8 @@
const int baseRefContext);
const XMLCh* resolvePrefixToURI(const XMLCh* const prefix);
+ const XMLCh* resolvePrefixToURI(const XMLCh* const prefix,
+ const unsigned int namespaceDepth);
/**
* Return whether an element is defined as a top level schema component
@@ -643,6 +656,9 @@
*/
void updateCircularSubstitutionList(SchemaInfo* const aSchemaInfo);
+ void processKeyRefFor(SchemaInfo* const aSchemaInfo,
+ ValueVectorOf<SchemaInfo*>* const infoList);
+
// -----------------------------------------------------------------------
// Private constants
// -----------------------------------------------------------------------
@@ -669,50 +685,52 @@
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
- bool fFullConstraintChecking;
- unsigned short fElemAttrDefaultQualified;
- int fTargetNSURI;
- int fEmptyNamespaceURI;
- int fCurrentScope;
- int fFinalDefault;
- int fBlockDefault;
- int fScopeCount;
- unsigned int fAnonXSTypeCount;
- const XMLCh* fTargetNSURIString;
- DatatypeValidatorFactory* fDatatypeRegistry;
- GrammarResolver* fGrammarResolver;
- SchemaGrammar* fSchemaGrammar;
- EntityResolver* fEntityResolver;
- ErrorHandler* fErrorHandler;
- XMLStringPool* fURIStringPool;
- XMLStringPool* fStringPool;
- XMLBuffer fBuffer;
- XMLValidator* fValidator;
- XMLScanner* fScanner;
- NamespaceScope* fNamespaceScope;
- RefHashTableOf<XMLAttDef>* fAttributeDeclRegistry;
- RefHashTableOf<ComplexTypeInfo>* fComplexTypeRegistry;
- RefHashTableOf<XercesGroupInfo>* fGroupRegistry;
- RefHashTableOf<XercesAttGroupInfo>* fAttGroupRegistry;
- RefHashTableOf<SchemaInfo>* fSchemaInfoList;
- SchemaInfo* fSchemaInfo;
- XercesGroupInfo* fCurrentGroupInfo;
- XercesAttGroupInfo* fCurrentAttGroupInfo;
- ComplexTypeInfo* fCurrentComplexType;
- ValueVectorOf<unsigned int>* fCurrentTypeNameStack;
- ValueVectorOf<unsigned int>* fCurrentGroupStack;
- GeneralAttributeCheck* fAttributeCheck;
- RefHash2KeysTableOf<XMLCh>* fGlobalTypes;
- RefHash2KeysTableOf<XMLCh>* fGlobalAttributes;
- RefHash2KeysTableOf<XMLCh>* fGlobalGroups;
- RefHash2KeysTableOf<XMLCh>* fGlobalAttGroups;
- RefHash2KeysTableOf<XMLCh>* fNotationRegistry;
- RefHash2KeysTableOf<XMLCh>* fRedefineComponents;
- RefHash2KeysTableOf<SchemaElementDecl>* fSubstitutionGroups;
- RefHash2KeysTableOf<ElemVector>* fValidSubstitutionGroups;
- RefHash2KeysTableOf<ElemVector>* fGrammarSubstitutionGroups;
- RefVectorOf<QName>* fRefElements;
- ValueVectorOf<int>* fRefElemScope;
+ bool fFullConstraintChecking;
+ unsigned short fElemAttrDefaultQualified;
+ int fTargetNSURI;
+ int fEmptyNamespaceURI;
+ int fCurrentScope;
+ int fFinalDefault;
+ int fBlockDefault;
+ int fScopeCount;
+ unsigned int fAnonXSTypeCount;
+ const XMLCh* fTargetNSURIString;
+ DatatypeValidatorFactory* fDatatypeRegistry;
+ GrammarResolver* fGrammarResolver;
+ SchemaGrammar* fSchemaGrammar;
+ EntityResolver* fEntityResolver;
+ ErrorHandler* fErrorHandler;
+ XMLStringPool* fURIStringPool;
+ XMLStringPool* fStringPool;
+ XMLBuffer fBuffer;
+ XMLValidator* fValidator;
+ XMLScanner* fScanner;
+ NamespaceScope* fNamespaceScope;
+ RefHashTableOf<XMLAttDef>* fAttributeDeclRegistry;
+ RefHashTableOf<ComplexTypeInfo>* fComplexTypeRegistry;
+ RefHashTableOf<XercesGroupInfo>* fGroupRegistry;
+ RefHashTableOf<XercesAttGroupInfo>* fAttGroupRegistry;
+ RefHashTableOf<SchemaInfo>* fSchemaInfoList;
+ SchemaInfo* fSchemaInfo;
+ XercesGroupInfo* fCurrentGroupInfo;
+ XercesAttGroupInfo* fCurrentAttGroupInfo;
+ ComplexTypeInfo* fCurrentComplexType;
+ ValueVectorOf<unsigned int>* fCurrentTypeNameStack;
+ ValueVectorOf<unsigned int>* fCurrentGroupStack;
+ ValueVectorOf<unsigned int>* fIC_NamespaceDepth;
+ ValueVectorOf<SchemaElementDecl*>* fIC_Elements;
+ GeneralAttributeCheck* fAttributeCheck;
+ RefHash2KeysTableOf<XMLCh>* fGlobalDeclarations;
+ RefHash2KeysTableOf<XMLCh>* fNotationRegistry;
+ RefHash2KeysTableOf<XMLCh>* fRedefineComponents;
+ RefHash2KeysTableOf<IdentityConstraint>* fIdentityConstraintNames;
+ RefHash2KeysTableOf<SchemaElementDecl>* fSubstitutionGroups;
+ RefHash2KeysTableOf<ElemVector>* fValidSubstitutionGroups;
+ RefVectorOf<QName>* fRefElements;
+ ValueVectorOf<int>* fRefElemScope;
+ RefHashTableOf<ValueVectorOf<DOM_Element> >* fIC_NodeListNS;
+ RefHashTableOf<ElemVector>* fIC_ElementsNS;
+ RefHashTableOf<ValueVectorOf<unsigned int> >* fIC_NamespaceDepthNS;
friend class GeneralAttributeCheck;
};
@@ -771,8 +789,14 @@
const XMLCh* TraverseSchema::getElementAttValue(const DOM_Element& elem,
const XMLCh* const attName,
const bool toTrim) {
+
+ DOM_Attr attNode = elem.getAttributeNode(attName);
+
+ if (attNode == 0) {
+ return 0;
+ }
- DOMString attValue = elem.getAttribute(attName);
+ DOMString attValue = attNode.getValue();
if (attValue.length() > 0) {
@@ -788,11 +812,10 @@
}
}
- unsigned int elemId = fStringPool->addOrFind(bufValue);
- return fStringPool->getValueForId(elemId);
+ return fStringPool->getValueForId(fStringPool->addOrFind(bufValue));
}
- return 0;
+ return XMLUni::fgZeroLenString;
}
inline bool TraverseSchema::isBaseFromAnotherSchema(const XMLCh* const baseURI)
1.5 +56 -0 xml-xerces/c/src/validators/schema/XUtil.cpp
Index: XUtil.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/XUtil.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XUtil.cpp 2001/05/11 13:27:39 1.4
+++ XUtil.cpp 2001/11/02 14:13:45 1.5
@@ -56,6 +56,9 @@
/*
* $Log: XUtil.cpp,v $
+ * Revision 1.5 2001/11/02 14:13:45 knoaman
+ * Add support for identity constraints.
+ *
* Revision 1.4 2001/05/11 13:27:39 tng
* Copyright update.
*
@@ -297,6 +300,33 @@
return DOM_Element();
}
+
+// Finds and returns the first child node with the given qualified name.
+DOM_Element XUtil::getFirstChildElementNS(const DOM_Node &parent
+ , const XMLCh** const elemNames
+ , const XMLCh* const uriStr
+ , unsigned int length)
+{
+ // search for node
+ DOM_Node child = parent.getFirstChild();
+ while (child != 0)
+ {
+ if (child.getNodeType() == DOM_Node::ELEMENT_NODE)
+ {
+ for (unsigned int i = 0; i < length; i++)
+ {
+ if (child.getNamespaceURI().equals(uriStr) &&
+ XMLString::compareString(child.getNodeName().rawBuffer(), elemNames[i]) ==0)
+ return (DOM_Element&)child;
+ }
+ }
+ child = child.getNextSibling();
+ }
+
+ // not found
+ return DOM_Element();
+}
+
// Finds and returns the last child element node.
DOM_Element XUtil::getLastChildElement(const DOM_Node &parent) {
@@ -461,6 +491,32 @@
(XMLString::compareString(element.getAttribute(attrName).rawBuffer(), attrValue) ==0))
return element;
}
+ sibling = sibling.getNextSibling();
+ }
+
+ // not found
+ return DOM_Element();
+}
+
+// Finds and returns the next sibling element node with the qualified name.
+DOM_Element XUtil::getNextSiblingElementNS(const DOM_Node &node
+ , const XMLCh** const elemNames
+ , const XMLCh* const uriStr
+ , unsigned int length)
+{
+ // search for node
+ DOM_Node sibling = node.getNextSibling();
+ while (sibling != 0)
+ {
+ if (sibling.getNodeType() == DOM_Node::ELEMENT_NODE)
+ {
+ for (unsigned int i = 0; i < length; i++)
+ {
+ if (sibling.getNamespaceURI().equals(uriStr) &&
+ XMLString::compareString(sibling.getNodeName().rawBuffer(), elemNames[i]) ==0)
+ return (DOM_Element&)sibling;
+ }
+ }
sibling = sibling.getNextSibling();
}
1.3 +15 -0 xml-xerces/c/src/validators/schema/XUtil.hpp
Index: XUtil.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/XUtil.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XUtil.hpp 2001/05/11 13:27:39 1.2
+++ XUtil.hpp 2001/11/02 14:13:45 1.3
@@ -56,6 +56,9 @@
/*
* $Log: XUtil.hpp,v $
+ * Revision 1.3 2001/11/02 14:13:45 knoaman
+ * Add support for identity constraints.
+ *
* Revision 1.2 2001/05/11 13:27:39 tng
* Copyright update.
*
@@ -115,6 +118,12 @@
, const XMLCh* const attrName
, const XMLCh* const attrValue);
+ // Finds and returns the first child node with the given qualifiedname.
+ static DOM_Element getFirstChildElementNS(const DOM_Node &parent
+ , const XMLCh** const elemNames
+ , const XMLCh* const uriStr
+ , unsigned int length);
+
// Finds and returns the last child element node.
static DOM_Element getLastChildElement(const DOM_Node &parent);
// Finds and returns the last child element node with the given name.
@@ -147,6 +156,12 @@
, const XMLCh* const elemName
, const XMLCh* const attrName
, const XMLCh* const attrValue);
+
+ // Finds and returns the next sibling node with the given qualified name.
+ static DOM_Element getNextSiblingElementNS(const DOM_Node &node
+ , const XMLCh** const elemNames
+ , const XMLCh* const uriStr
+ , unsigned int length);
protected:
// -----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org