commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John C Bledsoe <johncbled...@yahoo.com>
Subject [JXPath] Collection as Context
Date Fri, 10 Oct 2003 18:35:15 GMT
Hello,

Does JXPath support any kind of Collection as a
Context?  I have had success with a Map but no success
with an ArrayList.

For example,

Given a list of Addresses, find all with a zip code of
90210.

// pseudo code
ArrayList list = new ArrayList();
list.add(new Address("90210"));
list.add(new Address("66213"));
list.add(new Address("90210"));
JXPathContext context =
JXPathContext.newContext(list);
Iterator iter = context.iterate("zipCode='90210'"); 
// returns one element of Boolean.FALSE
// many other XPath expression attempts omitted

I got it to work when the list is a bean property of
another class; e.g. "addresses[zipCode='90210']".

Also, is there any guarantee that a search will return
an ordered iterator if the expression is executed on a
Collection that guarantees order; i.e. LinkedList?

John


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message