@Test
public void testXpath() throws Exception {
String xml = "<CONTACT><ID>10</ID></CONTACT>";
String expression = "//CONTACT[ID='1']/ID";
VTDGen p = new VTDGen();
p.setDoc(xml.getBytes("UTF-8"));
p.parse(false);
VTDNav nav = p.getNav();
AutoPilot pilot = new AutoPilot(nav);
pilot.selectXPath(expression);
int evalXPath = pilot.evalXPath();
if (evalXPath != -1) {
String readValue = nav.toNormalizedString(nav.getText());
Assert.assertEquals("10", readValue);
Assert.fail("evalXpath should have returned -1, but returned " + evalXPath);
}
}
When running the unit test above we get java.lang.AssertionError: evalXpath should have returned -1, but returned 2.
Does anyone know why this happens? Is this a known bug?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The following xpath finds a node while it shouldn't. This happens with VTD-xml java 2.12 and 2.13, while v2.11 works fine.
XML: <CONTACT><ID>10</ID></CONTACT>
Xpath: //CONTACT[ID='1']/ID
Result:10
Java unit test:
When running the unit test above we get java.lang.AssertionError: evalXpath should have returned -1, but returned 2.
Does anyone know why this happens? Is this a known bug?
this is a bug that has been idnentified and corrected in 2.13.1... I am embarassed by it and almost committed ritual suicide...