xsl-list
[Top] [All Lists]

[xsl] Unexpected result in sum

2007-11-09 12:50:54
Why does this not output 0.00?  When formatted, I end up with -$0.00.

I've read what I can find on negative zero, but can't see how this node
set and operation could produce it.

Using Saxon 8.9 processor (internal to Oxygen.)

Input:
<?xml version="1.0" encoding="UTF-8"?>
<a>
    <b>1103.86</b>
    <b>1829.30</b>
    <b>-853.77</b>
    <b>-243.17</b>
    <b>-1.11</b>
    <b>-1296.66</b>
    <b>588.52</b>
    <b>849.25</b>
    <b>-1976.22</b>
</a>

Output:
<?xml version="1.0" encoding="UTF-8"?>
<a>
   <sum-b>-2.2737367544323206E-13</sum-b>
   <sum-nodes>-2.2737367544323206E-13</sum-nodes>
</a>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="2.0">
    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="/a">
        <a>
            <sum-b>
                <xsl:value-of select="sum(b)"/>
            </sum-b>

            <xsl:variable name="nodes" select="b"/>

            <sum-nodes>
                <xsl:value-of select="sum($nodes)"/>
            </sum-nodes>
        </a>
    </xsl:template>
</xsl:stylesheet>

Thanks!
Angela Williams 
Office: 512.344.1547 ~ Fax: 512.397.6656
Angela(_dot_)Williams(_at_)The401kCompany(_dot_)com    
 


--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>