W3C home > Mailing lists > Public > www-xsl-fo@w3.org > April 2003

RE: Totals

From: <Jarno.Elovirta@nokia.com>
Date: Thu, 17 Apr 2003 09:12:36 +0300
Message-ID: <E392EEA75EC5F54AB75229B693B1B6A7052902B9@esebe018.ntc.nokia.com>
To: <kryoshida@sweetheart.com>, <www-xsl-fo@w3.org>

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
Received on Thursday, 17 April 2003 02:14:51 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:06:10 GMT