GNOME Bugzilla – Bug 557684
libxslt fails when using "*" for namespace in XPath expression - whereas Saxon handles it correctly
Last modified: 2008-11-03 00:32:45 UTC
Please describe the problem: libxml2/libxsl doesn't seem to accept a star "*" for a namespace in an XPath expression. Saxon ( http://saxon.sourceforge.net/ ) handles it correctly. Knowing that Saxon claims to be an "complete and conformant implementation of the XPath 2.0 recommendation", I would suppose that it's a bug in libxslt. (to be honest, I haven't tried with the latest Saxon however; the one I'm using is 8.51). Steps to reproduce: Running the XPath expression '/*:root/text()' causes an error when ran with '<root xmlns="http://my.domain.org/mynamespace">ok</root>' and with '<root>ok</root>' I'm running from Python and I get: Traceback (most recent call last):
+ Trace 208628
res = ctxt.xpathEval(expr)
if ret is None:raise xpathError('xmlXPathEval() failed')
Saxon returns 'ok' for both expression. Actual results: Expected results: Does this happen every time? Other information:
http://www.w3.org/TR/xpath#NT-NameTest [37] NameTest ::= '*' | NCName ':' '*' | QName can you show me how you can generate *:root from that production ? XPath1 definitely doesn't allows this, maybe XPath2 does, but libxml2 does not implement XPath2 And clearly the intents of the XPath authors was to allow wildards on namespaces, so if this has been added in XPath2 that's a violation of the original authors of XPaths, and if it was not added in XPath2 that's a Saxon bug. In any case it's clearly forbidden in XPath 1.0 so it's not a bug from a libxml2/libxslt perspective. Daniel
Yes, my mistake, this is XPath 2.0 only, see http://www.w3.org/TR/xpath20/#doc-xpath-Wildcard It was so obvious to me that XPath 2.0 was supported, that I didn't check. Coming from the Java world it was kind of expected.