This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Testing the type of the current node
> > <xsl:when test="self::text()">
>
> I can't see anything wrong with this, though I haven't had time to try it.
> Which product(s) have you tried it on - it's always worth telling us. And if
> you really think something should work and isn't working, it's always worth
> trying it on more than one product.
Though I did, and I thought that both XT and Saxon produced false in
this circumstance, I went back this morning and wrote the following test
case to be absolutely sure that I was right. Strange but true, Saxon
seems to have a bug in this department:
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:variable name="textnode">Text node</xsl:variable>
<xsl:template match="/">
<xsl:for-each select="document('')/*/xsl:variable">
<xsl:text>child::text() = </xsl:text>
<xsl:choose><xsl:when test="child::text()">true</xsl:when>
<xsl:otherwise>false</xsl:otherwise></xsl:choose>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="document('')/*/xsl:variable/text()">
<xsl:text>self::text() = </xsl:text>
<xsl:choose><xsl:when test="self::text()">true</xsl:when>
<xsl:otherwise>false</xsl:otherwise></xsl:choose>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
From Saxon:
child::text() = true
self::text() = false
From XT:
child::text() = true
self::text() = true
Steve
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list