In posting xs:decimal()
https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/xs_decimal19
it was discussed that xs:decimal() has to be applied to an atomic type, and a solution was provided allowing to apply xs:decimal() to a nodeset.
In addition it was mentioned that "XSLT 2.0" needs to be selected as "XSLT Version" in DataPower service's XML Manager's Compile Options Policy.
The XSLT 2.0 spec requires at least 18 digit precision for xs:decimal:
http://www.w3.org/TR/xslt20/#limits
DataPower xs:decimal supports precision of 18 digits, which can be seen by the following simple experiments.
The last three samples produce the following error messages in the log:
- long4.xml (overflow)
mpgw (coproc2): Execution of 'xa35://tmp/temp_00165' aborted: xa35://tmp/temp_00165:13: decimal overflow - long5.xml (number too long)
mpgw (coproc2): Execution of 'xa35://tmp/temp_00165' aborted: xa35://tmp/temp_00165:11: cannot convert value to decimal - long6.xml (number too long)
mpgw (coproc2): Execution of 'xa35://tmp/temp_00165' aborted: xa35://tmp/temp_00165:11: cannot convert value to decimal
$ cat long[1-6].xml
<n>123456789012345678.876543210987654321</n>
<n>899999999999999999.999999999999999998</n>
<n>799999999999999999.999999999999999999</n>
<n>899999999999999999.999999999999999999</n>
<n>.1234567890123456789</n>
<n>1234567890123456789</n>
$
$ java coproc2 decimalDemo.xsl long1.xml http://dp3-l3:2223
. 123456789012345678.876543210987654321
+ 100000000000000000.000000000000000001
= 223456789012345678.876543210987654322
$
$ java coproc2 decimalDemo.xsl long2.xml http://dp3-l3:2223
. 899999999999999999.999999999999999998
+ 100000000000000000.000000000000000001
= 999999999999999999.999999999999999999
$
$ java coproc2 decimalDemo.xsl long3.xml http://dp3-l3:2223
. 799999999999999999.999999999999999999
+ 100000000000000000.000000000000000001
= 900000000000000000
$
$ cat decimalDemo.xsl
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xsl:output method="text"/>
<xsl:variable name="add18d18"
select=" xs:decimal('100000000000000000.000000000000000001')"/>
<xsl:template match="/">
. <xsl:value-of select="xs:decimal(.)"/>
+ <xsl:value-of select="$add18d18"/>
= <xsl:value-of select="xs:decimal(.) + $add18d18"/>
</xsl:template>
</xsl:stylesheet>
$
Hermann.