[ 
https://issues.apache.org/jira/browse/JXPATH-189?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17656653#comment-17656653
 ] 

Markus Schlegel edited comment on JXPATH-189 at 1/10/23 2:35 PM:
-----------------------------------------------------------------

Came across this another time today. Had the awkward behavior, that the 
expression including our function "q:sorted()" did not work as the reporter 
already described in this issue.
Our case:
{code:java}
q:sorted('a' |'b') {code}
Surprisingly, it started to work as soon as I had a breakpoint in the function 
org.apache.commons.jxpath.ri.axes.NodeSetContext.getNodeSet() !

With the debugger, I found out, that the Class UnionContext is only usable 
within context which iterate over the result before accessing values, but is 
NOT when accessing the NodeSet values. But that's exactly what is being done 
for an ExtensionFunction, see 
org.apache.commons.jxpath.ri.compiler.ExtensionFunction.convert() .

A possible solution is, that UnionContext also prepares it's internal nodeSet 
when accessed by getNodeSet(). That would be the least-invasive change. 


was (Author: schlm3):
Came across this another time today. Had the awkward behavior, that the 
expression including our function "q:sorted()" did not work as the reporter 
already described in this issue.

Surprisingly, it started to work as soon as I had a breakpoint in the function 
org.apache.commons.jxpath.ri.axes.NodeSetContext.getNodeSet() !

With the debugger, I found out, that the Class UnionContext is only usable 
within context which iterate over the result before accessing values, but is 
NOT when accessing the NodeSet values. But that's exactly what is being done 
for an ExtensionFunction, see 
org.apache.commons.jxpath.ri.compiler.ExtensionFunction.convert() .

A possible solution is, that UnionContext also prepares it's internal nodeSet 
when accessed by getNodeSet(). That would be the least-invasive change. 

> UnionContext cannot be a paramter of XPath extension function
> -------------------------------------------------------------
>
>                 Key: JXPATH-189
>                 URL: https://issues.apache.org/jira/browse/JXPATH-189
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.3
>            Reporter: Magle
>            Priority: Minor
>   Original Estimate: 5h
>  Remaining Estimate: 5h
>
> When getNodeSet() of a UnionContext object is invoked, it's possible that the 
> "nodeSet" doesn't be prepared from "contexts", a empty nodeSet will be 
> returned.
> for example, an extension function test:count(nodeSet) to get the total count 
> of the nodeSet. it doesn't work for UnionContext, test:count('abc'|'ed'), the 
> result will be 0.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to