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

Re: Less than symbol in xsl:if or xsl:when

Subject: Re: Less than symbol in xsl:if or xsl:when
From: Sam Wilmott <sam@xxxxxxxxxx>
Date: Thu, 7 Oct 2010 22:26:16 -0400
Re:  Less than symbol in xsl:if or xsl:when
On 2010-10-07, at 3:42 PM, sudheshna iyer wrote:

> The following stmt works, but when I replace > with <, it doesn't work. I am
> compiling with xmlspy with xslt1.0
> <xsl:when test="string-length($VAR1) > $VAR2">  => Works
>
> <xsl:when test="string-length($VAR1) < $VAR3">  => Doesn't work
>
> My main goal is to  check whether length of VAR2 is in between 2 numbers..
like
>
> string-length($VAR1) >= $VAR2and string-length($VAR1) <= $VAR3
>
> How do I achieve this?

If you're using XSLT 2.0 rather than XSLT 1.0, then a better way to do it is:

string-length($VAR1) ge $VAR2and string-length($VAR1) le $VAR3

XSLT 2.0 introduced the scalar operators eq, ne, lt, gt, le and ge, which
compare single values rather than lists, which is what XSLT 1.0 comparison
operators do.  They are therefore safer to use when you're comparing single
values and they don't run into syntactic difficulties.

Sam.
------------
Sam Wilmott
sam@xxxxxxxxxx

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.