GNOME Bugzilla – Bug 54951
XPath node tests handle null namespace wrongly
Last modified: 2009-08-15 18:40:50 UTC
The XPath spec (http://www.w3.org/TR/xpath#node-sets) states that a QNAME with no prefix should not match against the default namespace. But... <parent xmlns="http://whatever"> <child/> </parent> and <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:message><xsl:value-of select="count(//child)"/></xsl:message> </xsl:template> </xsl:stylesheet> Produces '1'. It should produce '0'. Steve
Okay, I knew about it but never decided to fix it :-) Patch is actually in xpath.c in libxml --------------- *** xpath.c 2001/05/21 08:15:31 1.114 --- xpath.c 2001/05/21 13:56:12 *************** xmlXPathNodeCollectAndTest(xmlXPathParse *** 7348,7355 **** case XML_ELEMENT_NODE: if (xmlStrEqual(name, cur->name)) { if (prefix == NULL) { ! if ((cur->ns == NULL) || ! (cur->ns->prefix == NULL)) { #ifdef DEBUG_STEP n++; #endif --- 7348,7354 ---- case XML_ELEMENT_NODE: if (xmlStrEqual(name, cur->name)) { if (prefix == NULL) { ! if (cur->ns == NULL) { #ifdef DEBUG_STEP n++; #endif --------------- thanks for the heads-up ! Daniel
This was released in 2.3.10, I assume this is closed. Daniel