Menu

#6 Java AutoPilot default namespace searches return additional incorrect nodes

2.0
closed
None
2017-09-13
2016-06-13
No

I recently tried upgrade from 2.11 to 2.13 (I previous tried to upgrade to 2.12, but other issues caused me to revert back to 2.11) and found that I was getting failing unit tests.

On further inspection I tracked it down to the the AutoPilot class, when a default namespaced xpath search is performed it seems to take the lack of a namespace to be a wildcard for any namespace rather than just for the current default namespace.

I checked the expected outputs against http://www.freeformatter.com/xpath-tester.html with the xml:

<a xmlns:x="urn:test">
  <b id="1"/>
  <x:b id="2"/>
  <b id="3"/>
</a>

and the path "//b" which results in the expected two elements as I expected - for both version 2.12 and 2.13 of the AutoPilot class we get all three child elements of a.

I have created a JUnit test that shows the issue and uploaded as a Gist:

VtdAutoPilotXpathIssueTest.java (gist.github.com)

Discussion

  • jimmy zhang

    jimmy zhang - 2016-06-13

    vtd-xml 2.12 onward has a change in the behavior of matchElement() for VTDNav. based on user input/suggestion... the suggestion is to make the navigation behavior consistent with DOM when namespace awareness is turned off...

    I will come up with a fix as ap for you ...

     
  • jimmy zhang

    jimmy zhang - 2016-06-14
    • status: open --> pending
    • assigned_to: jimmy zhang
     
  • Philip Pearson

    Philip Pearson - 2016-06-14

    Thanks, that seems to fix the issue for me.

    Looking at the code I am not sure whether matchElement_IgnoreCase also needs a similar fix as it does not check ns and calls matchRawTokenString2_IgnoreCase only.

     
  • jimmy zhang

    jimmy zhang - 2016-06-14

    good point, will look into that... in the meaning time, 2.13 is a big step forward from 2.11 in every way... just you know

     
  • jimmy zhang

    jimmy zhang - 2017-09-13
    • status: pending --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB