GNOME Bugzilla – Bug 71181
pattern "p/text()" selects nothing
Last modified: 2009-08-15 18:40:50 UTC
I have encountered a problem with the following template: <xsl:template match="p/text()"> ... </xsl:template> which should match all text() children of a p element, but matches nothing. Given the following transformation, which reports all such nodes and their parent element: <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="p/text()"> <xsl:value-of select="concat('text in ', name(..), ' = "')"/> <xsl:value-of select="normalize-space(.)"/> <xsl:text>"
</xsl:text> </xsl:template> <xsl:template match="text()"/> </xsl:stylesheet> Applied to the following xhtml fragment: <body> <p>The first paragraph.</p> <p>The <em>second</em> paragraph.</p> </body> The result should be: text in p = "The first paragraph." text in p = "The" text in p = "paragraph." but there is no output at all, as the text children are not recognized. However, modifying the pattern to give the descendant text nodes of a p element instead of just the children: <xsl:template match="p//text()"> libxslt gives the correct output, namely: text in p = "The first paragraph." text in p = "The" text in em = "second" text in p = "paragraph." So there is no doubt that three of these text nodes are children of a p element... I tried saxon and xalan, which gave the correct ouput in both cases. I used libxslt 1.0.11 and libxml 2.4.14, both updated today from CVS, which gave the reported results (I encountered the bug with an earlier version of libxslt and upgraded to check whether it had been fixed in the meantime.) Julien
Hum, nice buglet, fixed now in CVS http://cvs.gnome.org/bonsai/cvsquery.cgi?module=libxslt&branch=HEAD&branchtype=match&dir=libxslt&file=&filetype=match&who=veillard&whotype=match&sortby=Date&hours=&date=explicit&mindate=02%2F11%2F02+10%3A22&maxdate=02%2F11%2F02+10%3A24&cvsroot=%2Fcvs%2Fgnome orchis:~/XSLT/libxslt -> xsltproc tst.xsl tst.xml text in p = "The first paragraph." text in p = "The" text in p = "paragraph." orchis:~/XSLT/libxslt -> thanks for the report, Daniel
Should be fixed in libxml2-2.4.15 / libxslt-1.0.12 thanks, Daniel (P.S.: la couleur de graougraou.com est vraiment abominable !)