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

AW: [xsl] format-number abd numerical truncation


Subject: AW: [xsl] format-number abd numerical truncation
From: Markus Abt <abt@xxxxxxxx>
Date: Thu, 28 Aug 2003 21:25:38 +0200

Hi John,

you didn't say with which xslt processor you got this funny result.
Report it as a bug and/or use some other one.


Regards,
Markus
__________________________
Markus Abt
Comet Computer GmbH
http://www.comet.de


----------
Von: 	Nunnington, John
Gesendet: 	Donnerstag, 28. August 2003 17:42
An: 	XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Betreff: 	[xsl] format-number abd numerical truncation

Hi All,

 

[2 part problem] 

 

We've encountered a problem with format-number where-by the value part
actually changes according to the precision.

 

XML:

<?xml version="1.0" encoding="UTF-8"?>
<AR_ITEMS elem="4">
   <EVENTS elem="1">
      <TOTAL elem="826">
         <AMOUNT>0.00000073173</AMOUNT>
      </TOTAL>
   </EVENTS>
   <EVENTS elem="2">
      <TOTAL elem="826">
         <AMOUNT>0.0000073173</AMOUNT>
      </TOTAL>
   </EVENTS>
   <EVENTS elem="3">
      <TOTAL elem="826">
         <AMOUNT>0.000073173</AMOUNT>
      </TOTAL>
   </EVENTS>
   <EVENTS elem="4">
      <TOTAL elem="826">
         <AMOUNT>0.73173</AMOUNT>
      </TOTAL>
   </EVENTS>
   <EVENTS elem="5">
      <TOTAL elem="826">
         <AMOUNT>0.073173</AMOUNT>
      </TOTAL>
   </EVENTS>
   <EVENTS elem="6">
      <TOTAL elem="826">
         <AMOUNT>0.00073173</AMOUNT>
      </TOTAL>
   </EVENTS>
</AR_ITEMS>



XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
   <xsl:output method="html" indent="yes"/>
   <!-- Main Driver Template -->
      <xsl:decimal-format zero-digit="0" decimal-separator="." name="df"
grouping-separator="," per-mille="," pattern-separator=";">
      </xsl:decimal-format>   
      <xsl:strip-space elements="*"></xsl:strip-space>
      <xsl:template match="/">
         <html>
         <HEAD>
         </HEAD>
         <body bgcolor="#ffffff">
            <table bgcolor="#cfcfcf" cellpadding="5" cellspacing="2"
border="1">
      <tbody>
         <xsl:for-each select="//EVENTS">
            <tr>
               <TD align="right">
                  <FONT size="3">
                     <xsl:if test="TOTAL[@elem  = 826]">
                        <xsl:value-of
select="format-number(TOTAL/AMOUNT,'0.0000')"/>
                     </xsl:if>
                  </FONT>
               </TD>
            </tr>
         </xsl:for-each>
      </tbody>
   </table>
   </body>
   </html>
   </xsl:template>
</xsl:stylesheet>

 

Resulting HTML:

 

0.0000
0.0000
0.1000
0.7317
0.7320
0.7000
 

 

...we never fixed this so we though that we'd correct the rounding in the
source program. This worked OK, as long as we had a full complement of
digits after the decimal point. When we have a number with less, say 0.7320,
it is being displayed at 0.732

 

Anybody ever comes across either of these problems and resolved them or
found them to be persistent bugs?



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords