GNOME Bugzilla – Bug 59946
Namespace empty string broken in XSLT
Last modified: 2009-08-15 18:40:50 UTC
If in my XML I set the current namespace to the empty string: <foo xmlns="http://frob.com/"> <bar xmlns=""/> </foo> Such that bar is "not considered to be in any namespace", then I cannot match that with XPath in my XSLT. i.e.: <xsl:template match="bar"> Bar! </xsl:template> Will never succeed. The only way I can match that element is with *[local-name() = 'bar'].
Hi Matt, (BTW your matt@sergeant.org email was bouncing and I had to suspend sending mail from the xml and xslt@gnome.org list, just reactivate them) Okay, found, the problem is actaully in libxml/SAX.c http://cvs.gnome.org/bonsai/cvsquery.cgi?module=gnome-xml&branch=HEAD&branchtype=match&dir=gnome-xml&file=&filetype=match&who=veillard&whotype=match&sortby=Date&hours=&date=explicit&mindate=09%2F10%2F01+14%3A13&maxdate=09%2F10%2F01+14%3A15&cvsroot=%2Fcvs%2Fgnome ------------------------------ diff -c -r1.75 SAX.c *** SAX.c 2001/09/10 14:40:42 1.75 --- SAX.c 2001/09/10 18:02:57 *************** *** 1134,1140 **** ctxt->sax->warning(ctxt->userData, "Namespace prefix %s is not defined\n", prefix); } ! xmlSetNs(ret, ns); /* * process all the other attributes --- 1134,1146 ---- ctxt->sax->warning(ctxt->userData, "Namespace prefix %s is not defined\n", prefix); } ! ! /* ! * set the namespace node, making sure that if the default namspace ! * is unbound on a parent we simply kee it NULL ! */ ! if ((ns != NULL) && (ns->href[0] != 0)) ! xmlSetNs(ret, ns); /* * process all the other attributes ------------------------------ this seems to cure it: orchis:~/XSLT/tests/tmp -> cat foo.xml <foo xmlns="http://frob.com/"> <bar xmlns=""/> </foo> orchis:~/XSLT/tests/tmp -> cat bar.xsl <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="bar"> Bar! </xsl:template> </xsl:stylesheet> orchis:~/XSLT/tests/tmp -> xsltproc bar.xsl foo.xml <?xml version="1.0"?> Bar! orchis:~/XSLT/tests/tmp -> thanks for the report ! Daniel
This should be closed by release 1.0.4, thanks, Daniel