[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: regexs, grouping (?) and XSLT2?

Subject: Re: regexs, grouping (?) and XSLT2?
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Mon, 9 Aug 2004 00:19:21 -0400
Re:  regexs
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"
		      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>

This gives me output like:

<author key="Jones">
   <year key="1999">
      <mods xmlns="http://www.loc.gov/mods/v3" ID="three">
	etc.

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?

Bruce

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.