Subject: Re: [xsl] sum function From: Jörg Heinicke <joerg.heinicke@xxxxxx> Date: Fri, 16 Nov 2001 18:51:53 +0100 |
<xsl:template match="amounts"> <xsl:variable name="sum"> <xsl:apply-templates select="amount[1]"/> </xsl:variable> <xsl:value-of select="$sum"/> </xsl:template>
<xsl:template match="amount"> <xsl:param name="sum" select="0"/> <xsl:apply-templates select="following-sibling::amount[1]"> <xsl:with-param name="sum" select="$sum + number(substring-after(.,'£'))"/> </xsl:apply-templates> <xsl:if test="not(following-sibling::amount[1])"> <xsl:value-of select="$sum + number(substring-after(.,'£'))"/> </xsl:if> </xsl:template>
How do I use the sum function on xml such as:
<Amount>12,345.12</Amount> <Amount>132,345.12</Amount> <Amount>2,345.12</Amount>
If I use Total Price = <xsl:value-of select="sum(//Amount)"/> I get the result NaN. However, if the data does not contain ',' the sum works correctly. Any help appreciated. Regards Jan
System Development VIRBUS AG Fon +49(0)341-979-7435 Fax +49(0)341-979-7409 joerg.heinicke@xxxxxxxxx www.virbus.de
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] sum function, Michael Kay | Thread | RE: [xsl] sum function, Hesselberth, Jan |
Re: [xsl] Jeni reminds me....., David Carlisle | Date | Re: [xsl] Reformatting character st, Jörg Heinicke |
Month |