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

Re: grouping, sorting, splitting

Subject: Re: grouping, sorting, splitting
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 18 Apr 2005 11:26:02 +0100
first sort and then group
If you need to sort and group it's much easier to program (and to think
about) if you do it in two steps, first sort and then group, eiether
doing it as two separate stylesheets or using a node-set extension
function which would allow you to do the two passes in one stylesheet.

Normally, after having done 

<xsl:for-each select="key('days', @date)[position() mod 3 = 1]">

You'd pick up the two following siblings by doing
select="following-sibling::*[position() &lt; 3]"

But axis navigation always refers to the source tree not to the sorted
node list constructed by xsl:sort so this doesn't work here.
If you do it in two passes, then on the second pass the sorted list is
reflected in the input so this would work.

If you do need to do it in one pass then as your sort criterion is
pretty simple I think you can do it in this case, you just can't easily
manke use of the key that has indexed your elements, you need to search
the doc again, something like

<xsl:for-each select="key('days', @date)[position() mod 3 = 1]">
<tr>
 <xsl:for-each
select=".|following-sibling::entry[@date=current()/@date][position()
&lt; 3]">
  <td>...

This relies on teh fact that sorting is stable: entries with the same
date will be reported in the same order as they appear in the original
document.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.