[xsl] Another grouping question

Subject: [xsl] Another grouping question
From: "James Cummings" <cummings.james@xxxxxxxxx>
Date: Mon, 25 Feb 2008 13:53:37 +0000
Ok,  I've finally had time to play with xsl:for-each-group again and
had another question.

Throughout my collection() of documents there are some tei:seg
elements with a @type of 'dMeeting' and a @subtype of 'C'.

I can get a nice list of these that looks like:
<item>25 --  met with mr foo </item>
<item>20 --  met with ms foo </item>
<item>17 --  met with miss blort </item>

By doing something like:
===========
<xsl:variable name="docs"  select="collection('../../working/xml/files.xml')"/>
<xsl:variable name="dMeetingC"
select="$docs//tei:text//tei:seg[@type="dMeeting"][@subtype='C']"/>
<xsl:variable name="norm-dMeetingC"
select="$dMeetingC/normalize-space(lower-case(.))"/>


<div>
  <head>Frequency List</head>
  <list type="unordered">
    <xsl:for-each-group select="$norm-dMeetingC" group-by=".">
      <xsl:sort select="count(current-group())" data-type="number"
order="descending"/>
      <xsl:sort select="current-grouping-key()"/>
      <xsl:variable name="count" select="count(current-group())"/>
      <xsl:variable name="date">
        <!-- what I want to get here is the
./ancestor::tei:p[@type='dDay']//tei:date[1]/substring-before(@when,
          '-') from the current tei:seg to form a list of dates on
which the meeting took place.  all of these will be
         inside a tei:p of this @type. I eventually what to turn each
of these into a link to that paragraph. -->
        </xsl:variable>
      <item>
        <xsl:value-of select="concat($count, ' --  ',
          current-grouping-key(), '  -- ', $date)"/>
        </item>
    </xsl:for-each-group>
    </list>
</div>
===========

Is it because I've normalize-space()'d that I can't then traverse up
from the node to get the ancestor::tei:p?  What I want to end up with
instead is something like:

<item>25 --  met with mr foo (1804-01-12, 1804-04-15, 1805-03-17,
1805-12-25, etc. etc.) </item>
<item>20 --  met with ms foo (1804-01-13, 1804-04-16, 1805-03-18,
1805-12-26, etc. etc.)</item>
<item>17 --  met with miss blort (1804-01-10, 1804-04-12, 1805-03-14,
1805-12-23, etc. etc.)</item>

(though I'll eventually hide them with css, with an optional display,
and turn them into links to the text.)

How in the middle of an xsl:for-each-group do I traverse up the
hierarchy, yet maintain the comparison in a normalize-space()'d
lower-case() kind of manner?  Suggestions for what should go in the
date variable?

Many many thanks,

-James

Current Thread