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

RE: [xsl] Nested grouping question


Subject: RE: [xsl] Nested grouping question
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 2 Jan 2004 23:43:55 -0000

This looks like a fairly standard grouping problem. You haven't really
made it clear what you've tried and why you're stuck - are you already
using Muenchian grouping, as described at
www.jenitennison.com/xslt/grouping, or are you a raw beginner? 

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Andrew Kirkpatrick
> Sent: 02 January 2004 21:30
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Nested grouping question
> 
> 
> Hi,
> I've been grappling with this for a while and hope someone 
> can offer some suggestions.
> 
> I've got an XML file organized in one way that I'm trying to 
> convert to match the organization of other files that I deal 
> with.  I want the file hierarchy to be:
> 
> <game>
>     <state>
>         <user/>
>     </state>
> </game>
> 
> There are many games, states, and users.
> 
> The file that I'm trying to convert is organized by user.  I 
> can do grouping to determine the states and games, but it 
> seems like I need to do redundant grouping to do the 
> conversion.  Has anyone does anything similar?  I've got 
> samples of the input XML and the desired XML below.  Any 
> suggestions are appreciated...
> 
> Thanks in advance,
> AWK
> 
> 
> INPUT XML:
> <?xml version="1.0" encoding="UTF-8"?>
> <report>
>     <user>
>         <name>Bill</name>
>         <state>MT</state>
>         <game>Halo</game>
>     </user>
>     <user>
>         <name>Joe</name>
>         <state>NJ</state>
>         <game>Halo</game>
>     </user>
>     <user>
>         <name>Joe</name>
>         <state>NJ</state>
>         <game>PGR 2</game>
>     </user>
>     <user>
>         <name>Joe</name>
>         <state>MT</state>
>         <game>Halo</game>
>     </user>
>     <user>
>         <name>Jim</name>
>         <state>AZ</state>
>         <game>PGR 2</game>
>     </user>
>     <user>
>         <name>Bill</name>
>         <state>IN</state>
>         <game>XIII</game>
>     </user>
>     <user>
>         <name>Sue</name>
>         <state>IN</state>
>         <game>Halo</game>
>     </user>
>     <user>
>         <name>Kim</name>
>         <state>AZ</state>
>         <game>PGR 2</game>
>     </user>
>     <user>
>         <name>Pat</name>
>         <state>AZ</state>
>         <game>XIII</game>
>     </user>
>     <user>
>         <name>Ed</name>
>         <state>AZ</state>
>         <game>PGR 2</game>
>     </user>
>     <user>
>         <name>Neo</name>
>         <state>MT</state>
>         <game>Halo</game>
>     </user>
>     <user>
>         <name>Mary</name>
>         <state>IN</state>
>         <game>Halo</game>
>     </user>
>     <user>
>         <name>Jen</name>
>         <state>MT</state>
>         <game>XIII</game>
>     </user>
>     <user>
>         <name>Thor</name>
>         <state>NJ</state>
>         <game>XIII</game>
>     </user>
> </report>
> 
> 
> DESIRED OUTPUT XML:
> <?xml version="1.0"?>
> <report>
>   <game title="Halo">
>     <state name="MT">
>         <user name="Bill"/>
>         <user name="Joe"/>
>         <user name="Neo"/>
>     </state>
>     <state name="NJ">
>         <user name="Joe"/>
>     </state>
>     <state name="IN">
>         <user name="Sue"/>
>     <user name="Mary"/>
>     </state>
>   </game>
>   <game title="PGR 2">
>     <state name="AZ">
>         <user name="Jim"/>
>         <user name="Kim"/>
>         <user name="Ed"/>
>     </state>
>     <state name="NJ">
>         <user name="Joe"/>
>     </state>
>   </game>
>   <game title="XIII">
>     <state name="MT">
>         <user name="Jen"/>
>     </state>
>     <state name="NJ">
>         <user name="Thor"/>
>     </state>
>     <state name="IN">
>         <user name="Bill"/>
>     </state>
>     <state name="AZ">
>         <user name="Pat"/>
>     </state>
>   </game>
> </report>
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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



Current Thread
Keywords
xml