Bugs item #770410, was opened at 2003-07-13 07:05
Message generated for change (Comment added) made by maartenc
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=770410&group_id=16035
Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Rob Grzywinski (rgrzywinski)
>Assigned to: Maarten Coene (maartenc)
Summary: Odd Node.detach() behavior
Initial Comment:
<a>
<b>
<c>1</c>
</b>
<b>
<c>2</c>
</b>
</a>
List b = document.selectNodes("/a/b");
for(Node node : b)
{
node.detach();
System.out.println("B's path: " + node.getPath());
System.out.println("C: " + node.selectSingleNode
("/b/c"));
}
This will output:
B's path: /b
C: null
B's path: /b
C: null
rather than the expected:
B's path: /b
C: 1
B's path: /b
C: 2
(I'm just using the 1.5 loop syntax for clarity.)
I apologize in advance if this is a brain fart on my behalf.
----------------------------------------------------------------------
>Comment By: Maarten Coene (maartenc)
Date: 2004-06-17 20:56
Message:
Logged In: YES
user_id=178745
the XPath expression you give to the node to select the
content of the C element is not correct and the null as
output is correct. Since you provide an absolute path to the
node which doesn't belong to a document anymore, it should
return null.
However, your code illustrates another bug in dom4j: the
getPath() method on the detached node should not return an
absolute path in this situation, it should return a relative
path selecting itself: "." should be returned instead of
"/b". This is fixed now in CVS.
Thanks
Maarten
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=770410&group_id=16035
-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev