sum on exsl:node-set is bringing back an incorrect value

427 Views Asked by At

I have written some xsl to create some xml code which is then summed. Here is the code:

              <xsl:variable name ="tmpTotal">
                <root>
                  <xsl:for-each select="key('idxid',$id)//parent::*/transaction/transaction-date[substring(@iso-date,1,4) = $newyear  ]">
                      <xsl:if test="../transaction-type[@code='E']">
                        <item>
                          <xsl:value-of select="number(../value)"/>
                        </item>
                      </xsl:if>

                    </xsl:for-each>
               </root>
            </xsl:variable>

              <xsl:variable name="value" select="sum(exsl:node-set($tmpTotal)/root/item)" />
              <h3>
                All: <xsl:value-of select="exsl:node-set($tmpTotal)/*"/> <br/>
                Year: <xsl:value-of select="$newyear"/> <br/>
                Value:<xsl:value-of select="$value"/> <br/>

              </h3>

The result is as follows: All: 96363464029561 Year: 2005 Value:73837

The list of numbers (From the All: output) are as follows: 9636 3460 29561 The total should be 42657. However, the total from the sum(exsl:node-set($tmpTotal)/root/item) is 73837. If the numbers are correct in the xml, why am I getting an incorrect total? Thanks in advance for your help.

1

There are 1 best solutions below

0
On

Your calculations are wrong. 9636 + 34640 + 29561 = 73837