[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] how to keep big integer format?


Subject: Re: [xsl] how to keep big integer format?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 20 Oct 2006 00:15:55 +0100

formatting the number may get you a bit further, but eventually you'll
get to a range where adding 1 doesn't change the value (as a double)
try 

      <object_id>1111111111111111111</object_id>

for example.

If you are using xslt you can use the xs:integer type for integers.

<xsl:template match="blueprint">
: <xsl:value-of select="1+marker_object/object_id"/>
: <xsl:value-of select="format-number(1+marker_object/object_id,'#0')"/>
: <xsl:value-of select="1+xs:integer(marker_object/object_id)"/>
</xsl:template>

makes
$ saxon8 int.xml int.xsl
<?xml version="1.0" encoding="UTF-8"?>
: 1.1111111111111112E18
: 1111111111111111168
: 1111111111111111112

for example. 

In XSLT1 you'd have to work a bit harder, implementing decimal encoded
addition using string handling.

David


Current Thread
Keywords