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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--