Subject: RE: [xsl] Multiple groupings From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 27 Apr 2004 10:02:46 -0400 |
I am outputting this data to html. When I use this XSL: ... I am getting all of the PaymentType and CityName at the very top of the report. Then I get all of the records sequentially below that.
How can I break the record listing and subtitle each section? It worked fine in the text version.
For totaling, should I just use keys?
T:\ftemp>type akridge.xml <?xml version="1.0" encoding="UTF-8"?> <ArrayOfAccountLineItems> <AccountLineItem> <ID>12993</ID> <PaymentType>Credit Card</PaymentType> <SettleDate>2004-04-14T22:57:46.6230000-04:00</SettleDate> <CityName>Las Vegas</CityName> <Amount>123</Amount> </AccountLineItem> <AccountLineItem> <ID>12992</ID> <PaymentType>Cash</PaymentType> <SettleDate>2004-04-14T22:57:46.6230000-04:00</SettleDate> <CityName>New York</CityName> <Amount>123</Amount> </AccountLineItem> <AccountLineItem> <ID>12963</ID> <PaymentType>Check</PaymentType> <SettleDate>2004-04-14T22:57:51.3100000-04:00</SettleDate> <CityName>Orlando</CityName> <Amount>123</Amount> </AccountLineItem> <AccountLineItem> <ID>12962</ID> <PaymentType>Check</PaymentType> <SettleDate>2004-04-14T22:57:51.3100000-04:00</SettleDate> <CityName>New York</CityName> <Amount>123</Amount> </AccountLineItem> <AccountLineItem> <ID>12969</ID> <PaymentType>Credit Card</PaymentType> <SettleDate>2004-04-14T22:57:51.4830000-04:00</SettleDate> <CityName>Las Vegas</CityName> <Amount>123</Amount> </AccountLineItem> <AccountLineItem> <ID>12968</ID> <PaymentType>Voucher</PaymentType> <SettleDate>2004-04-14T22:57:51.4830000-04:00</SettleDate> <CityName>Orlando</CityName> <Amount>123</Amount> </AccountLineItem> <AccountLineItem> <ID>12975</ID> <PaymentType>Check</PaymentType> <SettleDate>2004-04-14T22:57:51.6400000-04:00</SettleDate> <CityName>Las Vegas</CityName> <Amount>123</Amount> </AccountLineItem> <AccountLineItem> <ID>12974</ID> <PaymentType>Check</PaymentType> <SettleDate>2004-04-14T22:57:51.6400000-04:00</SettleDate> <CityName>Orlando</CityName> <Amount>123</Amount> </AccountLineItem> <AccountLineItem> <ID>12981</ID> <PaymentType>Voucher</PaymentType> <SettleDate>2004-04-14T22:57:51.8100000-04:00</SettleDate> <CityName>New York</CityName> <Amount>123</Amount> </AccountLineItem> <AccountLineItem> <ID>12980</ID> <PaymentType>Cash</PaymentType> <SettleDate>2004-04-14T22:57:51.8100000-04:00</SettleDate> <CityName>Orlando</CityName> <Amount>123</Amount> </AccountLineItem> </ArrayOfAccountLineItems>
T:\ftemp>type akridge.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/"> <xsl:variable name="items" select="/ArrayOfAccountLineItems/AccountLineItem"/> <xsl:for-each select="$items"> <xsl:if test="generate-id(.)= generate-id($items[PaymentType=current()/PaymentType])"> <xsl:variable name="payments" select="$items[PaymentType=current()/PaymentType]"/> <xsl:text/>Payments for '<xsl:value-of select="PaymentType"/>': <xsl:text/> <xsl:for-each select="$payments"> <xsl:if test="generate-id(.)= generate-id($payments[CityName=current()/CityName])"> <xsl:text/> In city '<xsl:value-of select="CityName"/>': <xsl:text/> <xsl:for-each select="$payments[CityName=current()/CityName]"> <xsl:value-of select="concat(' ID:',ID,' Date:',SettleDate)"/> <xsl:text> </xsl:text> </xsl:for-each> <xsl:text/> Total for <xsl:value-of select="CityName"/> <xsl:text>: </xsl:text> <xsl:value-of select="sum($payments[CityName=current()/CityName]/Amount)"/> <xsl:text> </xsl:text> </xsl:if> </xsl:for-each> <xsl:text/> Total for <xsl:value-of select="PaymentType"/> <xsl:text>: </xsl:text> <xsl:value-of select="sum($payments[PaymentType=current()/PaymentType]/Amount)"/> <xsl:text> </xsl:text> </xsl:if> </xsl:for-each> </xsl:template>
</xsl:stylesheet> T:\ftemp>saxon akridge.xml akridge.xsl Payments for 'Credit Card': In city 'Las Vegas': ID:12993 Date:2004-04-14T22:57:46.6230000-04:00 ID:12969 Date:2004-04-14T22:57:51.4830000-04:00 Total for Las Vegas: 246 Total for Credit Card: 246 Payments for 'Cash': In city 'New York': ID:12992 Date:2004-04-14T22:57:46.6230000-04:00 Total for New York: 123 In city 'Orlando': ID:12980 Date:2004-04-14T22:57:51.8100000-04:00 Total for Orlando: 123 Total for Cash: 246 Payments for 'Check': In city 'Orlando': ID:12963 Date:2004-04-14T22:57:51.3100000-04:00 ID:12974 Date:2004-04-14T22:57:51.6400000-04:00 Total for Orlando: 246 In city 'New York': ID:12962 Date:2004-04-14T22:57:51.3100000-04:00 Total for New York: 123 In city 'Las Vegas': ID:12975 Date:2004-04-14T22:57:51.6400000-04:00 Total for Las Vegas: 123 Total for Check: 492 Payments for 'Voucher': In city 'Orlando': ID:12968 Date:2004-04-14T22:57:51.4830000-04:00 Total for Orlando: 123 In city 'New York': ID:12981 Date:2004-04-14T22:57:51.8100000-04:00 Total for New York: 123 Total for Voucher: 246
-- Public courses: Spring 2004 world tour of hands-on XSL instruction Each week: Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO
World-wide on-site corporate, govt. & user group XML/XSL training. G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Multiple groupings, Kenny Akridge | Thread | RE: [xsl] Multiple groupings, Kenny Akridge |
RE: [xsl] ANN: XSLT 2.0 and XPath 2, David . Pawson | Date | RE: [xsl] Multiple groupings, Kenny Akridge |
Month |