After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 71181 - pattern "p/text()" selects nothing
pattern "p/text()" selects nothing
Status: VERIFIED FIXED
Product: libxslt
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
Daniel Veillard
Depends on:
Blocks:
 
 
Reported: 2002-02-11 14:14 UTC by Julien Quint
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Julien Quint 2002-02-11 14:14:25 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(..), ' = &#x22;')"/>
    <xsl:value-of select="normalize-space(.)"/>
    <xsl:text>&#x22;&#xa;</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
Comment 1 Daniel Veillard 2002-02-11 15:32:00 UTC
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
Comment 2 Daniel Veillard 2002-02-12 08:45:25 UTC
Should be fixed in libxml2-2.4.15 / libxslt-1.0.12

 thanks,

Daniel

(P.S.: la couleur de graougraou.com est vraiment abominable !)