The code you have supplied should be doing the following: Take a length parameter Separate it into variables named number and units Use those variables to set a lenght-in-mm variable Format the length-in-mm with two decimal places. The error message you are getting is "Arithmetic operator is not defined for arguments of types (xs:string, xs:decimal)". This is because you are passing a string to an arithmetic operator, but the operator is expecting a number. I suspect the statements where the number variable is used to set the length-in-mm variable. for example:
<!-- Output the length, translated into mm -->
<xsl:variable name="length-in-mm">
<xsl:choose>
<xsl:when test="$units='cm'">
<xsl:value-of select="$number * 10"/>
If $number is a string, it would generate the error you are seeing This is the code that sets the number variable
<xsl:variable name="number" select="normalize-space(translate($length, '+-0123456789 abcdefghijklmnopqrstuvwxyz', '0123456789'))"/>
It incorrectly does the following: translates a + character to a 0 (zero) translates a - character to a 1 (one) translates the digits 0-7 to the digits 2-9 respectively (i.e. adds 2) discards any 8, 9, space, or lowercase a-z An alternative version of this line is commented out:
<!--xsl:variable name="number" select="normalize-space(translate($length, '+-0123456789.abcdefghijklmnopqrstuvwxyz', '+-0123456789.'))"/-->
This strips any lowercase a-z and is more likely to be correct. I'd suggest backing up your current version, and then trying the following change at the start:
<xsl:template name="Get-size">
<xsl:param name="length"/>
<!-- Get the number part by blanking out the units part and discarding white space. -->
<xsl:variable name="number" select="normalize-space(translate($length, ' abcdefghijklmnopqrstuvwxyz', ''))"/>
<!-- Get the units part by blanking out the number part and discarding white space. -->
<xsl:variable name="units" select="normalize-space(translate($length, ' +-0123456789.', ''))"/>
<!-- Output the length, translated into mm -->
It does essentially the same, but is easier to understand and maintain.
... View more