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

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

Subject: Re: not()'ing a false variable, xalan 2.4.D1
From: Greg Faron <gfaron@xxxxxxxxxxxxxxxxxx>
Date: Thu, 07 Nov 2002 17:37:38 -0700
Re:  not()'ing a false variable
At 05:17 PM 11/7/2002, you wrote:
  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?

Test case:

<?xml version="1.0"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">

<xsl:output method="xml"/>

<xsl:template match="/">

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

Stop here. This is where you are confused. If you were to instead say
<xsl:variable name="false-variable" select="false()"/>, it would work exactly as you would expect it to. The problem is that you are creating a result-tree-fragment consisting of the text node "false". That is what happens when you say <xsl:value-of select="false()" />.


Later, you test if the variable has any content (when test="$false-variable"), which it does: the string "false".

Solution: Use the 'select' attribute of xsl:variable when you want a boolean result, not a string result.


Greg Faron Integre Technical Publishing Co.



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


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.