| Subject: Re: [xsl] [XSL] Calculating Length of String Variables From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 13 Sep 2007 13:43:07 +0100 | 
<
xsl:when test="string-length($image_src) = '4' or '5'">
that is a boolean or operator, which is true if either operand is
true. The first operand is true if 
string-length($image_src) = '4'
which is true if the string length of image source when converted to a
string is '4'. You meant
string-length($image_src) = 4
which would just test if teh length is 4 (which is the same thing, but
quicker)
the second operand to or is
'5'
a string, if used in a boolean context counts as true if it is non
empty, which is always teh case, so this is always true, so teh or
expression is always true.
you meant
string-length($image_src) = 5
so the whole thing can be wriiten as
<xsl:variabel name="l" select="string-length(@url"/>
<xsl:choose>
<xsl:when test="$l=4 or $l=4"><!- or in xpath 2 $l=(4,5) -->
<img src="images/{@url}"/>
</xsl:when>
<xsl:when test="$l=6">
<img src="images/{substring(@url,1,4)}.gif alt="Picture
No. {substring(@url,1,4)}"/>
</xsl:when>
David
________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| RE: [xsl] [XSL] Calculating Length , Michael Kay | Thread | Re: [xsl] [XSL] Calculating Length , Abel Braaksma | 
| Re: [xsl] Filtering new tags using , Mukul Gandhi | Date | Re: [xsl] [XSL] Calculating Length , Abel Braaksma | 
| Month |