You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Elliotte Harold <el...@metalab.unc.edu> on 2005/05/04 15:05:00 UTC

JXPath cycles

How does Commons JXPath handle cycles when querying JavaBeans? For 
instance suppose bean A has a property X whose value is a reference to 
bean B. Suppose also bean B has a property Y whose value is a reference 
to bean A. Then suppose, starting with bean A as the context node, we 
make the query .//*. What happens and why? Is it an infinite loop?

This is a simple case, but clearly the cycle could be longer than length 2.

-- 
Elliotte Rusty Harold  elharo@metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim

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


Re: JXPath cycles

Posted by Dmitri Plotnikov <dm...@apache.org>.
Elliotte,

While traversing the graph of model objects, JXPath maintains a trace of 
nodes it's visited.  If it encouters a node that has already been visited, 
it simply skips it.  That's how it avoids the infinite loop in a situation 
like the one you are describing.

I hope this helps,

- Dmitri

----- Original Message ----- 
From: "Elliotte Harold" <el...@metalab.unc.edu>
To: <co...@jakarta.apache.org>
Sent: Wednesday, May 04, 2005 9:05 AM
Subject: JXPath cycles


> How does Commons JXPath handle cycles when querying JavaBeans? For 
> instance suppose bean A has a property X whose value is a reference to 
> bean B. Suppose also bean B has a property Y whose value is a reference to 
> bean A. Then suppose, starting with bean A as the context node, we make 
> the query .//*. What happens and why? Is it an infinite loop?
>
> This is a simple case, but clearly the cycle could be longer than length 
> 2.
>
> -- 
> Elliotte Rusty Harold  elharo@metalab.unc.edu
> XML in a Nutshell 3rd Edition Just Published!
> http://www.cafeconleche.org/books/xian3/
> http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>
> 



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