Search code examples
javaxmlxpathvtd-xml

Prior knowledge on attributes?


I am currently looking to integrate VTD-XML in to our project (as a replacement of a Stax based system).

Our xml files are mostly structured like this:

<header>
  <entry1 timestamp="0"/>
  <entry2 timestamp="1"/>
  <entry1 timestamp="2"/>
  <entry2 timestamp="3"/>
</header>

Is there a way to get VTD-XML to recognize that the timestamps are strictly ordered and to abort a xpath query like /header/*[@timestamp < 2] early?


Solution

  • not that i'm aware of. But you could select the last node:

    /header/*[@timestamp = 2]
    

    and then use selectPrecedingNode()