0

With the help of VTD-XML, I want to find all attributes belonging to a namespace knowing only its uri.

Here is my code:

VTDGen vg = new VTDGen();
vg.setDoc("<root xmlns=\"urn:foo\" xmlns:nsBar=\"urn:nsBar\" nsBar:Baz=\"value\"/>".getBytes());
vg.parse(true);

VTDNav n = vg.getNav();
    
AutoPilot autoPilot = new AutoPilot(n);
autoPilot.selectXPath("//@*[namespace-uri()='urn:nsBar']");
//autoPilot.selectXPath("//@*[namespace-uri()='urn:foo']");
    
int r;
while( (r= autoPilot.evalXPath()) != -1) {
     System.out.println("°°° " + n.toString(r));
}

The below code outputs nothing. If you uncomment the commented line and comment the previous one, you get this:

°°° nsBar:Baz

However nsBar:Baz belongs to the nsBar namespace. The uri of this namespace is urn:nsBar. What's wrong with vtd-xml here ?

Stephan
  • 41,764
  • 65
  • 238
  • 329
  • 1
    Related issue ? https://stackoverflow.com/questions/10543680/vtd-xml-exception-name-space-qualification-exception-prefixed-attribute-not-qu/10543852 `[...] the order of the attributes/ns declarations affects VTD when parsing.` But this bug should have been fixed now. What happens if you declare `xmlns:nsBar=\"urn:nsBar\"` in first position in the `vg.setDoc` step ? Maybe you should test with a sample XML where `xmlns=\"urn:foo\"`doesn't exist. Ultimately ask directly to the developer jzhang@ximpleware.com or post on https://sourceforge.net/p/vtd-xml/bugs/ – E.Wiest Jun 22 '20 at 03:16
  • With a sample XML where xmlns=\"urn:foo\"doesn't exist, the problem is still there. The project seems dormant. On the first of January 2020, jzhang was notified for the change on a bug published back in 2017. As of this writing, there's still no reply. Thanks for your help @E.Wiest. – Stephan Jun 22 '20 at 06:05

0 Answers0