xsl-list
[Top] [All Lists]

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

2016-01-20 11:48:39
Rick Quatro rick(_at_)rickquatro(_dot_)com 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.

--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>