File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes XPathAPI.selectSingleNode going up the document on cached element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "XPathAPI.selectSingleNode going up the document on cached element" Watch "XPathAPI.selectSingleNode going up the document on cached element" New topic
Author

XPathAPI.selectSingleNode going up the document on cached element

jeroen dijkmeijer
Ranch Hand

Joined: Sep 26, 2003
Posts: 131
Hi,
I'm currently doing some XML maninupalation using Java built in tooling.

I have a (non validating) configuration file:

Note that the first element does not have a tail element whereas the second does. In the program I retrieve the template elements by doing:

returning a list with all the elements. The elements are stored in some wrapper objects. Which in turn are stored in a list. Iterating over the list I search in stored elements:

I hope your are still with me: the first template does not contain a tail element, the second does. But the code above, happily retrieves the tail element of the stored element's sibbling, which is not the desired behavior: It should return null.

Line above should give null ERRROR (?)
Is there a way to make this happen? I tried the xerces and the Java 1.5 implementation, both give same results. Is this the documented behavior?
Or should I set a setting on the DocumentBuilderFactory?

Thank you for your time and kind regards,
Jeroen.
[ June 10, 2008: Message edited by: jeroen dijkmeijer ]
jeroen dijkmeijer
Ranch Hand

Joined: Sep 26, 2003
Posts: 131
found it, need to drop the slashes. It's behavior is according the specs.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XPathAPI.selectSingleNode going up the document on cached element