I am trying to output a table which lists a customer's payments whilst keeping a running total. A section of my XML is as follows: [CODE]<Accounts> <Payment> <CustomerID>1</CustomerID> <Date>2009-03-16</Date> <Amount>22</Amount> </Payment> <Payment> <CustomerID>4</CustomerID> <Date>2009-02-12</Date> <Amount>35</Amount> </Payment> <Payment> <CustomerID>2</CustomerID> <Date>2009-05-17</Date> <Amount>41</Amount> </Payment>[/CODE] I have included the following code to sort the output into date order: [CODE]<xsl:apply-templates select="Payment"> <xsl:sort select="Date" /> </xsl:apply-templates> [/CODE] In attempting to output the table I have written the following code: [CODE]<td> <xsl:apply-templates select="Date" /> </td> <td> <xsl:apply-templates select="Amount" /> </td> <td> <xsl:variable name="running-total" select="sum(preceding-sibling::Payment/Amount) + Amount)" /> <xsl:value-of select="$running-total" /> </td>[/CODE] However, when accumulating the running total …

Member Avatar
Member Avatar
+0 forum 1

The End.