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

RE: Can I use a boolean variable in an xsl:if test

Subject: RE: Can I use a boolean variable in an xsl:if test
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 08 Feb 2005 16:01:48 -0500
xsl if boolean
Jay,

At 03:11 PM 2/8/2005, you wrote:
> My guess is that newbies imagine xsl:value-of to be
> some kind of "evaluate" function. Of course what it
> really is, is an instruction to write a string to a
> result tree (to "the" result tree or to a
> result-tree-fragment, as the case may be). Since this
> is generally what we want to have happen to our
> results, there seems to be nothing to get confused
> about.
>
> Until it breaks, that is, because we're not writing it
> out, but doing something else with it instead. Like
> testing whether it's true, while imagining we're
> testing the expression that was evaluated for it.

I find that I stay out of hot water with xsl:value-of if I just remember
that it returns a string. If I use xsl:value-of on a string, I get a
string. If I use xsl:value-of on a node, I get a string representation of
that node. Either way, though, I get a string.

Yes, my wetware XSLT processor works the same way.


Of course, the string "" returns false() as a Boolean, whereas a result-tree-fragment with a root but nothing in it returns true(), so an extra refinement is required to keep the story really straight --

xsl:variable
  xsl:value-of select="''"

and

xsl:variable select="''"

are coerced to true() and false() respectively, when we test them. The first adds the empty string to the root of an RTF bound to a variable; the second binds the string itself.

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

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.