I'm having trouble with sum'ing up values in a variable.
XSLT Source
<xsl:variable name="amountIn" xml:space="preserve">
<values>
<xsl:for-each select="ext:node-set($finData)//child::balance/@in">
<value><xsl:value-of select="."/></value>
</xsl:for-each>
</values>
</xsl:variable>
XML source:
<source>
<balance dpt="-1" diff="0,00" out="555777,00" in="555777,00" acnt="2120"/>
<balance dpt="-1" diff="0,00" out="777778,00" in="777778,00" acnt="2240"/>
<balance dpt="-1" diff="0,00" out="878787,00" in="878787,00" acnt="2380"/>
<balance dpt="-1" diff="0,00" out="87878787,00" in="87878787,00" acnt="2400"/>
</source>
I expected this to give me the result, but all I get is "NaN"
<xsl:value-of select="sum(ext:node-set($amountIn)/values/value)"/>
you are getting NAN because of the , in the number using the translate number to change this into a . should work!
<xsl:variable name="amountIn" xml:space="preserve">
<values>
<xsl:for-each select="ext:node-set($finData)//child::balance/@in">
<value><xsl:value-of select="translate(.,',','.')"/></value>
</xsl:for-each>
</values>
</xsl:variable>