string-length($image_src) = '4' or '5'
You're trying to guess the syntax of XPath here, and you've guessed
something that's meaningful in the language but doesn't mean what you think.
It means
(string-length($image_src) = '4') or (boolean('5'))
and boolean('5') is true.
In XPath 2.0 you can write
string-length($image_src) = (4, 5)
In 1.0, write
string-length($image_src) = 4 or string-length($image_src) = 5
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Alice Ju-Hsuan Wei [mailto:ajwei(_at_)indiana(_dot_)edu]
Sent: 13 September 2007 12:23
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] [XSL] Calculating Length of String Variables
Thanks to Michael and Jing. This part is now working and
prints out the "value of the string length" accurately.
However, when I tried to use the node with the result of
"123456," it prints out the "string-length" as a 6 preperly.
But when I try to run a "test" of action according to this
result, it does not perform any of the actionsth as in
<xsl:when test="string-length($image_src_ ='6'">, but
performs the actions as in
<xsl:when-test="string-length($image_src)='4' or '5'"> as shown below:
<xsl:when test="string-length($image_src) = '4' or '5'">
<img>
<xsl:attribute
name="src">images/<xsl:value-of select="./@url"/>.gif</xsl:attribute>
<xsl:attribute name="alt"> Picture No.
<xsl:value-of select="./@url"/>
</xsl:attribute>
</img>
</xsl:when>
<xsl:when test="string-length($image_src) = '6' ">
<img>
<xsl:attribute
name="src">images/<xsl:value-of select="substring($image_src,1,4)"
/>.gif</xsl:attribute>
<xsl:attribute name="alt"> Picture No.
<xsl:value-of select="substring($src,1,4)"/>
</xsl:attribute>
</img>
</xsl:when>
Does anyone know if there is something I should have done
that I have not?
Thank again.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--