Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XPathAPI.selectSingleNode going up the document on cached element

 
jeroen dijkmeijer
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
found it, need to drop the slashes. It's behavior is according the specs.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic