Re: [xsl] Can I use a boolean variable in an xsl:if test

Subject: Re: [xsl] Can I use a boolean variable in an xsl:if test
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 8 Feb 2005 15:47:50 GMT
The answer to the question in the subject line is "yes"
but there is a but....

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

as stated on this list most days, don't use xsl:variable with content
and no select attribute unless that's what you really want.

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

would make show into a boolean valued variable, $show would have value
true() or false() depending.

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

makes show into a result tree fragment corresponding to a node set that
has a root node with single child a text node with string value "truee"
or "false" depending. So getting this is more to type and a _lot_ more
data stored in the machine (nodes are expensive thins to construct
compared to ataomic values). Often efficiency is the only difference but
here the other difference is that if used in a boolean context a result
tree fragment acts like the corresponding node set so is true just if
teh node set is non empty which is always the case as all result tree
fragments correspond to a node set with exactly one node (a root node).


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

Current Thread