Subject: [xsl] Multiple Grouping & Muenchian Method From: "Steve Sze" <steveyksze@xxxxxxxxx> Date: Fri, 21 Jul 2006 14:26:35 -0400 |
Is it possible to have a group within a group. I did look at http://www.biglist.com/lists/xsl-list/archives/200101/msg00070.html but I either get a date with data from both dates or the same date for each data set.
Thank You Steve
Desire Sample Output -------------------- 07-13-2006 USA Group Name id AAA Adel 12345 AAA Barry 12346 AAA Carl 12347 BBB Dave 12345 BBB Ethel 12346 BBB Fred 12347
EUR Group Name id CCC George 24567 CCC Harold 23458 CCC Jennifer 23459
07-14-2006 USA Group Name id BBB Dave 12345 BBB Ethel 12346 BBB Fred 12347
EUR Group Name id CCC George 24567 CCC Harold 23458 CCC Jennifer 23459
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="by-date" match="entry" use="date" /> <xsl:key name="by-country" match="entry" use="country" />
<xsl:template match="/report"> <html> <head> <title/> </head> <body> <table border="1"> <xsl:variable name="break_by_date" select="//entry[key('by-date', date)]"/> <xsl:variable name="break_by_country" select="key('by-country', currency)"/> <xsl:for-each select="$break_by_date[generate-id() = generate-id(key('by-country', country)[1])]"> <tr> <td><xsl:value-of select="date"/></td> </tr> <tr> <td><xsl:value-of select="country" /></td> </tr> <tr> <td>Group</td> <td>Name</td> <td>id</td> </tr> <xsl:for-each select="key('by-country', country)"> <tr> <td><xsl:value-of select="../@type" /></td> <td><xsl:value-of select="name" /></td> <td><xsl:value-of select="id" /></td> </tr> </xsl:for-each> </xsl:for-each> </table> </body> </html> </xsl:template>
Sample XML file <report> <table> <date>07-13-2006 <group type="AAA">111111 <entry> <date>07-13-2006</date> <name>Adel</name> <country>USA</country> <id>12345</id> </entry> <entry> <date>07-13-2006</date> <name>Barry</name> <country>USA</country> <id>12346</id> </entry> <entry> <date>07-13-2006</date> <name>Carl</name> <country>USA</country> <id>12347</id> </entry> </group> <group type="BBB">111111 <entry> <date>07-13-2006</date> <name>Dave</name> <country>USA</country> <id>12345</id> </entry> <entry> <date>07-13-2006</date> <name>Ethel</name> <country>USA</country> <id>12346</id> </entry> <entry> <date>07-13-2006</date> <name>Fred</name> <country>USA</country> <id>12347</id> </entry> </group> <group type="CCC">111111 <entry> <date>07-13-2006</date> <name>George</name> <country>EUR</country> <id>24567</id> </entry> <entry> <date>07-13-2006</date> <name>Harold</name> <country>EUR</country> <id>23458</id> </entry> <entry> <date>07-13-2006</date> <name>Jennifer</name> <country>EUR</country> <id>23459</id> </entry> </group> </date> <date>07-14-2006 <group type="BBB">111111 <entry> <date>07-14-2006</date> <name>Dave</name> <country>USA</country> <id>12345</id> </entry> <entry> <date>07-14-2006</date> <name>Ethel</name> <country>USA</country> <id>12346</id> </entry> <entry> <date>07-14-2006</date> <name>Fred</name> <country>USA</country> <id>12347</id> </entry> </group> <group type="CCC">111111 <entry> <date>07-14-2006</date> <name>George</name> <country>EUR</country> <id>24567</id> </entry> <entry> <date>07-14-2006</date> <name>Harold</name> <country>EUR</country> <id>23458</id> </entry> <entry> <date>07-14-2006</date> <name>Jennifer</name> <country>EUR</country> <id>23459</id> </entry> </group> </date> </table> </report>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: RE: [xsl] extract values from a, cknell | Thread | Re: [xsl] Multiple Grouping & Muenc, Mukul Gandhi |
Re: [xsl] xsl:key() and $variables., Svante Schubert | Date | RE: [xsl] Multiple Grouping & Muenc, Jacoby, Peter R. |
Month |