[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Grouping and Subtotals

Subject: RE: Grouping and Subtotals
From: "David Petersen" <david@xxxxxxxxxxxxxx>
Date: Tue, 1 Apr 2003 11:40:11 -0600
xml subtotals
I may have stumbled upon the solution after posting this message:

After the <xsl:for-each select> line, I created a $currentGroup
variable.  I then used it during the sum operation.  So far in my
testing, it appears to work.  Can anyone see anything wrong with this?

------------------------------------------------------------------------
-----------------
<xsl:key name="listofbrochures" match="RECORD" use="BrochureName" />
<xsl:template match="DATA">
<table>
<xsl:for-each select="RECORD[count(. |
key('listofbrochures',BrochureName)[1]) = 1]">
	<xsl:variable name="currentGroup" select="key('listofbrochures',
BrochureName)" />
		<tr>
			<td nowrap="true" class="dataValue">
						<xsl:value-of
select="BrochureName"/>
			</td>
			<td align="center" class="dataValue">
				<xsl:value-of
select="format-number(BrochureID,'#,##0')"/>
			</td>
			<td align="right" class="dataValue">
				<xsl:value-of
select="format-number(sum($currentGroup/./ProjectedUnits),'#,##0')"/>
			</td>
			<td align="right" class="dataValue">
				<xsl:value-of
select="format-number(sum($currentGroup/./ProjectedForActual),'#,##0')"/
>
			</td>
			<td align="right" class="dataValue">
				<xsl:value-of
select="format-number(sum($currentGroup/./ActualUnits),'#,##0')"/>
			</td>
			<td align="right" class="dataValue">
				<xsl:value-of
select="format-number(sum($currentGroup/./RemainingProjected),'#,##0')"/
>
			</td>
		</tr>
</xsl:for-each>
<tr>
<td colspan="2" class="dataValue"
align="right"><strong>Totals:</strong></td>
<td class="dataValue" align="right"><xsl:value-of
select="format-number(sum(//ProjectedUnits),'#,##0')"/></td>
<td class="dataValue" align="right"><xsl:value-of
select="format-number(sum(//ProjectedForActual),'#,##0')"/></td>
<td class="dataValue" align="right"><xsl:value-of
select="format-number(sum(//ActualUnits),'#,##0')"/></td>
<td class="dataValue" align="right"><xsl:value-of
select="format-number(sum(//RemainingProjected),'#,##0')"/></td>
</tr>
</table>
</xsl:template>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.