commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Benson (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (JXPATH-147) Union of extension functions returning Collection not properly handled
Date Wed, 08 Jun 2011 14:54:59 GMT

     [ https://issues.apache.org/jira/browse/JXPATH-147?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Matt Benson closed JXPATH-147.
------------------------------

    Resolution: Invalid

As you can see in ExtensionFunctionTest#testCollectionReturn(), the correct xpath by which
to refer to the _elements_ of the {{Collection}} function result is {{test:collection()/name}}
or {{test:collection/@name}}.  Similarly, {{test:collection()/name | test:collection()/name}}
and {{test:collection()/@name | test:collection()/@name}} accomplish the union you require.

Sorry for the delay!

> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message