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

Re: Re: Capturing/testing results of a boolean express

Subject: Re: Re: Capturing/testing results of a boolean expression.
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 02 Aug 2002 18:46:33 -0400
boolean express
Ed,

At 05:59 PM 8/2/2002, you wrote:
Maybe details are called for, because as I gnaw at this problem and read
archives I realize the trick might be to establish an expression which
returns a "boolean" as opposed to an expression which returns a
"results-tree-fragment".

Quite right. This is a tricky subtlety in declaring variables, that these aren't the same thing.


I have a variable which will have a string value.  I wish to compare
that string value to another string value (which happens to be a literal
value).  I've done this directly in a xsl:if or xsl:when before, but now
I'm trying to capture the results of the expression in a variable.

<xsl:variable name="X" ..../>

<xsl:variable name="flag" select="$X = 'literal-string-value'" />

Is there a way to do this that returns a 'boolean' and not a
'results-tree-fragment'?

The way you gave should do precisely that. The select="$X = 'literal-string-value'" will return a Boolean and bind it to the variable. Whereas


<xsl:variable name="flag">
  <xsl:value-of select="$X = 'literal-string-value'" />
</xsl:variable>

will take the Boolean, turn it into a string, and put it into an RTF.

Is there a way to take a 'results-tree-fragment' which has the value
"true" or "false" and turn it back into the equivalent 'boolean' value?

Sure:


<xsl:variable name="flag" select="$rtf = 'true'"/> will bind $flag to Boolean true() only if the string value of $rtf is 'true'; otherwise it'll be false().

(true() and false() are functions that will return the Boolean true and false values respectively. They too may be useful to you.)

But any time you do <xsl:value-of select="$flag"/> you are coercing the Boolean back into a string, since that's what value-of does.

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 ======================================================================


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.