xsl-list
[Top] [All Lists]

RE: not()'ing a false variable, xalan 2.4.D1

2002-11-08 02:01:46
    <!-- make a false variable entitled 'false-variable' -->
    <xsl:variable name="false-variable">
      <xsl:value-of select="false()"/>
    </xsl:variable>


You are creating a variable whose value is a result-tree-fragment,
specifically, a tree consisting of a document node owning a text node.
The string-value of the text node is obtained by converting the boolean
value false() to a string, so it will be the string "false". When a
result-tree-fragment is converted to a boolean, the result is always
true().

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

In fact, 99% of the time that you see an <xsl:variable> containing a
single <xsl:value-of> instruction, it would be better to use the select
attribute instead.

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list