XML - Sum()

Hi All,

Im flying by the seat of my pants here…I’ve managed to output data using xsl in a table format. Now I need to add a sum function on the ‘BankTotals’ column. Any ideas would be much appreciated.

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl=“XSLT Namespace

version="1.0"

xmlns:xalan="http://xml.apache.org/xslt">





<xsl:template match="/">

	<html>

		<body>

			<center><h2>Banking</h2></center>

			<table border="0" width="95%">

			<th></th>

			<th align="left">Date</th>

			<th align="left">Details</th>

			<th align="right">Bank Amount</th>

	<xsl:apply-templates/> 

			</table>

		</body>

	</html>

</xsl:template>



<xsl:template match="viewentry">

		<tr bgcolor="#e6e6fa">

		<td width="1%" valign="bottom"><a target="frmDocPreview" style="text-decoration:none">

			<xsl:attribute name="href"><xsl:value-of select="@unid"/>?opendocument</xsl:attribute>

			<img border="0" src="/icons/doclink.gif" /></a></td>



			<xsl:apply-templates select="entrydata" />

		</tr>

</xsl:template>



<xsl:template match="entrydata[@name='Date']">

<td width="10%">

<xsl:variable name="d" select="substring(.,8)"/>

  <xsl:variable name="m" select="substring(.,6,2)"/>

  <xsl:variable name="y" select="substring(.,1,5)"/>



	<xsl:value-of select="concat($d,'-',$m,'-',$y)" />

</td>

</xsl:template>

<xsl:template match="entrydata[@name='Details']">

<td width="30%">

	<xsl:value-of select="text" />

</td>

</xsl:template>

<xsl:template match="entrydata[@name='BankTotals']">

<td align = "right" width="10%">

	<xsl:value-of select="format-number(.,'$###,##0.00')" />

</td>

  </xsl:template>

</xsl:stylesheet>

Thanks in Advance,

Terry

Subject: XML - Sum()

Have you tried the xslt sum function?

http://www.zvon.org/xxl/XSLTreference/OutputExamples/example_1_1_frame.html