Re: [xsl] not()'ing a false variable, xalan 2.4.D1

Subject: Re: [xsl] not()'ing a false variable, xalan 2.4.D1
From: David N Bertoni/Cambridge/IBM <david_n_bertoni@xxxxxxxxxx>
Date: Thu, 7 Nov 2002 16:47:05 -0800



Hi Elizabeth,

Elizabeth Barham <lizzy@xxxxxxxxxxxxxxxxx> wrote:
> Hi,
>
>    I am trying to make a variable that is either true or false, and
> later doing an <xsl:if> operation with the condition being not'd, but
> for some reason xalan 2.4.D1 is saying that a not("variable assigned
> as false") is not true.
>
>    Is this a bug or am I doing something wrong?

You're doing something wrong.

>     <!-- make a false variable entitled 'false-variable' -->
>     <xsl:variable name="false-variable">
>       <xsl:value-of select="false()"/>
>     </xsl:variable>

This is not a "false" variable.  It's a result tree fragment with a text
node whose content is the string "false".

This is a "false" variable, if I understand what you are trying to do:

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

A result tree fragment variable _always_ evalutes to boolean true(),
because it is considered to be a node-set with one node in it: the root of
the tree.  Thus, the XPath expression "boolean($rtf)" is always true and
"not($rtf)" is always false.

For more information, see:

   http://www.w3.org/TR/xslt#section-Result-Tree-Fragments

Hope that helps!

Dave


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


Current Thread