Re: [xsl] Different behaviour for the first item in a for-each-group

Subject: Re: [xsl] Different behaviour for the first item in a for-each-group
From: "Mark Wilson" <mark@xxxxxxxxxxxx>
Date: Sat, 31 Oct 2009 19:31:41 -0700
Hi Ken,
That seems to be it. I checked 28 of the 200+ pages and all was OK.

Sorry I did not make it clear from the start. Also, somewhere along the line an un-needed for-each crept in.

By the way, you have helped with this very same function three times now over the past year. For the record, here is the actual correct template.

Thanks again.
Happy Halloween!
Mark

xsl:template name="format-article">
<xsl:for-each-group select="../Article" group-by="Title">
<xsl:sort select="Title"/>
<xsl:sort select="Year"/>
<xsl:sort select="IssueNumber" data-type="number"/>
<xsl:sort select="Page"/>
<xsl:variable name="group-position" select="position()"/>
<fo:table-row>
<xsl:if test="position()=1 and $group-position=1">
<!--then at the very first of the sorted population-->
<xsl:attribute name="keep-with-previous">always</xsl:attribute>
</xsl:if>
<!-- And all the others in a non-"keeping" row -->
<fo:table-cell>
<fo:block>
<xsl:choose>
<xsl:when test="parent::Item">
<xsl:call-template name="article0"/>
</xsl:when>
<xsl:when test="parent::Level1">
<xsl:call-template name="article1"/>
</xsl:when>
<xsl:when test="parent::Level2">
<xsl:call-template name="article2"/>
</xsl:when>
<xsl:when test="parent::Level3">
<xsl:call-template name="article3"/>
</xsl:when>
</xsl:choose>
<fo:block xsl:use-attribute-sets="citation">
<fo:wrapper xsl:use-attribute-sets="title">
<!--for a given title-->
<xsl:apply-templates select="Title"/>
</fo:wrapper>
<xsl:apply-templates select="Person"/>
<!--and for each citation-->
<xsl:apply-templates select="current-group()" mode="format"/>
</fo:block>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each-group>
</xsl:template>


Current Thread