[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hi Andrew,
At 04:29 PM 1/2/2004, you wrote:
Cool.
I'm unsure of what you mean by needing "redundant grouping".
But I can give a couple of hints on how to proceed. If you're using keys to retrieve your nodes when grouped, as you probably know
<xsl:key name="users-by-state" match="user" use="state"/>
will let you retrieve all the <user> elements with a given state as the value of a <state> element child.
Similarly, providing each <user> has just one state and one game, you can create a compound key
<xsl:key name="users-by-state-game" match="user" use="concat(state, game)"/>
which will get you all the users that contain a given state/game combination.
To handle what might be the "redundant grouping" problem you allude to, you might also find a key useful to retrieve all the states represented for a given game:
<xsl:key name="state-by-game" match="state" use="../game"/>
This will give you a way to traverse over the states for each game (the first level of your grouping); within this traversal (of course, you'll have to de-duplicate these sets of nodes as you go, in the usual way), you can use the compound key to get the particular users for each state/game.
I hope that's a help. Ask again if I'm being too sketchy. Definitely consult http://www.jenitennison.com under "grouping" if you haven't already; a search for "XSLT two-level grouping" might also turn something up.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl] Nested grouping question
Subject: Re: [xsl] Nested grouping question From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Fri, 02 Jan 2004 17:51:49 -0500 |
Hi Andrew,
At 04:29 PM 1/2/2004, you wrote:
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.
Cool.
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.
I'm unsure of what you mean by needing "redundant grouping".
But I can give a couple of hints on how to proceed. If you're using keys to retrieve your nodes when grouped, as you probably know
<xsl:key name="users-by-state" match="user" use="state"/>
will let you retrieve all the <user> elements with a given state as the value of a <state> element child.
Similarly, providing each <user> has just one state and one game, you can create a compound key
<xsl:key name="users-by-state-game" match="user" use="concat(state, game)"/>
which will get you all the users that contain a given state/game combination.
To handle what might be the "redundant grouping" problem you allude to, you might also find a key useful to retrieve all the states represented for a given game:
<xsl:key name="state-by-game" match="state" use="../game"/>
This will give you a way to traverse over the states for each game (the first level of your grouping); within this traversal (of course, you'll have to de-duplicate these sets of nodes as you go, in the usual way), you can use the compound key to get the particular users for each state/game.
I hope that's a help. Ask again if I'm being too sketchy. Definitely consult http://www.jenitennison.com under "grouping" if you haven't already; a search for "XSLT two-level grouping" might also turn something up.
Cheers, Wendell
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Nested grouping question, Andrew Kirkpatrick | Thread | RE: [xsl] Nested grouping question, Michael Kay |
RE: [xsl] anyway obvious way to spe, Ray Tayek | Date | RE: [xsl] Nested grouping question, Michael Kay |
Month |
Keywords