[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Can I use a boolean variable in an xsl:if test

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
xsl variable boolean
> <!-- 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.