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

Re: [xsl] for-each-group - only get elements in each group


Subject: Re: [xsl] for-each-group - only get elements in each group
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 20 Jan 2016 17:48:35 -0000

Rick Quatro rick@xxxxxxxxxxxxxx wrote:


<xsl:template match="Cases"> <xsl:for-each-group select="Story" group-by="Category"> <category><xsl:copy-of select="current-grouping-key()"/></category> <xsl:apply-templates select="Case"/> </xsl:for-each-group> </xsl:template>

If you use
<xsl:for-each-group select="Story/Category" group-by=".">
<category><xsl:copy-of
select="current-grouping-key()"/></category>
<xsl:apply-templates select="current-group()/following-sibling::Case[1]"/>
</xsl:for-each-group>


then I think, for your sample, you will get the wanted result. But I am not sure how you want to relate "Category" and "Case" elements.


Current Thread