You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Dmitri Plotnikov <dp...@yahoo.com> on 2003/04/23 00:20:24 UTC

Re: [jxpath] [Bug 19231] - JXPathContext.iterate(String) returns duplicate children

Mr. Fielding,

Before I start digging into this, let me ask you this question: do the
duplicate beans returned by JXPath correspond to duplicate Pointers? 
JXPath promises to eliminate duplicate Pointers, but does not promise
to return the same bean only once.  If multiple pointers correspond to
the same bean, JXPath will return that bean multiple times.  To
determine if we in fact have a problem, please change the code to call
iteratePointers() instead of iterate() and print the results.  Let's
see if we have duplicates among the printed pointers.

Thank you,

- Dmitri



http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19231

JXPathContext.iterate(String) returns duplicate children

           Summary: JXPathContext.iterate(String) returns duplicate 
children
           Product: Commons
           Version: 1.0 Alpha
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: JXPath
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: jpfield@adelphia.net


i have a bean hierarchy as follows

Collection Listing.getProperties()  // returns collection of Property 
objects
Collection Property.getStructures()  // returns collection of Structure

objects
Collection Structure.getRooms()     // returns collection of Room 
objects
Collection Room.getRooms()          // also returns collection of Room 
objects

the following code:

public void testCreate() throws Exception {
    JXPathContext context = JXPathContext.newContext(this.listing);
    for (Iterator i =
(Iterator)context.iterate("properties/structures/levels//rooms[name='Bathroom']");
i.hasNext();) {
	Room bathroom = (Room) i.next();
	System.out.println(bathroom.getName() +" "+      bathroom.getValue());
    }
}


run against the following pseudo structure:

Listing = (null)
+-Property = (10116 St. Paul's Lane)
+-+-Structure = (Townhouse)
+-+-+-Level = (First Floor)
+-+-+-+-Kitchen = (Kitchen)
+-+-+-+-Room = (Living Room)
+-+-+-+-Bathroom = (Powder Room)
+-+-+-Level = (Second Floor)
+-+-+-+-Bedroom = (Master Bedroom)
+-+-+-+-+-Bathroom = (Master Bath)
+-+-+-+-Bedroom = (Guest Bedroom)
+-+-+-+-+-Bathroom = (Guest Bath)


generates the following output:

Bathroom Powder Room
Bathroom Master Bath
Bathroom Guest Bath
Bathroom Master Bath
Bathroom Guest Bath


the last four should only have been two.  the direct xpath would be
'properties/structures/levels/rooms[name='Bedroom']' 
and 
'properties/structures/levels/rooms/rooms[name='Bedroom']'.

but when i use the 
'properties/structures/levels//rooms[name='Bedroom']' style
query, the rooms/rooms children get listed twice.


__________________________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com

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