[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Variable: true or false
Hi Tom:
This is very tricky. Problem is, your declaration <xsl:variable name="selectUser"/> isn't as "empty" as it looks. Absent a select expression, the variable contains a result tree fragment. XSLT (11.1) says about this special data type that it "is treated equivalently to a node-set that contains just a single root node" (going on to qualify this considerably). That is, if you had the declaration <xsl:variable name="selectUser"> <holla/> </xsl:variable> the variable $selectUser would be bound to a result tree fragment with a structure containing two nodes, a root and a single child (an element named 'holla'). But yours contains just that single root. Alas, when this is treated as a node-set containing a root for purposes of evaluating the boolean() function, this comes out as true(). If you'd said <xsl:variable name="selectUser" select="''"/> (setting the value to be the empty string), or <xsl:variable name="selectUser" select="false()"/> (a boolean false), or even <xsl:variable name="selectUser" select=""/> (the null expression evaluates to an empty node set), ...*then* you'd have gotten false as you expected. This is only one reason result tree fragments are troublesome. Since they are also of questionable utility, rumor has it they may be invited to leave, disappearing from future versions of XSLT. Then you'll get an (empty) node set as you expected. Cheers, Wendell At 09:02 PM 4/6/01, you wrote: I do the transform on this XSL and get "true". I would have expected "false". Thought the boolean of an empty object would always be false.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|