RE: [xsl] Splitting already-grouped output into two parts

Subject: RE: [xsl] Splitting already-grouped output into two parts
From: cknell@xxxxxxxxxx
Date: Tue, 27 Dec 2005 15:14:19 -0500
What are you counting when you say "half the data"? Does that mean half the <record> elements or something else?
Charles Knell
cknell@xxxxxxxxxx - email

-----Original Message-----
From:     Asparagirl <asparagirl@xxxxxxx>
Sent:     Tue, 27 Dec 2005 14:18:43 -0500
To:       <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:  [xsl] Splitting already-grouped output into two parts

Hi.  I'm having problems with XSLT and was hoping someone here could help me
troubleshoot or offer advice.  

Here's a sample of my XML (edited to remove superfluous stuff):

=========================================== <RECORDS>
      <name>Anderson, Bob</name>
      <name>Anderson, Bob</name>
      <name>Brock, Jessica</name>
      <name>Carlisle, Jen</name>
      <name>Carlisle, Jen</name>
I'm using the Muenchian Method to group my results by surname.  Here's my
stylesheet (again, edited to remove lots of superfluous stuff):

=========================================== <xsl:key name="videos-by-surname" match="RECORD" use="name" />

<xsl:template match="RECORDS">
<xsl:for-each select="RECORD[count(. | key('videos-by-surname', name)[1]) = 1]">

<xsl:sort select="name" />
<xsl:element name="h3"><xsl:value-of select="name" />:</xsl:element>
<xsl:element name="ul">
   <xsl:for-each select="key('videos-by-surname', name)">
      <xsl:sort select="AssetID" />
      <xsl:element name="li"><xsl:value-of select="AssetID" /></xsl:element>

So far, it all works fine; the output looks sort of like this:

=========================================== <h3>Anderson, Bob:</h3>

<h3>Brock, Jessica:</h3>

<h3>Carlisle, Jen:</h3>
But what I'd like to do is take this grouped output and divide it into two
roughly-equally sized groups.  That is, I'd like to create two DIV's, each
with about half the data in them.  I do not want to use tables.  And I don't
want to break up the UL's/LI's across the columns; each of the tops of the
columns need to start with a new H3 name and its associated grouping, not be
continued from the previous column.

So, how can I count up all the resulting H3's/names from my Muenchian
grouping, divide it by two, and then wrap each of the two new groups in
DIV's?  It's likely something simple, but I'm flummoxed.  Please help a
fuzzy newbie!  (Explanations using small words would be much appreciated.)


- Brooke Schreier Ganz

Current Thread