|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: position behavior in nested grouping
Ganesh Babu N wrote:
I need to find out the starting group or group[1] in the inner loop so that i can append <section-head> to that. I think you need to reorganize your grouping code to achieve the output you want. Try whether the following does what you want: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output indent="yes"/> <xsl:template match="articles"> <sections> <section-title>Contents</section-title> <xsl:for-each-group select="row" group-by="tokenize(col[2], '\|')[1]"> <xsl:choose> <xsl:when test="contains(col[2], '|')"> <xsl:variable name="outer-key" select="current-grouping-key()"/> <xsl:for-each-group select="current-group()" group-by="tokenize(col[2], '\|')[2]"> <section> <xsl:if test="position() eq 1"> <section-head><xsl:value-of select="$outer-key"/></section-head> </xsl:if> <section-subhead><xsl:value-of select="current-grouping-key()"/></section-subhead> <xsl:apply-templates select="current-group()"/> </section> </xsl:for-each-group> </xsl:when> <xsl:otherwise> <section> <section-head><xsl:value-of select="current-grouping-key()"/></section-head> <xsl:apply-templates select="current-group()"/> </section> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </sections> </xsl:template> <xsl:template match="row">
<para>
<page><xsl:value-of select="col[3]"/></page>
</para>
</xsl:template>
</xsl:stylesheet>In your original stylesheet you end up with three groups in the outer grouping and then the inner grouping simply has only one group for each of the (last two) groups in the outer grouping. -- Martin Honnen http://msmvps.com/blogs/martin_honnen/
|
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
|






