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/12/03 22:18:32 UTC
cvs commit: xml-xerces/c/src/validators/schema TraverseSchema.cpp
knoaman 01/12/03 13:18:32
Modified: c/src/validators/schema TraverseSchema.cpp
Log:
Re-implementation of checkRecurse and checkRecurseUnordered.
Revision Changes Path
1.68 +36 -15 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.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- TraverseSchema.cpp 2001/11/28 19:40:30 1.67
+++ TraverseSchema.cpp 2001/12/03 21:18:32 1.68
@@ -55,7 +55,7 @@
*/
/*
- * $Id: TraverseSchema.cpp,v 1.67 2001/11/28 19:40:30 knoaman Exp $
+ * $Id: TraverseSchema.cpp,v 1.68 2001/12/03 21:18:32 knoaman Exp $
*/
// ---------------------------------------------------------------------------
@@ -8148,47 +8148,56 @@
}
// check for mapping of children
+ XMLExcepts::Codes codeToThrow = XMLExcepts::NoError;
unsigned int count1= derivedNodes->size();
unsigned int count2= baseNodes->size();
unsigned int current = 0;
for (unsigned int i=0; i<count1; i++) {
- ContentSpecNode* derivedNode = derivedNodes->elementAt(i);
bool matched = false;
- for (unsigned int j = current; j<count2 && !matched; j++) {
+ for (unsigned int j = current; j < count2; j++) {
ContentSpecNode* baseNode = baseNodes->elementAt(j);
current++;
try {
- checkParticleDerivationOk(derivedNode, derivedScope, baseNode, baseScope, baseInfo);
+ checkParticleDerivationOk(derivedNodes->elementAt(i), derivedScope, baseNode, baseScope, baseInfo);
matched = true;
+ break;
}
catch(const XMLException&) {
if (!toLax && !emptiableParticle(baseNode)) {
- ThrowXML(RuntimeException, XMLExcepts::PD_Recurse2);
+ break;
}
}
}
// did not find a match
if (!matched) {
- ThrowXML(RuntimeException, XMLExcepts::PD_Recurse2);
+
+ codeToThrow = XMLExcepts::PD_Recurse2;
+ break;
}
}
// Now, see if there are some elements in the base we didn't match up
// in case of Sequence or All
- if (!toLax) {
+ if (!toLax && codeToThrow == XMLExcepts::NoError) {
for (unsigned int j = current; j < count2; j++) {
if (!emptiableParticle(baseNodes->elementAt(j))) {
- ThrowXML(RuntimeException, XMLExcepts::PD_Recurse2);
+
+ codeToThrow = XMLExcepts::PD_Recurse2;
+ break;
}
}
}
+
+ if (codeToThrow != XMLExcepts::NoError) {
+ ThrowXML(RuntimeException, codeToThrow);
+ }
}
void TraverseSchema::checkNSSubset(const ContentSpecNode* const derivedSpecNode,
@@ -8280,6 +8289,7 @@
ThrowXML(RuntimeException, XMLExcepts::PD_Recurse1);
}
+ XMLExcepts::Codes codeToThrow = XMLExcepts::NoError;
unsigned int derivedCount= derivedNodes->size();
unsigned int baseCount = baseNodes->size();
bool* foundIt = new bool[baseCount];
@@ -8295,18 +8305,19 @@
ContentSpecNode* derivedNode = derivedNodes->elementAt(i);
bool matched = false;
- for (unsigned int j = 0; j < baseCount && !matched; j++) {
+ for (unsigned int j = 0; j < baseCount; j++) {
try {
checkParticleDerivationOk(derivedNode, derivedScope, baseNodes->elementAt(j), baseScope, baseInfo);
if (foundIt[j]) {
- ThrowXML(RuntimeException, XMLExcepts::PD_RecurseUnordered);
+ break;
}
foundIt[j] = true;
matched = true;
+ break;
}
catch (const XMLException&) {
}
@@ -8314,15 +8325,25 @@
// didn't find a match.
if (!matched) {
- ThrowXML(RuntimeException, XMLExcepts::PD_RecurseUnordered);
+
+ codeToThrow = XMLExcepts::PD_RecurseUnordered;
+ break;
}
}
// For all unmapped particles in base, check to see it it's emptiable or not
- for (unsigned int j=0; j < baseCount; j++) {
- if (!foundIt[j] && !emptiableParticle(baseNodes->elementAt(j))) {
- ThrowXML(RuntimeException, XMLExcepts::PD_RecurseUnordered);
- }
+ if (codeToThrow == XMLExcepts::NoError) {
+ for (unsigned int j=0; j < baseCount; j++) {
+ if (!foundIt[j] && !emptiableParticle(baseNodes->elementAt(j))) {
+
+ codeToThrow = XMLExcepts::PD_RecurseUnordered;
+ break;
+ }
+ }
+ }
+
+ if (codeToThrow != XMLExcepts::NoError) {
+ ThrowXML(RuntimeException, codeToThrow);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org