[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Grouping a List into A Grid Structure
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|