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.
binding a variable in outer loop is giving the group position with
respect to outer loop. But I need the position with respect to inner
loop.
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/
--~------------------------------------------------------------------
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>
--~--