GNOME Bugzilla – Bug 57644
XPath processing and default namespaces
Last modified: 2009-08-15 18:40:50 UTC
textXPath produces weird result if a default namespace is specified in a given xml document. Example: Contents of test.xml is: <foo xmlns="http://bar/"/> Results of testXPath from libxml2 2.3.14 and 2.4.0: [goevert@charlie] ./testXPath -i ~/tmp/test.xml /foo Object is a Node Set : Set contains 0 nodes: I would have expected what I do get with libxml2 2.3.9: [goevert@charlie] ./testXPath -i ~/tmp/test.xml /foo Object is a Node Set : Set contains 1 nodes: 1 ELEMENT foo default namespace href=http://bar/ If test.xml contains only <foo/> I get correct results with all versions: [goevert@charlie] ./testXPath -i ~/tmp/test.xml /foo Object is a Node Set : Set contains 1 nodes: 1 ELEMENT foo
This is not a bug, it was a bug in previous release and had been fixed: http://www.w3.org/TR/xpath#node-tests ------------------------------- A node test that is a QName is true if and only if the type of the node (see [5 Data Model]) is the principal node type and has an expanded-name equal to the expanded-name specified by the QName. -------------------------------- in the document, the expanded name of the foo element is (http://bar/ , foo) in you XPath query, the expanded name is (null , foo) they don't match ! You need to provide a namespace prefix in the XPath query and have it defined in the XPath context. Daniel
I think we can close this bug now, Daniel