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!

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()"/>
<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>
<!-- And all the others in a non-"keeping" row -->
<xsl:when test="parent::Item">
<xsl:call-template name="article0"/>
<xsl:when test="parent::Level1">
<xsl:call-template name="article1"/>
<xsl:when test="parent::Level2">
<xsl:call-template name="article2"/>
<xsl:when test="parent::Level3">
<xsl:call-template name="article3"/>
<fo:block xsl:use-attribute-sets="citation">
<fo:wrapper xsl:use-attribute-sets="title">
<!--for a given title-->
<xsl:apply-templates select="Title"/>
<xsl:apply-templates select="Person"/>
<!--and for each citation-->
<xsl:apply-templates select="current-group()" mode="format"/>

Current Thread