[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Torsten Schassan schrieb:
Michael Ludwig
Re: [xsl] Problem with base64encode.xsl
Subject: Re: [xsl] Problem with base64encode.xsl From: Michael Ludwig <mlu@xxxxxxxxxxxxx> Date: Fri, 18 Jul 2008 15:53:22 +0200 |
Torsten Schassan schrieb:
Arithmetic operator is not defined for arguments of types (xs:string, xs:double) URL: http://www.w3.org/TR/xpath20/#ERRXPTY0004
The error points to this line in <xsl:call-template name="binaryToDecimal">:
<xsl:with-param name="sum" select="$sum + substring($binary,string-length($binary) ) * $power"/>
This works in loosely-typed XSL 1.0, but doesn't in strictly-typed XSL 2.0, which you are using.
(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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Problem with base64encode.xsl, Torsten Schassan | Thread | RE: [xsl] Problem with base64encode, Michael Kay |
[xsl] Problem with base64encode.xsl, Torsten Schassan | Date | RE: [xsl] Problem with base64encode, Michael Kay |
Month |
Keywords