[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Bug in format-number ? Unexpected rounding
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@xxxxxx Dpto Tecnologias de la Informacion Telf: 91 111 41 11 B.O.E. (Boletin Oficial del Estado) Ministerio de la Presidencia
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|