GNOME Bugzilla – Bug 53689
processing-instruction() in apply-templates
Last modified: 2009-08-15 18:40:50 UTC
There seems to be a problem with function processing-instruction() in the "select" attribute of xsl:apply-templates element. This function works fine with the "match" attribute in xsl:template element. *** Stylesheet: [rchaillat@pc-1229 modules]$ cat pi-match.xsl <?xml version= "1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match = "/" > <xsl:apply-templates select="//processing-instruction()"/> <xsl:apply-templates select="//comment()"/> <!-- xsl:apply-templates/--> </xsl:template> <xsl:template match = "processing-instruction()" > <xsl:value-of select = "concat(name(),' : ',.)" /> </xsl:template> <xsl:template match = "comment()" > <xsl:text>######################### </xsl:text> <xsl:value-of select = "." /> <xsl:text> #########################</xsl:text> </xsl:template> </xsl:stylesheet> *** Xml file: [rchaillat@pc-1229 modules]$ cat pi-test.xml <?xml version= "1.0"?> <a> <!-- Commentaire --> <?php lines of code ?> </a> *** Result : [rchaillat@pc-1229 modules]$ xsltproc pi-match.xsl pi-test.xml Error xpath.c:5305: Start of litteral //processing-instruction() ^ Error xpath.c:7457: Invalid expression //processing-instruction() ^ <?xml version="1.0"?> ######################### Commentaire ######################### *** If you use apply-templates without the "select", we can see that the matching of PI works: --- <?xml version= "1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match = "/" > <xsl:apply-templates/> </xsl:template> <xsl:template match = "processing-instruction()" > <xsl:value-of select = "concat(name(),' : ',.)" /> </xsl:template> </xsl:stylesheet> --- <?xml version="1.0"?> php : lines of code --- This might be related to libxml since it's an xpath error, but I attribute it to libxslt since it appears only in this apply-template "select" context. Regards, Renaud
right, bug was in xpath.c , I commited the fix in CVS: orchis:~/XSLT/tests/general -> xsltproc bug-14-.xsl ../docs/bug-14-.xml <?xml version="1.0"?> php : lines of code ######################### Commentaire ######################### orchis:~/XSLT/tests/general -> I will send the diff, Daniel
shipped in 0.9.0 Daniel