RE: Totals
<[email protected]> Thu, 17 Apr 2003 09:12:36 +0300
| Newsgroups | gmane.text.xml.xsl.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,
> I want to group and sub-total based on a SBU - Strategic Business Unit:
[snip]
> There are 4 different SBU's and I want to sub-total at the end of each SBU. How can I do this?
<xsl:key name="sbu" match="Customer" use="SBU" />
<xsl:template match="*[Customer]">
<xsl:for-each select="Customer[generate-id(.) = generate-id(key('sbu', SBU))]">
<fo:block>
<xsl:for-each select="key('sbu', SBU)">
<fo:block>
<xsl:value-of select="CustomerNumber" />
</fo:block>
...
</xsl:for-each>
</fo:block>
<fo:block>
<xsl:text>sub-total: </xsl:text>
<xsl:value-of select="sum(key('sbu', SBU)/PostInc)" />
</fo:block>
</xsl:for-each>
</xsl:template>
XSL-List at <http://mulberrytech.com/xsl/xsl-list/> is usually a better place to ask XSLT related questions.
Cheers,
Jarno - VNV Nation: Procession