commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitri Plotnikov" <dmi...@apache.org>
Subject Re: [JXPath] Collection as Context
Date Mon, 13 Oct 2003 00:21:53 GMT
John,

Have  you tried "/.[zipCode='90210']"?  I don't remember exactly, but this
might work.

The iterator returns items in the so called "document order", which for all
intents and purposes it the natural order in which the graph is traversed.

- Dmitri

----- Original Message ----- 
From: "John C Bledsoe" <johncbledsoe@yahoo.com>
To: <commons-user@jakarta.apache.org>
Sent: Friday, October 10, 2003 2:35 PM
Subject: [JXPath] Collection as Context


> 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
>
>
>
>


---------------------------------------------------------------------
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