Re: [xsl] boolean variables

Subject: Re: [xsl] boolean variables
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 9 Aug 2006 16:23:58 +0100
This is a FAQ if (in XSLT1) you use xsl:variable with content then it
always gennerates a result tree fragment which correspnds to a root node
with a child  a text node with the string value of the content. This
acts like a node set with a single / node, in particular it's non empty
so acts as true().

don't do this

        <xsl:variable name="false">
            <xsl:call-template name="get-false"/>

  <xsl:template name="get-false">
        <xsl:value-of select="false()"/>

do this

  <xsl:variable name="false" select="false()"/>

the first version is equivalent to

<xsl:variable name="false">false</xsl:variable>

which corresponds to a document with thattext, so is non empty and has
boolean value true().


Current Thread