You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2008/02/25 14:26:09 UTC
svn commit: r630839 - in /xerces/c/trunk: src/xercesc/validators/schema/
tests/src/XSTSHarness/regression/
tests/src/XSTSHarness/regression/XERCESC-1745/
Author: amassari
Date: Mon Feb 25 05:26:04 2008
New Revision: 630839
URL: http://svn.apache.org/viewvc?rev=630839&view=rev
Log:
Report an error when a grammar or a type is not found (XERCESC-1745)
Added:
xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1745/
xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1745/a.xsd
xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1745/b.xsd
Modified:
xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp
xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet
Modified: xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp?rev=630839&r1=630838&r2=630839&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp Mon Feb 25 05:26:04 2008
@@ -310,7 +310,7 @@
if (rootPrefix == 0 || !*rootPrefix) {
- const XMLCh* xmlnsStr = schemaRoot->getAttribute(XMLUni::fgXMLNSString);
+ const XMLCh* xmlnsStr = schemaRoot->getAttribute(XMLUni::fgXMLNSString);
if (!xmlnsStr || !*xmlnsStr) {
schemaRoot->setAttribute(XMLUni::fgXMLNSString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
@@ -778,7 +778,7 @@
// ------------------------------------------------------------------
// Resolve namespace to a grammar
- // ------------------------------------------------------------------
+ // ------------------------------------------------------------------
Grammar* aGrammar = 0;
if (nameSpace)
@@ -1701,7 +1701,7 @@
aLocator->setValues(fStringPool->getValueForId(fStringPool->addOrFind(fSchemaInfo->getCurrentSchemaURL())),
0, ((XSDElementNSImpl*) elem)->getLineNo(),
((XSDElementNSImpl*) elem)->getColumnNo());
-
+
if (fRedefineComponents && fRedefineComponents->get(SchemaSymbols::fgELT_GROUP, nameIndex))
{
@@ -1772,7 +1772,7 @@
if (nameEmpty && topLevel) {
reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::NoNameGlobalElement,
- SchemaSymbols::fgELT_ATTRIBUTEGROUP);
+ SchemaSymbols::fgELT_ATTRIBUTEGROUP);
return 0;
}
@@ -3106,7 +3106,7 @@
}
DatatypeValidator* newDV = 0;
-
+
if (baseValidator) {
if (!baseValidator->isAtomic()) {
@@ -3322,18 +3322,18 @@
}
}
- else if (baseValidator->getType() == DatatypeValidator::QName) {
- // We need the URI string for the prefix to determine
- // if that matches the value in the instance document.
- // Code was just comparing the string of prefix:localname
- // and if the schema and instance document had different
- // prefixes with the same URI string then we were giving an error.
+ else if (baseValidator->getType() == DatatypeValidator::QName) {
+ // We need the URI string for the prefix to determine
+ // if that matches the value in the instance document.
+ // Code was just comparing the string of prefix:localname
+ // and if the schema and instance document had different
+ // prefixes with the same URI string then we were giving an error.
const XMLCh* localPart = getLocalPart(attValue);
const XMLCh* prefix = getPrefix(attValue);
const XMLCh* uriStr = (prefix && *prefix) ? resolvePrefixToURI(content, prefix) : fTargetNSURIString;
- enums.get()->addElement(XMLString::replicate(attValue, fGrammarPoolMemoryManager));
- enums.get()->addElement(XMLString::replicate(uriStr, fGrammarPoolMemoryManager));
+ enums.get()->addElement(XMLString::replicate(attValue, fGrammarPoolMemoryManager));
+ enums.get()->addElement(XMLString::replicate(uriStr, fGrammarPoolMemoryManager));
}
else {
enums.get()->addElement(XMLString::replicate(attValue, fGrammarPoolMemoryManager));
@@ -4563,7 +4563,7 @@
fBuffer.reset();
XMLSize_t startIndex = 0;
-
+
while (startIndex < xpathLen) {
if(XMLChar1_0::isWhitespace(*(xpathExpr+startIndex)))
{
@@ -4631,7 +4631,7 @@
fAnnotation = generateSyntheticAnnotation(elem, fNonXSAttList);
}
if (fAnnotation)
- {
+ {
if (janAnnot.isDataNull())
janAnnot.reset(fAnnotation);
else
@@ -4647,8 +4647,8 @@
return false;
}
- if (XMLString::startsWith(xpathExpr, fgForwardSlash)
- || XMLString::startsWith(xpathExpr, fgDot)) {
+ if (XMLString::startsWith(xpathExpr, fgForwardSlash)
+ || XMLString::startsWith(xpathExpr, fgDot)) {
fBuffer.set(xpathExpr);
}
else {
@@ -4676,7 +4676,7 @@
reportSchemaError(elem, e);
return false;
}
- }
+ }
elem = XUtil::getNextSiblingElement(elem);
}
@@ -4788,7 +4788,7 @@
if (annot) {
fSchemaGrammar->addAnnotation(annot);
sawAnnotation = true;
- }
+ }
}
else if (XMLString::equals(name, SchemaSymbols::fgELT_SIMPLETYPE)) {
@@ -5081,31 +5081,34 @@
if (baseValidator == 0) {
- SchemaInfo::ListType infoType = SchemaInfo::INCLUDE;
+ SchemaInfo::ListType infoType = SchemaInfo::INCLUDE;
SchemaInfo* saveInfo = fSchemaInfo;
- int saveScope = fCurrentScope;
+ int saveScope = fCurrentScope;
- if (!XMLString::equals(uri, fTargetNSURIString) && (uri && *uri)) {
+ if (!XMLString::equals(uri, fTargetNSURIString) && (uri && *uri)) {
- // Make sure that we have an explicit import statement.
- // Clause 4 of Schema Representation Constraint:
- // http://www.w3.org/TR/xmlschema-1/#src-resolve
- unsigned int uriId = fURIStringPool->addOrFind(uri);
+ // Make sure that we have an explicit import statement.
+ // Clause 4 of Schema Representation Constraint:
+ // http://www.w3.org/TR/xmlschema-1/#src-resolve
+ unsigned int uriId = fURIStringPool->addOrFind(uri);
- if (!fSchemaInfo->isImportingNS(uriId)) {
+ if (!fSchemaInfo->isImportingNS(uriId)) {
- reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::InvalidNSReference, uri);
- return 0;
- }
+ reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::InvalidNSReference, uri);
+ return 0;
+ }
- SchemaInfo* impInfo = fSchemaInfo->getImportInfo(uriId);
+ SchemaInfo* impInfo = fSchemaInfo->getImportInfo(uriId);
- if (!impInfo || impInfo->getProcessed())
- return 0;
+ if (!impInfo || impInfo->getProcessed())
+ {
+ reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::TypeNotFound, uri, localPart);
+ return 0;
+ }
- infoType = SchemaInfo::IMPORT;
- restoreSchemaInfo(impInfo, infoType);
- }
+ infoType = SchemaInfo::IMPORT;
+ restoreSchemaInfo(impInfo, infoType);
+ }
DOMElement* baseTypeNode = fSchemaInfo->getTopLevelComponent(SchemaInfo::C_SimpleType,
SchemaSymbols::fgELT_SIMPLETYPE, localPart, &fSchemaInfo);
@@ -5209,7 +5212,7 @@
XMLCh* token = tokenizer.nextToken();
if (XMLString::equals(token, SchemaSymbols::fgATTVAL_SUBSTITUTION)
- && blockType == ES_Block) {
+ && blockType == ES_Block) {
if ((blockSet & SchemaSymbols::XSD_SUBSTITUTION) == 0 ) {
blockSet += SchemaSymbols::XSD_SUBSTITUTION;
@@ -5347,7 +5350,7 @@
const XMLCh*
TraverseSchema::checkTypeFromAnotherSchema(const DOMElement* const elem,
- const XMLCh* const typeStr) {
+ const XMLCh* const typeStr) {
const XMLCh* prefix = getPrefix(typeStr);
const XMLCh* typeURI = resolvePrefixToURI(elem, prefix);
@@ -5469,7 +5472,10 @@
SchemaInfo* impInfo = fSchemaInfo->getImportInfo(uriId);
if (!impInfo || impInfo->getProcessed())
+ {
+ reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::TypeNotFound, typeURI, localPart);
return 0;
+ }
infoType = SchemaInfo::IMPORT;
restoreSchemaInfo(impInfo, infoType);
@@ -5588,7 +5594,7 @@
unsigned int uriId = fURIStringPool->addOrFind(nameURI);
if (fSchemaInfo->getTargetNSURI() != (int) uriId)
- {
+ {
//if (!XMLString::equals(nameURI, fTargetNSURIString)) {
// Make sure that we have an explicit import statement.
@@ -5623,7 +5629,7 @@
}
infoType = SchemaInfo::IMPORT;
- restoreSchemaInfo(impInfo, infoType);
+ restoreSchemaInfo(impInfo, infoType);
}
}
else
@@ -5889,7 +5895,7 @@
// if Global attribute registry does not contain the ref attribute, get
// the referred attribute declaration and traverse it.
if (!refAttDef) {
-
+
if (fAttributeDeclRegistry->containsKey(localPart) == false) {
DOMElement* referredAttribute = fSchemaInfo->getTopLevelComponent(SchemaInfo::C_Attribute,
@@ -5991,16 +5997,16 @@
attDef->setDefaultType(XMLAttDef::Required);
}
}
- else
- {
- if (fixedVal) {
- attDef->setDefaultType(XMLAttDef::Fixed);
+ else
+ {
+ if (fixedVal) {
+ attDef->setDefaultType(XMLAttDef::Fixed);
valueConstraint = fixedVal;
- }
- else if (defaultVal) {
- attDef->setDefaultType(XMLAttDef::Default);
- }
- }
+ }
+ else if (defaultVal) {
+ attDef->setDefaultType(XMLAttDef::Default);
+ }
+ }
if (valueConstraint) {
@@ -6307,7 +6313,7 @@
// Compose the final content model by concatenating the base and
// the current in sequence
if (!specNode) {
- specNodeWasNull = true;
+ specNodeWasNull = true;
if (isMixed) {
if (baseSpecNode && baseSpecNode->hasAllContent()) {
reportSchemaError(ctElem, XMLUni::fgXMLErrDomain, XMLErrs::NotAllContent);
@@ -6500,7 +6506,7 @@
}
}
else {
-
+
// Make sure that we have an explicit import statement.
// Clause 4 of Schema Representation Constraint:
// http://www.w3.org/TR/xmlschema-1/#src-resolve
@@ -6654,9 +6660,9 @@
return;
}
- ComplexTypeInfo* baseTypeInfo = typeInfo->getBaseComplexTypeInfo();
- if (baseTypeInfo && baseTypeInfo->getPreprocessed())
- throw TraverseSchema::RecursingElement;
+ ComplexTypeInfo* baseTypeInfo = typeInfo->getBaseComplexTypeInfo();
+ if (baseTypeInfo && baseTypeInfo->getPreprocessed())
+ throw TraverseSchema::RecursingElement;
const DOMElement* child = attElem;
SchemaAttDef* attWildCard = 0;
@@ -6738,7 +6744,7 @@
}
attWildCard->setDefaultType(defAttType);
- }
+ }
}
SchemaAttDef* baseAttWildCard = (baseTypeInfo) ? baseTypeInfo->getAttWildCard() : 0;
@@ -6755,7 +6761,7 @@
fGrammarPoolMemoryManager);
janBaseAttWildCard.reset(baseAttWildCard);
}
-
+
if (baseAttWildCard && attWildCard) {
XMLAttDef::DefAttTypes saveDefType = attWildCard->getDefaultType();
@@ -7029,7 +7035,7 @@
if (!validSubsElements) {
- if (fTargetNSURI == chainElemURI) {
+ if (fTargetNSURI == chainElemURI) {
break; // an error must have occured
}
@@ -7043,7 +7049,7 @@
if (!validSubsElements) {
break;
}
-
+
validSubsElements = new (fGrammarPoolMemoryManager) ValueVectorOf<SchemaElementDecl*>(*validSubsElements);
fValidSubstitutionGroups->put((void*) chainElemName, chainElemURI, validSubsElements);
}
@@ -7092,7 +7098,7 @@
if (!validSubs) {
- if (fTargetNSURI == subsElemURI) {
+ if (fTargetNSURI == subsElemURI) {
return; // an error must have occured
}
@@ -7106,7 +7112,7 @@
if (!validSubs) {
return;
}
-
+
validSubs = new (fGrammarPoolMemoryManager) ValueVectorOf<SchemaElementDecl*>(*validSubs);
fValidSubstitutionGroups->put((void*) subsElemName, subsElemURI, validSubs);
}
@@ -7166,7 +7172,7 @@
fBuffer.append(localPart);
unsigned int nameIndex = fStringPool->addOrFind(fBuffer.getRawBuffer());
-
+
if (fCurrentGroupStack->containsElement(nameIndex)) {
reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::NoCircularDefinition, localPart);
@@ -7606,7 +7612,7 @@
if ((typeC == XMLAttDef::Any_Other && typeR == XMLAttDef::Any_List) ||
(typeR == XMLAttDef::Any_Other && typeC == XMLAttDef::Any_List)) {
- unsigned int compareURI = 0;
+ unsigned int compareURI = 0;
ValueVectorOf<unsigned int>* nameURIList = 0;
if (typeC == XMLAttDef::Any_List) {
@@ -7653,7 +7659,7 @@
// If both O1 and O2 are sets, then the intersection of those sets must be
// the value.
if (typeR == XMLAttDef::Any_List && typeC == XMLAttDef::Any_List) {
-
+
ValueVectorOf<unsigned int>* uriListR = resultWildCard->getNamespaceList();
ValueVectorOf<unsigned int>* uriListC = compareWildCard->getNamespaceList();
unsigned int listSize = (uriListC) ? uriListC->size() : 0;
@@ -7690,9 +7696,9 @@
if (qnameR->getURI() != compareWildCard->getAttName()->getURI()) {
if (qnameR->getURI() == (unsigned int)fEmptyNamespaceURI) {
- qnameR->setURI(compareWildCard->getAttName()->getURI());
+ qnameR->setURI(compareWildCard->getAttName()->getURI());
}
- else if (compareWildCard->getAttName()->getURI() != (unsigned int)fEmptyNamespaceURI) {
+ else if (compareWildCard->getAttName()->getURI() != (unsigned int)fEmptyNamespaceURI) {
qnameR->setURI(fEmptyNamespaceURI);
resultWildCard->setType(XMLAttDef::AttTypes_Unknown);
@@ -7787,7 +7793,7 @@
// 2. If the set does not include absent, then a pair of not and
// absent.
if ((typeC == XMLAttDef::Any_Other && typeR == XMLAttDef::Any_List) ||
- (typeR == XMLAttDef::Any_Other && typeC == XMLAttDef::Any_List)) {
+ (typeR == XMLAttDef::Any_Other && typeC == XMLAttDef::Any_List)) {
ValueVectorOf<unsigned int>* nameURIList = 0;
QName* attNameR = resultWildCard->getAttName();
@@ -8032,7 +8038,7 @@
// 2.2 The value must not be identical to the ·namespace test·.
// 2.3 The value must not be ·absent·.
if (wildCardType == XMLAttDef::Any_Other &&
- ((int) nameURI) != fEmptyNamespaceURI &&
+ ((int) nameURI) != fEmptyNamespaceURI &&
wildCard->getAttName()->getURI() != nameURI) {
return true;
}
@@ -8041,7 +8047,7 @@
// members of the set
if (wildCardType == XMLAttDef::Any_List) {
- ValueVectorOf<unsigned int>* nameURIList = wildCard->getNamespaceList();
+ ValueVectorOf<unsigned int>* nameURIList = wildCard->getNamespaceList();
if (nameURIList->containsElement(nameURI)) {
return true;
@@ -8085,7 +8091,7 @@
ValueVectorOf<unsigned int>* childURIList = childAttWildCard->getNamespaceList();
- if (baseWildCardType == XMLAttDef::Any_List) {
+ if (baseWildCardType == XMLAttDef::Any_List) {
ValueVectorOf<unsigned int>* baseURIList = baseAttWildCard->getNamespaceList();
unsigned int childListSize = (childURIList) ? childURIList->size() : 0;
@@ -8538,8 +8544,8 @@
else if (XMLString::equals(name, SchemaSymbols::fgELT_REDEFINE)) { // need to search the redefine decl...
for (DOMElement* redefChild = XUtil::getFirstChildElement(child);
- redefChild != 0;
- redefChild = XUtil::getNextSiblingElement(redefChild)) {
+ redefChild != 0;
+ redefChild = XUtil::getNextSiblingElement(redefChild)) {
const XMLCh* redefName = redefChild->getLocalName();
@@ -8758,7 +8764,7 @@
const XMLCh* nillable = getElementAttValue(elem, SchemaSymbols::fgATT_NILLABLE);
// check constraint value
- valueConstraint = getElementAttValue(elem, SchemaSymbols::fgATT_DEFAULT);
+ valueConstraint = getElementAttValue(elem, SchemaSymbols::fgATT_DEFAULT);
if (fixedVal)
{
elementMiscFlags |= SchemaSymbols::XSD_FIXED;
@@ -8859,7 +8865,7 @@
if (validator->getType() == DatatypeValidator::ID)
reportSchemaError(
elem, XMLUni::fgXMLErrDomain, XMLErrs::ElemIDValueConstraint
- , elemDecl->getBaseName(), valConstraint
+ , elemDecl->getBaseName(), valConstraint
);
try
@@ -9041,9 +9047,9 @@
default:
aBuf.append(nextCh);
break;
- } // end switch
- }
- else
+ } // end switch
+ }
+ else
aBuf.append(nextCh);
nextCh = *++srcVal;
@@ -9199,7 +9205,7 @@
const XMLCh* fullName = fStringPool->getValueForId(fStringPool->addOrFind(fBuffer.getRawBuffer()));
grammar->getComplexTypeRegistry()->put((void*) fullName, complexType);
complexType->setTypeName(fullName);
- complexType->setAttWildCard
+ complexType->setAttWildCard
(
new (memMgr) SchemaAttDef
(
Added: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1745/a.xsd
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1745/a.xsd?rev=630839&view=auto
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1745/a.xsd (added)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1745/a.xsd Mon Feb 25 05:26:04 2008
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:a="a"
+ targetNamespace="a">
+
+ <xs:simpleType name="AA">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="B"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+</xs:schema>
Added: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1745/b.xsd
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1745/b.xsd?rev=630839&view=auto
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1745/b.xsd (added)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1745/b.xsd Mon Feb 25 05:26:04 2008
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:a="a"
+ xmlns:b="b"
+ targetNamespace="b">
+
+ <xs:import namespace="a" schemaLocation="a.xsd"/>
+
+ <!-- If you change a:A to b:A, the error is detected. -->
+ <xs:simpleType name="B">
+ <xs:restriction base="a:A">
+ <xs:enumeration value="B"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <!-- If you change xs:string to b:B you will get the wrong diagnostics.
+ If you change xs:string to a:A you will get the correct diagnostics.
+ -->
+ <xs:element name="root" type="xs:string"/>
+
+</xs:schema>
Modified: xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet?rev=630839&r1=630838&r2=630839&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet (original)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet Mon Feb 25 05:26:04 2008
@@ -365,6 +365,17 @@
<current status="accepted" date="2008-02-13"/>
</schemaTest>
</testGroup>
+ <testGroup name="XERCESC-1745">
+ <annotation>
+ <documentation>Inheritance by restriction does not detect a missing type from an imported schema</documentation>
+ </annotation>
+ <documentationReference xlink:href="https://issues.apache.org/jira/browse/XERCESC-1745"/>
+ <schemaTest name="XERCESC-1745">
+ <schemaDocument xlink:href="./XERCESC-1745/b.xsd"/>
+ <expected validity="invalid"/>
+ <current status="accepted" date="2008-02-25"/>
+ </schemaTest>
+ </testGroup>
<testGroup name="XERCESC-1777">
<annotation>
<documentation>Restriction checking code resolves an element from a wrong schema grammar</documentation>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org