[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: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 8 Feb 2005 15:58:35 -0000
xsl if test boolean
This:

<xsl:variable name="show">
  <xsl:value-of select = "$time != 60000" />
</xsl:variable>

is not a boolean variable, it is a result tree fragment. If you convert a
result tree fragment to a boolean, the result is always true.

The correct way to write a boolean variable is:

<xsl:variable name="show" select="$time != 60000" />

I simply have no idea why this verbose, inefficient, and often incorrect
style using <xsl:value-of> within <xsl:variable> has become so popular.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Ken Goodridge [mailto:goodridgehunting@xxxxxxxxx] 
> Sent: 08 February 2005 15:39
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Can I use a boolean variable in an xsl:if test
> 
> 
>    I've been using the following xsl with success, but
> I am seeing the xsl:if not work properly in another
> installation. In both cases I get
> <debug><show>false</show><time>60000</time></debug>,
> but in one case the noshow shows. Does this code break
> the rules or am I seeing a bug in the xsl transform?
> In both cases I'm using xalan. I can check to see if
> the versions are different if someone thinks that may
> help.
> 
> <xsl:template name="my_template">
>         <xsl:param name="time"/>
> 
> <!-- Don't show if time is one minute -->
> <xsl:variable name="show">
>   <xsl:value-of select = "$time != 60000" />
> </xsl:variable>
> 
> <debug>
>     <show><xsl:value-of select = "$show" /></show>
>     <time><xsl:value-of select = "$time" /></time>
> </debug>
> 
> <xsl:if test="$show">
>     <noshow><xsl:value-of select = "$show" /></noshow>
> </xsl:if>
> 
> </xsl:template>
> 
> 
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> The all-new My Yahoo! - What will yours do?
> http://my.yahoo.com 

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.