[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] 3 level Muenchian Grouping ?


Subject: Re: [xsl] 3 level Muenchian Grouping ?
From: "Manish Rambabu" <manishrb@xxxxxxxxxxx>
Date: Tue, 20 Jan 2004 22:12:42 +0000

Ken,

Thanks much for the quick response. I realised the solution below ignores the group with Order Date "02/01/03" for category "1" and Type "AX".

Manish




From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] 3 level Muenchian Grouping ?
Date: Tue, 20 Jan 2004 15:31:10 -0500
MIME-Version: 1.0
X-Sender: crane@xxxxxxxxxxxx
Received: from mc9-f33.hotmail.com ([65.54.166.40]) by mc9-s16.hotmail.com with Microsoft SMTPSVC(5.0.2195.6824); Tue, 20 Jan 2004 12:35:15 -0800
Received: from biglist.com ([216.223.208.41]) by mc9-f33.hotmail.com with Microsoft SMTPSVC(5.0.2195.6824); Tue, 20 Jan 2004 12:34:51 -0800
Received: from localhost (daemon@localhost)by biglist.com (8.8.8/8.8.5/BL-2) with SMTP id PAA13884;Tue, 20 Jan 2004 15:32:41 -0500 (EST)
Received: by biglist.com (km_bm v1.13); Tue, 20 Jan 2004 15:32:00 -0500
Received: (from majordom@localhost)by biglist.com (8.8.8/8.8.5/BL-2) id PAA13854;Tue, 20 Jan 2004 15:31:56 -0500 (EST)
X-Message-Info: TiNwL5K19MGcUE3L10DDQpwbL3eG2n5OTOowlL1ODV8=
Message-Id: <5.2.0.9.0.20040120152900.014663b8@xxxxxxxxxxxx>
X-Mailer: QUALCOMM Windows Eudora Version 5.2.0.9
In-Reply-To: <BAY2-F86LSAQV6uPDVn0000da2f@xxxxxxxxxxx>
X-MailLoop: 1
Return-Path: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
X-OriginalArrivalTime: 20 Jan 2004 20:34:51.0976 (UTC) FILETIME=[DB0D9480:01C3DF94]


At 2004-01-20 19:45 +0000, Manish Rambabu wrote:
Below are the XML and XSL files where I am able to do a 2 level Muenchian grouping. Can someone please shed some light on how I can group further by ORDER_DATE and calculate a subTotal for each Order Date. I know I need to generate a 3rd concatenated key.

Or ... you could use a different method. When doing multiple-level groups I find the variable-based grouping methodology to be a lot easier to work with.


An example is below (text only, you can add the markup you need).

I hope this helps.

...................... Ken


T:\ftemp>type manish.xml <?xml version="1.0" ?> <ORDER_DETAILS> <CUSTOMER> <NAME>John Smith</NAME> <SITE> <ADDRESS> <STREET>111 Freedom Drive</STREET> <CITY>Chicago</CITY> <STATE>IL</STATE> <ZIP>60111</ZIP> </ADDRESS> <ACCOUNT_NUMBER>12222</ACCOUNT_NUMBER> <CATEGORY>1</CATEGORY> <TYPE>AX</TYPE> <ORDER_DATE>01/01/03</ORDER_DATE> <PRICE>21.99</PRICE> </SITE> </CUSTOMER>

<CUSTOMER>
 <NAME>Mary Jane</NAME>
 <SITE>
 <ADDRESS>
  <STREET>16 Penn Ave NW</STREET>
  <CITY>Washington DC</CITY>
  <STATE>DC</STATE>
  <ZIP>20333</ZIP>
 </ADDRESS>
 <ACCOUNT_NUMBER>67889</ACCOUNT_NUMBER>
 <CATEGORY>1</CATEGORY>
 <TYPE>AX</TYPE>
 <ORDER_DATE>02/01/03</ORDER_DATE>
 <PRICE>11.98</PRICE>
 </SITE>
</CUSTOMER>

<CUSTOMER>
 <NAME>Mark Anderson</NAME>
 <SITE>
 <ADDRESS>
  <STREET>175 Commerce Park</STREET>
  <CITY>San Francisco</CITY>
  <STATE>CA</STATE>
  <ZIP>93311</ZIP>
 </ADDRESS>
 <ACCOUNT_NUMBER>66145</ACCOUNT_NUMBER>
 <CATEGORY>1</CATEGORY>
 <TYPE>BX</TYPE>
 <ORDER_DATE>01/31/03</ORDER_DATE>
 <PRICE>11.98</PRICE>
 </SITE>
