[Home] [By Thread] [By Date] [Recent Entries]
Torsten Schassan schrieb:
Arithmetic operator is not defined for arguments of types (xs:string, xs:double) URL: http://www.w3.org/TR/xpath20/#ERRXPTY0004
(1) $binary is a string, so you can use string operations like
string-length() and substring()
(2) You're using the result of these string operations with arithmetic
operators like + and * ; this works in 1.0, but not in 2.0.
(3) In order for it to work in 2.0, use the number() function to
convert the result of substring() to a number.<xsl:transform version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:variable name="sum" select="3"/>
<xsl:variable name="binary" select="'123456789'"/>
<xsl:variable name="power" select="4"/>
<xsl:value-of select="$sum +
number( substring( $binary,string-length( $binary))) * $power"/>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:transform>Michael Ludwig
|

Cart



