Re: [xsl] regexs, grouping (?) and XSLT2?

Subject: Re: [xsl] regexs, grouping (?) and XSLT2?
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Mon, 9 Aug 2004 00:19:21 -0400
On Aug 8, 2004, at 6:45 PM, Michael Kay wrote:

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.

Fair enough. Anything to get me pointed in the right direction is appreciated. Let me just see if I understand the following:

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.

So something like this to start?

<xsl:template match="mods:modsCollection">
  <xsl:for-each-group select="mods:mods"
      <xsl:attribute name="key">
	<xsl:value-of select="current-grouping-key()"/>
      <xsl:for-each-group select="current-group()"
	  <xsl:attribute name="key">
	    <xsl:value-of select="current-grouping-key()"/>
	  <xsl:copy-of select="current-group()"/>

This gives me output like:

<author key="Jones">
   <year key="1999">
      <mods xmlns=""; ID="three">

The problem is that the author key only captures the first name element. Is this why you say I may need to "write a function that calculates the grouping key"? Any further hints on how to do this?


Current Thread