commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitri Plotnikov <>
Subject Re: [jxpath] JXPathContext#iterate(String) returns same object multip le times
Date Thu, 05 Jun 2003 14:27:49 GMT

No, you are absolutely right.  JXPath is guaranteed to returned unique
pointers, but not unique objects.  If your graph has multiple paths to
the same object, it may be returned repeatedly. The "//" axis has a
protection built into it against simple loops like a->b->a (you'll need
to use the nigthly build to get that behavior).  Other than that there
is really no cure other than specifying more explicit paths. 

- Dmitri

--- "Wannheden, Knut" <> wrote:
> Hi all,
> I just noted that both the methods JXPathContext#iterate(String) and
> JXPathContext#iteratePointers(String) can return the same object
> multiple
> times if the path (or pointer) to it is different.
> In my object graph I have some two-way associations which can cause
> this
> behaviour and that's of course not desirable.  In this scenario
> iteratePointers("//b") can end up returning something like:
> 	/a[1]/b[1]
> 	/a[1]/b[1]/a/b[1]
> 	/a[1]/b[1]/a/[b[1]/a/b[1]
> 	...
> The two-way associations I have are actually containments comparable
> to
> XML's parent-child relationship between elements.  How can I extend
> JXPath
> to specify what properties in my model are parent relationships?
> But regardless of these parent-child relationships I think it's
> questionable
> whether the same object should ever be returned twice by these
> iterators.
> Because it means that the iteration can turn out to be never-ending. 
> Or
> will it even always be indefinite?  But I've probably missed an
> important
> aspect here :-)
> --
> knut
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).

View raw message