You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Krishna Patil <kr...@ihc.com> on 2005/01/25 22:08:33 UTC

A bug in JXPathContext::iteratePointers() ?

I have noticed that the result of JXPathContext::selectNodes() and
JXPathContext::iteratePointers differ in numbers for a given path. Is
this a bug in JXPathContext::iteratePointers() method?

Here is an example:

Class A{
       private List list;
      //getter and setter
      :
}

--------
Here is a code snippet for creating an object graph that starts from
instance of A.

A a1 = new A();
List list1 = new LinkedList();

A a11 = new A();
list1.add(a11);

A a12 = new A();
List list12 = new LinkedList();
A a121 = new A();
list12.add(a121);
a12.setList(list12);
list1.add(a12);

A a13 = new A();
list1.add(a11);

a1.setList(list1);

And the list attribute can have instances of A as elements in it.

When I use "//list" with selectNodes() it returns me all the list
element nodes in the entire object graph.
However, when I use the same expression i.e "//list" with
JXPathContext::iteratePointers(), it returns only those nodes that last
leaves in their corresponding branches.
So, in the above example, selectNodes() returns the following objects.

A[1]
A[2]
A[2]/A[1]
A[3]

whreas iteratePointers() returns the pointers for the following
objects.

A[2]/A[1]
A[3]

I was hoping to get same number pointers as the number of nodes
returned by selectNodes() in the above example.
Is it a bug? Please let me know.

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