I used recursive function to calculate the total of calculated column (price * quantity), for each invoice and each client. Now I need to calculate the total for all invoices per client and for all invoices for all clients.
xml looks like this:
<cinvoices>
<client> (with information @ client) </client>
<invoices>
<products>
<product> (information @ product: name, type ect and..
<price>123</price>
<quantity>21</quantity>
</product>
<product> (information @ product: name, type ect and..
<price>123</price>
<quantity>11</quantity>
</product>
</products>
<invoices>
<products>
<product> (information @ product: name, type ect and..
<price>32</price>
<quantity>3</quantity>
</product>
<product> (information @ product: name, type ect and..
<price>12</price>
<quantity>9</quantity>
</product>
</products>
</invoices>
</client>
<client>
<same as above>
</client>
</cinvoices>
The function used in xslt is:
<xsl:template name="sumProducts">
<xsl:param name="pList"/>
<xsl:param name="pRunningTotal" select="0"/>
<xsl:choose>
<xsl:when test="$pList">
<xsl:variable name="varMapPath" select="$pList[1]"/>
<xsl:call-template name="sumProducts">
<xsl:with-param name="pList" select="$pList[position() > 1]"/>
<xsl:with-param name="pRunningTotal"
select="$pRunningTotal + $varMapPath/price * $varMapPath/quantity"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
$<xsl:value-of select="format-number($pRunningTotal, '#,##0.00')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
===================== function called as follow:
<xsl:call-template name="sumProducts">
<xsl:with-param name="pList" select="*/*"/>
</xsl:call-template>
Any idea how to use this function to calculate the total for invoices for each client and the grand total for all clients and all invoices.
thank you.