</CUSTOMER>

<CUSTOMER>
 <NAME>Chris Dewalt</NAME>
 <SITE>
 <ADDRESS>
  <STREET>1344 Washington Park</STREET>
  <CITY>San Francisco</CITY>
  <STATE>CA</STATE>
  <ZIP>93344</ZIP>
 </ADDRESS>
 <ACCOUNT_NUMBER>000234</ACCOUNT_NUMBER>
 <CATEGORY>1</CATEGORY>
 <TYPE>BX</TYPE>
 <ORDER_DATE>01/31/03</ORDER_DATE>
 <PRICE>41.00</PRICE>
 </SITE>
</CUSTOMER>

<CUSTOMER>
 <NAME>Sam Dewar</NAME>
 <SITE>
 <ADDRESS>
  <STREET>123 Hunington Way</STREET>
  <CITY>Mclean</CITY>
  <STATE>VA</STATE>
  <ZIP>20121</ZIP>
 </ADDRESS>
 <ACCOUNT_NUMBER>100988</ACCOUNT_NUMBER>
 <CATEGORY>2</CATEGORY>
 <TYPE>BX</TYPE>
 <ORDER_DATE>01/31/03</ORDER_DATE>
 <PRICE>11.00</PRICE>
 </SITE>
</CUSTOMER>
 <CUSTOMER>
 <NAME>Peter Henderson</NAME>
 <SITE>
 <ADDRESS>
  <STREET>421 RidgeTop Place</STREET>
  <CITY>Sarosota</CITY>
  <STATE>MI</STATE>
  <ZIP>10121</ZIP>
 </ADDRESS>
 <ACCOUNT_NUMBER>800223</ACCOUNT_NUMBER>
 <CATEGORY>1</CATEGORY>
 <TYPE>AX</TYPE>
 <ORDER_DATE>01/01/03</ORDER_DATE>
 <PRICE>83.00</PRICE>
 </SITE>
</CUSTOMER>
</ORDER_DETAILS>

T:\ftemp>type manish.xsl
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="ORDER_DETAILS">

<xsl:variable name="custs" select="CUSTOMER/SITE"/>
<xsl:for-each select="$custs">
<xsl:if test="generate-id(.)=
generate-id($custs[CATEGORY=current()/CATEGORY])">
<xsl:text/>Category: <xsl:value-of select="CATEGORY"/><xsl:text>
</xsl:text>
<xsl:variable name="cats" select="$custs[CATEGORY=current()/CATEGORY]"/>
<xsl:for-each select="$cats">
<xsl:if test="generate-id(.)=
generate-id($cats[TYPE=current()/TYPE])">
<xsl:text/>Type: <xsl:value-of select="TYPE"/><xsl:text>
</xsl:text>
<xsl:variable name="types" select="$cats[TYPE=current()/TYPE]"/>
<xsl:if test="generate-id(.)=
generate-id($types[ORDER_DATE=current()/ORDER_DATE])">
<xsl:text/>Order Date: <xsl:value-of select="ORDER_DATE"/><xsl:text>
</xsl:text>
<xsl:for-each select="$types[ORDER_DATE=current()/ORDER_DATE]">
<xsl:if test="position()>1">,</xsl:if>
<xsl:value-of select="../NAME"/>
</xsl:for-each><xsl:text>
</xsl:text>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:template>


</xsl:stylesheet>

T:\ftemp>saxon manish.xml manish.xsl
<?xml version="1.0" encoding="utf-8"?>Category: 1
Type: AX
Order Date: 01/01/03
John Smith,Peter Henderson
Type: BX
Order Date: 01/31/03
Mark Anderson,Chris Dewalt
Category: 2
Type: BX
Order Date: 01/31/03
Sam Dewar

T:\ftemp>rem Done!


-- North America (Washington, DC): 3-day XSLT/2-day XSL-FO 2004-03-15 - (San Francisco, CA): 3-day XSLT/2-day XSL-FO 2004-03-22 Asia (Hong Kong, China): 3-day XSLT/2-day XSL-FO 2004-05-17 Europe (Bremen, Germany): 3-day XSLT/2-day XSL-FO 2004-05-24 Instructor-led on-site corporate, government & user group training for XSLT and XSL-FO world-wide: please contact us for the details

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


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


_________________________________________________________________
There are now three new levels of MSN Hotmail Extra Storage! Learn more. http://join.msn.com/?pgmarket=en-us&page=hotmail/es2&ST=1



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




Current Thread
Keywords