commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam J Chesney" <>
Subject [JXPath] Problem adding objects to an ArrayList Variable
Date Thu, 06 Feb 2003 11:52:23 GMT

Attached is a small test program that simply defines a Context like this:

 Object o = new Object ();
 JXPathContext context = JXPathContext.newContext( o );
 context.getVariables().declareVariable("myList", new ArrayList() );

 FunctionLibrary library = new FunctionLibrary ();
 library.addFunctions( new ClassFunctions ( List.class, "list" ) );
 context.setFunctions( library );

The output from executing several XPath expressions on it is thus:

getValue("list:size($myList)") returns: 0

getValue("list:add($myList, 'hello')") returns: true

getValue("list:size($myList)") returns: 0

getValue("$myList") returns: []

I would expect the String 'hello' to be added to the list, and therefore the second call to
size should return 1.

Am I doing something wrong here?



Tel:   (+44) 117 908 1254 (Direct)
Mobile (+44) 7780 962 961
This communication is intended solely for the addressee and is confidential.
If you are not the intended recipient, any disclosure, copying, distribution
or any action taken or omitted to be taken in reliance on it, is prohibited
and may be unlawful.
Although this e-mail and any attachments are believed to be free of any
virus, or any other defect which might affect any computer or IT system into
which they are received and opened, it is the responsibility of the
recipient to ensure that they are virus free and no responsibility is
accepted by Multicom Products Limited for any loss or damage arising in any
way from receipt or use thereof.

View raw message