dmitri 2003/06/25 19:18:47
Modified: jxpath/src/test/org/apache/commons/jxpath/ri/model
XMLModelTestCase.java
jxpath/src/java/org/apache/commons/jxpath/ri
EvalContext.java
jxpath/src/java/org/apache/commons/jxpath/ri/axes
DescendantContext.java
Log:
Fixed document order problem for the descendant-or-self axis
Revision Changes Path
1.11 +14 -4
jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java
Index: XMLModelTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XMLModelTestCase.java 11 Mar 2003 00:59:38 -0000 1.10
+++ XMLModelTestCase.java 26 Jun 2003 02:18:46 -0000 1.11
@@ -62,6 +62,8 @@
package org.apache.commons.jxpath.ri.model;
+import java.util.Iterator;
+
import org.apache.commons.jxpath.AbstractFactory;
import org.apache.commons.jxpath.IdentityManager;
import org.apache.commons.jxpath.JXPathContext;
@@ -168,6 +170,7 @@
"vendor/location",
1);
}
+
public void testSetValue() {
assertXPathSetValue(
@@ -399,6 +402,13 @@
"vendor//promotion[../@stores = 'all']",
list(""));
}
+
+// public void testAxisDescendantDocumentOrder() {
+// Iterator iter = context.iteratePointers("//*");
+// while (iter.hasNext()) {
+// System.err.println(iter.next());
+// }
+// }
public void testAxisParent() {
// parent::
1.25 +22 -7
jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/EvalContext.java
Index: EvalContext.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/EvalContext.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- EvalContext.java 25 Mar 2003 02:41:33 -0000 1.24
+++ EvalContext.java 26 Jun 2003 02:18:46 -0000 1.25
@@ -75,6 +75,9 @@
import org.apache.commons.jxpath.JXPathException;
import org.apache.commons.jxpath.NodeSet;
import org.apache.commons.jxpath.Pointer;
+import org.apache.commons.jxpath.ri.axes.*;
+import org.apache.commons.jxpath.ri.axes.AncestorContext;
+import org.apache.commons.jxpath.ri.axes.DescendantContext;
import org.apache.commons.jxpath.ri.axes.RootContext;
import org.apache.commons.jxpath.ri.model.NodePointer;
@@ -128,12 +131,24 @@
* 0 - does not require ordering
*/
public int getDocumentOrder() {
- // Default behavior: if the parent needs to be ordered,
- // this one needs to be ordered too
- if (parentContext != null && parentContext.getDocumentOrder() != 0) {
+ if (parentContext != null && parentContext.isChildOrderingRequired()) {
return 1;
}
return 0;
+ }
+
+ /**
+ * Even if this context has the natural ordering and therefore does
+ * not require collecting and sorting all nodes prior to returning them,
+ * such operation may be required for any child context.
+ */
+ public boolean isChildOrderingRequired() {
+ // Default behavior: if this context needs to be ordered,
+ // the children need to be ordered too
+ if (getDocumentOrder() != 0) {
+ return true;
+ }
+ return false;
}
/**
1.14 +8 -4
jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/DescendantContext.java
Index: DescendantContext.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/DescendantContext.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- DescendantContext.java 4 May 2003 23:53:19 -0000 1.13
+++ DescendantContext.java 26 Jun 2003 02:18:47 -0000 1.14
@@ -97,6 +97,10 @@
this.nodeTest = nodeTest;
}
+ public boolean isChildOrderingRequired() {
+ return true;
+ }
+
public NodePointer getCurrentNodePointer() {
if (position == 0) {
if (!setPosition(1)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]