xsl-list
[Top] [All Lists]

RE: [xsl] Type error with variable as=xs:string using xsl:choose

2006-09-07 02:39:45

You are generating more than one string - in fact you are generating text nodes, but these have a string value. I think you want to use xsl:sequence with a concat function in the select attribute.

From: "Trevor Nicholls" <trevor(_at_)castingthevoid(_dot_)com>

The following variable definition is giving me the error
"XTTE0570: A sequence of more than one item is not allowed as the value of
variable normsrc"

I'm using Saxon 8.6.1 on Windows XP.

====
<xsl:variable name="normsrc" as="xs:string">
<xsl:choose>
<xsl:when test="contains($xsrc,'/images/images/')">
<xsl:text>images/</xsl:text>
<xsl:value-of select="substring-after($xsrc,'/images/images/')" />
</xsl:when>
<xsl:when test="contains($xsrc,'/images/')">
<xsl:text>images/</xsl:text>
<xsl:value-of select="substring-after($xsrc,'/images/')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$xsrc" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
====

If I drop the as="xs:string" attribute it works perfectly, but I'm sure I've
got exactly this construction elsewhere without complaint. One difference
with this logic is that the 'when' tests overlap: any $xsrc that matches the first 'when' will also match the second, but I understood that 'choose' will
only make one choice. Am I confused?

Cheers
Trevor



--~------------------------------------------------------------------
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>
--~--


_________________________________________________________________
Be the first to hear what's new at MSN - sign up to our free newsletters! http://www.msn.co.uk/newsletters


--~------------------------------------------------------------------
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>
--~--