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

Re: 'true' or true()

Subject: Re: 'true' or true()
From: Karl Stubsjoen <kstubs@xxxxxxxxx>
Date: Mon, 1 Nov 2010 14:36:30 -0700
Re:  'true' or true()
Ahh, so must fall back to string comparison.  I figured as such, but
wanted confirmation.  Thanks!
Karl..

On Mon, Nov 1, 2010 at 2:23 PM, G. Ken Holman
<gkholman@xxxxxxxxxxxxxxxxxxxx> wrote:
> At 2010-11-01 14:14 -0700, Karl Stubsjoen wrote:
>>
>> I have a parameter which will either be, true() by default or 'true'
>> (set by user).  Given the name isTrue, how do you properly write the
>> if test below:
>>
>> <xsl:param name="isTrue" select="true()"/>
>> <xsl:if test="$isTrue or isTrue=true()">
>>
>> When user sets the param value = 'false' the above isTrue test still
>> passes.
>
> Right ... because most tools pass user-specified parameter values as
> strings, and any non-empty string tests as true.
>
> In your situation I would do for XSLT 1.0:
>
>  <xsl:param name="isTrue" select="'true'"/>
>  ...
>  <xsl:if test="$isTrue='true'">...
>
> If you are using XSLT 2.0 I would cast the passed value using xsd:boolean()
> which has a value set of four strings '1', '0', 'true' and 'false'.
>
> I hope this helps.
>
> . . . . . . . . Ken
>
>
> --
> Contact us for world-wide XML consulting & instructor-led training
> Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
> G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
> Legal business disclaimers:  http://www.CraneSoftwrights.com/legal
>
>



--
Karl Stubsjoen
MeetScoresOnline.com
(602) 845-0006

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.