You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Markus Schlegel (Jira)" <ji...@apache.org> on 2023/01/10 14:34:00 UTC

[jira] [Commented] (JXPATH-189) UnionContext cannot be a paramter of XPath extension function

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

Markus Schlegel commented on JXPATH-189:
----------------------------------------

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)