There seems to be a bug with ExtensionFunctions and collections as
parameters.

Example:

List list = new ArrayList();
list.add("foo");
list.add("bar");
context.getVariables().declareVariable("myList", list); Collection
values = context.getValue("test:getItems($myList)");

* Values returns: [bar, bar] not [foo, bar]

Extension Function:

    public static Collection getItems(Collection items) {
        return items;
    }


It seems that the iterator building the collection is always returning
the last element. Since the existing unit test
(ExtensionFunctionTest.testCollectionMethodCall) is only testing the
size, the test passes. I added a test to check the actual values passed
to the extension function.

Diff of ExtensionFunctionTest.java
270a271,282
>     public void testCollectionMethodCall2() {
>         List list = new ArrayList();
>         list.add("foo");
>         list.add("bar");
>         context.getVariables().declareVariable("myList", list);
> 
>         assertXPathValue(
>             context,
>             "test:getItems($myList)",
>             list);
>     }
> 

Diff of TestFunctions.java
168c168,172
<     
---
> 
>     public static Collection getItems(Collection items) {
>         return items;
>     }
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to