Subject: RE: Can I use a boolean variable in an xsl:if test
From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx>
Date: Tue, 8 Feb 2005 16:13:41 -0000
|
> <!-- Don't show if time is one minute -->
> <xsl:variable name="show">
> <xsl:value-of select = "$time != 60000" />
> </xsl:variable>
[snip]
> <xsl:if test="$show">
> <noshow><xsl:value-of select = "$show" /></noshow> </xsl:if>
>
> </xsl:template>
Here you want:
<xsl:variable name="show" select="$time != 60000" />
Whenever you define a variable with no select statement (i.e. it has
child content) :
<xsl:variable name="show">
...
</xsl:variable>
...the variable has a type of 'tree' (result tree fragment). What you
are doing above is testing if the tree is true or false, and a tree is
true if it is non-empty. So, your $show variable above contains a tree
with a root node and single text node with the value 'false', which
makes it true :)
By using the select attribute the result of the expression is bound to
the variable, giving the variable a type of boolean (and not RTF) which
is what you are after.
Cheers
andrew
| Current Thread |
|
Andrew Welch - 8 Feb 2005 16:16:06 -0000 <=
Andrew Welch - 9 Feb 2005 08:35:52 -0000
Pawson, David - 9 Feb 2005 11:06:43 -0000
|
|