[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hi,
I have this XML:
But I want to have this:
I manage to group the items into their corresponding type using for each group. The problem is how can i group the b items according to their position with respect to the list (all first item goes together, all second item goes together, etc.).
This is what i have so far:
[xsl] Grouping a List into A Grid Structure
Subject: [xsl] Grouping a List into A Grid Structure From: Jeff Sese <jeferson.sese@xxxxxxxxxxxx> Date: Mon, 23 Jun 2008 11:20:31 +0800 |
Hi,
I have this XML:
<root> <list> <item type="a">list 1 item 1</item> <item type="b">list 1 item 2</item> </list> <list> <item type="a">list 2 item 1</item> <item type="b">list 2 item 2</item> <item type="b">list 2 item 3</item> <item type="b">list 2 item 4</item> </list> <list> <item type="a">list 3 item 1</item> <item type="b">list 3 item 2</item> <item type="b">list 3 item 3</item> </list> </root>
But I want to have this:
<root> <list> <item type="a">list 1 item 1</item> <item type="a">list 2 item 1</item> <item type="a">list 3 item 1</item> <item type="b">list 1 item 2</item> <item/> <item/> <item/> <item type="b">list 2 item 2</item> <item type="b">list 3 item 2</item> <item/> <item type="b">list 2 item 3</item> <item type="b">list 3 item 3</item> <item/> <item type="b">list 2 item 4</item> <item/> </list> </root>
I manage to group the items into their corresponding type using for each group. The problem is how can i group the b items according to their position with respect to the list (all first item goes together, all second item goes together, etc.).
This is what i have so far:
<xsl:template match="root"> <xsl:for-each-group select="list/item" group-by="@type"> <xsl:choose> <xsl:when test="current-grouping-key()='a'"> <xsl:copy-of select="current-group()"/> </xsl:when> <xsl:otherwise> <!-- grouping logic here --> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </xsl:template>
Thanks in advance, -- Jeff
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] the future of xslt, bryan rasmussen | Thread | Re: [xsl] Grouping a List into A Gr, Florent Georges |
RE: [xsl] the future of xslt, Michael Kay | Date | [no subject], Unknown |
Month |