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

RE: Type error with variable as=xs:string using xsl:c

Subject: RE: Type error with variable as=xs:string using xsl:choose
From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx>
Date: Thu, 07 Sep 2006 10:41:12 +0100
RE:  Type error with variable as=xs:string using  xsl:c
You defined the variable as a single string instance.
If $xsrc has more than one node and the xsl:otherwise instruction kicks in then this is an error.


Perhaps change to:

<xsl:otherwise>
<xsl:value-of select="$xsrc[1]" />
</xsl:otherwise>

Joe



From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:   Type error with variable as=xs:string using xsl:choose
Date: Thu, 7 Sep 2006 21:29:25 +1200

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

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.