Hi!
We are having a strange behaviour in XSLT having some weird rounding of
integer values when displaying them through "format-number()" function.
I happens with serveral numbers and with different numbers of decimals.
Is this the expected behaviour ?
We are using recent versions of libxmls2 (2.7.4) and libxslt (1.1.26),
and PHP (5.3.3). Anyhow the results are the same with xsltproc.
The sample code:
<?php
$XML = '<?xml version="1.0"
encoding="iso-8859-1"?><Dato>1000000000001</Dato>';
$XSL = <<<EOF
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version = '1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method="text" />
<xsl:decimal-format name="european" decimal-separator=","
grouping-separator="." />
<xsl:template match="/">
<p><xsl:value-of select="format-number(., '#,#', 'european')"/></p>
<p><xsl:value-of select="format-number(., '#,##', 'european')"/></p>
<p><xsl:value-of select="format-number(., '#,###', 'european')"/></p>
<p><xsl:value-of select="format-number(., '#,####', 'european')"/></p>
<p><xsl:value-of select="format-number(., '#,#####', 'european')"/></p>
<p><xsl:value-of select="format-number(., '#,######', 'european')"/></p>
<p><xsl:value-of select="format-number(., '#,#######', 'european')"/></p>
<p><xsl:value-of select="format-number(., '#,########', 'european')"/></p>
<p><xsl:value-of select="format-number(., '#,#########', 'european')"/></p>
<p><xsl:value-of select="format-number(., '#,##########', 'european')"/></p>
</xsl:template>
</xsl:stylesheet>
EOF;
$docXML = new DOMDocument();
$docXSL = new DOMDocument();
$docXML->loadXML($XML);
$docXSL->loadXML($XSL);
$procXSL = new XsltProcessor();
$procXSL->importStylesheet($docXSL);
$docHTML = $procXSL->transformToDoc($docXML);
echo $docHTML->saveXML();
?>
The output we get (it is supposed to show always "1000000000001"):
<?xml version="1.0"?>
<p>1000000000001</p>
<p>1000000000001</p>
<p>1000000000001</p>
<p>1000000000001</p>
<p>1000000000001</p>
<p>1000000000000,999878</p>
<p>1000000000001</p>
<p>1000000000001,00012207</p>
<p>1000000000001</p>
<p>1000000000000,9998779297</p>
Thanks,
David.
--
David Guerrero E-mail:
david(_at_)boe(_dot_)es
Dpto Tecnologias de la Informacion Telf: 91 111 41 11
B.O.E. (Boletin Oficial del Estado) Ministerio de la Presidencia
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--