Hi,
[color=blue]
> I am looking to transform the above XML into the below structure
> grouping payments with alike ones util there is a different payment
> encountered. I also need to inculde a count of the like payments.
>[/color]
The following sample stylesheet produces the output you want.
<?xml version='1.0' encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="Amounts">
<Payments>
<xsl:apply-templates select="Amount[position()= 1 or . !=preceding::Amount[1]]"/>
</Payments>
</xsl:template>
<xsl:template match="Amount">
<xsl:variable name="count" select="count(following::Amount[. !=current()][1]/preceding::Amount) "/>
<xsl:variable name="cnt">
<xsl:if test="$count =0"><xsl:value-of select="count(../Amount)"/></xsl:if>
<xsl:if test="$count !=0"><xsl:value-of select="$count"/></xsl:if>
</xsl:variable>
<Payment amount="{.}" numpayments="{$cnt - count(preceding::Amount) }" />
</xsl:template>
</xsl:stylesheet>
regards,
--
Joris Gillis (
http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum