Subject: Re: [xsl] regexs, grouping (?) and XSLT2?|
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Mon, 9 Aug 2004 00:19:21 -0400
I think you're trying to solve several problems at the same time here. It
fails my 10-minute rule: I never spend more than ten minutes answering a
question on this list.
Essentially both the para output and the list of citations are grouping problems that can be tackled using xsl:for-each-group, probably using group-adjacent. You may need to write a function that calculates the grouping key. The suffix "a", "b" etc can be obtained using xsl:number. It may be simplest to start by generating a copy of the bibliography in which the list of authors (Doe and Jones) and the year/serial (1999b) appear as additional computed child elements or attributes, and then working with this copy.
<xsl:template match="mods:modsCollection"> <xsl:for-each-group select="mods:mods" group-by="mods:name/mods:namePart[@type='family']"> <author> <xsl:attribute name="key"> <xsl:value-of select="current-grouping-key()"/> </xsl:attribute> <xsl:for-each-group select="current-group()" group-by="substring(mods:originInfo/mods:dateIssued,1,4)"> <year> <xsl:attribute name="key"> <xsl:value-of select="current-grouping-key()"/> </xsl:attribute> <xsl:copy-of select="current-group()"/> </year> </xsl:for-each-group> </author> </xsl:for-each-group> </xsl:template>
<author key="Jones"> <year key="1999"> <mods xmlns="http://www.loc.gov/mods/v3" ID="three"> etc.