Re: [xsl] grouping/position problem

Subject: Re: [xsl] grouping/position problem
From: Bruce D'Arcus <bdarcus@xxxxxxxxx>
Date: Fri, 22 Apr 2005 21:05:28 -0400
OK, I'm making some progress. I now correctly handle the position() values for the inner (author-year) group.

However, I still can't figure out how to get the author-shorten variable to yield true if there is more than one node in the bib:grouping-key(.) group AND the node in question is not the first in the group. So, it'd yield false if there is only one node in an author group, or if it's the first in a multiple node group. Help?

<xsl:template match="mods:modsCollection" mode="sort_author-year">
<xsl:variable name="bibrefs" select="mods:mods"/>
<xsl:for-each-group select="$bibrefs" group-by="bib:grouping-key(.)">
<xsl:sort select="current-grouping-key()"/>
<!-- my problem is the below variable; I was trying to figure out how to couple the count of the group with a count of the preceding nodes within the group, but I couldn't figure this out. Not sure it's even possible. -->
<xsl:variable name="author-shorten" as="xs:boolean"
select="count(current-group()) > 1"/>
<xsl:for-each-group select="current-group()" group-by="bib:year(.)">
<xsl:sort select="current-grouping-key()" />
<xsl:for-each select="current-group()">
<xsl:variable name="year">
<xsl:value-of select="current-grouping-key()"/>
<xsl:if test="last() > 1">
<xsl:number value="position()" format="a"/>
</xsl:if>
</xsl:variable>
<xsl:apply-templates select="mods:titleInfo">
<xsl:with-param name="year" select="$year"/>
<xsl:with-param name="author-shorten" select="$author-shorten"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:for-each-group>
</xsl:for-each-group>
</xsl:template>


Current Thread