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

RE: Splitting already-grouped output into two parts

Subject: RE: Splitting already-grouped output into two parts
From: cknell@xxxxxxxxxx
Date: Tue, 27 Dec 2005 15:14:19 -0500
splitting videos
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:   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>
<RECORD>
      <name>Anderson, Bob</name>
      <AssetID>1426419</AssetID>
</RECORD>
<RECORD>
      <name>Anderson, Bob</name>
      <AssetID>1440105</AssetID>
</RECORD>
<RECORD>
      <name>Brock, Jessica</name>
      <AssetID>1429062</AssetID>
</RECORD>
<RECORD>
      <name>Carlisle, Jen</name>
      <AssetID>1426278</AssetID>
</RECORD>
<RECORD>
      <name>Carlisle, Jen</name>
      <AssetID>1436229</AssetID>
</RECORD>
<RECORDS>
=========================================== 
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>
   </xsl:for-each>
</xsl:element>

</xsl:for-each>
</xsl:template>
=========================================== 
So far, it all works fine; the output looks sort of like this:

=========================================== <h3>Anderson, Bob:</h3>
<ul>
  <li>1426419</li>
  <li>1440105</li>
</ul>

<h3>Brock, Jessica:</h3>
<ul>
   <li>1429062</li>
</ul>

<h3>Carlisle, Jen:</h3>
<ul>
   <li>1426278</li>
   <li>1436229</li>
</ul>
=========================================== 
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.)

Thanks!


- Brooke Schreier Ganz

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.