--- Warren Liang <[EMAIL PROTECTED]> wrote: > Hi all, > > How does JXPath handle circular object paths? My > object graph is can > have circular references to objects that are the > same instance (i.e. > obj1 == obj2), or are different instances but have > equivalent values > (i.e. obj1.equals(obj2)) > > Right now, I'm evaluating JXPath expressions that do > not match > anything in the object graph and it seems like it's > going through an > infinite loop. Some of my expressions use the > "match anywhere" > operator (i.e. //).
If you are encountering behavior that feels wrong to you, feel welcome to open an issue in JIRA, preferably with some sample code that can easily be turned into a standalone JUnit test. > > Does JXPath use a breadth first search or a depth > first search through > the object graph? > In my experience, not being the original author of the code, JXPath determines matching nodes for a given level, then applies subsequent levels in recursive-descent fashion to each node selected at the current level. So given: <a> <b> <c /><c /> </b> <b> <c /><c /> </b> <b> <c /><c /> </b> </a> and path "/a/b/c", JXPath will determine that a[1] matches the first step and apply the next step. Now it determines that a[1]/b[1], a[1]/b[2] and a[1]/b[3] match the second step. Then it applies the third step to a[1]/b[1], a[1]/b[2], and a[1]/b[3] in succession. I interpret this as being depth first. > Ideally, I'd be able to tell JXPath to recurse a > maximum depth, or to > recognize that a node has already been traversed > Are there hooks for > me to do this? > I suppose nothing would ever stop you from implementing a custom "I haven't seen this before" function to guard each step, but it might get a little heavy at RT depending on the size of your graph. Off the top of my head I can't remember what, if any, safeguards are built into JXPath to prevent infinite recursion, hence my initial suggestion (and attempt to put the onus onto you ;) ) that you submit reports for problems encountered. Is any of this helpful whatsoever? -Matt > Thanks, > > Warren Liang > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]