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 2001/05/09 18:36:48 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/validators/schema/identity XPathMatcher.java
neilg 01/05/09 09:36:48
Modified: java/src/org/apache/xerces/validators/schema/identity
XPathMatcher.java
Log:
added support for descendant axis in schema identity constraints.
Revision Changes Path
1.10 +33 -2 xml-xerces/java/src/org/apache/xerces/validators/schema/identity/XPathMatcher.java
Index: XPathMatcher.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/XPathMatcher.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XPathMatcher.java 2001/05/08 19:55:46 1.9
+++ XPathMatcher.java 2001/05/09 16:36:45 1.10
@@ -79,7 +79,7 @@
*
* @author Andy Clark, IBM
*
- * @version $Id: XPathMatcher.java,v 1.9 2001/05/08 19:55:46 neilg Exp $
+ * @version $Id: XPathMatcher.java,v 1.10 2001/05/09 16:36:45 neilg Exp $
*/
public class XPathMatcher {
@@ -327,8 +327,31 @@
fBufferContent = true && fShouldBufferContent;
}
+ // now if the current step is a descendant step, we let the next
+ // step do its thing; if it fails, we reset ourselves
+ // to look at this step for next time we're called.
+ // so first consume all descendants:
+ int descendantStep = fCurrentStep;
+ while(fCurrentStep < steps.length && steps[fCurrentStep].axis.type == XPath.Axis.DESCENDANT) {
+ if (DEBUG_MATCH) {
+ XPath.Step step = steps[fCurrentStep];
+ System.out.println(toString()+" [DESCENDANT] MATCHED!");
+ }
+ fCurrentStep++;
+ }
+ if (fCurrentStep == steps.length) {
+ if (DEBUG_MATCH) {
+ System.out.println(toString()+" XPath DIDN'T MATCH!");
+ }
+ fNoMatchDepth++;
+ if (DEBUG_MATCH) {
+ System.out.println(toString()+" [CHILD] after NO MATCH");
+ }
+ return;
+ }
+
// match child::... step, if haven't consumed any self::node()
- if (fCurrentStep == startStep &&
+ if ((fCurrentStep == startStep || fCurrentStep > descendantStep) &&
steps[fCurrentStep].axis.type == XPath.Axis.CHILD) {
XPath.Step step = steps[fCurrentStep];
XPath.NodeTest nodeTest = step.nodeTest;
@@ -337,6 +360,10 @@
}
if (nodeTest.type == XPath.NodeTest.QNAME) {
if (!nodeTest.name.equals(element)) {
+ if(fCurrentStep > descendantStep) {
+ fCurrentStep = descendantStep;
+ return;
+ }
fNoMatchDepth++;
if (DEBUG_MATCH) {
System.out.println(toString()+" [CHILD] after NO MATCH");
@@ -392,6 +419,10 @@
}
}
if (!fMatched) {
+ if(fCurrentStep > descendantStep) {
+ fCurrentStep = descendantStep;
+ return;
+ }
fNoMatchDepth++;
if (DEBUG_MATCH) {
System.out.println(toString()+" [ATTRIBUTE] after");
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org