Union of extension functions returning Collection not properly handled
----------------------------------------------------------------------
Key: JXPATH-147
URL: https://issues.apache.org/jira/browse/JXPATH-147
Project: Commons JXPath
Issue Type: Bug
Affects Versions: 1.3
Reporter: Samuel Solon
Evaluating an xpath expression that is the union of two external functions that
return a Collection doesn't return the full contents of each of the Collections.
Looking through the code I found that UnionContext uses getCurrentNodePointer
in setPosition which will ignores the index value that might have been set on
the EvalContext when the pointer references a collection.
I added "getValuePointer()" (as below) to the expression so the index would be
respected and that seemed to cure the problem as tested by a simple test I
added to ExtensionFunctionTest.java
public void testCollectionUnionReturn() {
String expr = "test:collection()|test:collection()";
List res = context.selectNodes(expr);
assertEquals("size " + expr, 4, res.size());
}
Although all the project tests still pass I admit to not being quite sure that
this is the proper solution but it works for me.
---
commons-jxpath-1.3-src/src/java/org/apache/commons/jxpath/ri/axes/UnionContext.java
2008-07-30 09:31:20.000000000 -0700
+++
../commons-jxpath-1.3-src/src/java/org/apache/commons/jxpath/ri/axes/UnionContext.java
2010-04-13 18:04:48.592423397 -0700
@@ -58,7 +58,7 @@
EvalContext ctx = (EvalContext) contexts[i];
while (ctx.nextSet()) {
while (ctx.nextNode()) {
- NodePointer ptr = ctx.getCurrentNodePointer();
+ NodePointer ptr =
ctx.getCurrentNodePointer().getValuePointer();
if (!pointers.contains(ptr)) {
pointers.add(ptr);
}
@@ -73,4 +73,5 @@
}
return super.setPosition(position);
}
+
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira