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

Re: testing strings

Subject: Re: testing strings
From: Michel CASABIANCA <casa@xxxxxx>
Date: 17 Nov 1999 00:31:36 +0100
xsl testing strings
Bill Abbas <babbas@xxxxxxxxxx> writes:
> Pretty basic question about how to handle strings.  If I have an element in
> XML like so
> 
>          	<Whatever>
>                 <Choice>
>                     true
>                 </Choice>
> 	</Whatever>
>             
> And I want to output one of two values, depending on whether the Choice
> element is true or false.  
> 
> The following transform doesn't seem to do the trick.
> 
> 	<xsl:template match="Whatever">
> 	        <xsl:choose>
>             	    <xsl:when test="{Choice}='true')">
> 	                        Choice is true
>             	    </xsl:when>
> 	                <xsl:otherwise>
>             	            Choice is false
> 	                </xsl:otherwise>
> 	        </xsl:choose>
> 	</xsl:template>
> 
> What is the proper syntax for a test to compare strings?  Thanks.

I would rather do this way:

<Whatever>
   <true/>
</Whatever>

or

<Whatever>
</Whatever>

if not true.

Yu could perform the test this way:

<xsl:template match="Whatever">
   <xsl:choose>
      <xsl:when test="true">
         Choice is true
      </xsl:when>
      <xsl:otherwise>
         Choice is false
      </xsl:otherwise>
   </xsl:choose>
</xsl:template>

This is more readable and efficient in my opinion.

-- 
Michel CASABIANCA
mailto:casa@xxxxxx
http://www.sdv.fr/pages/casa


 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.