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

Sorting and grouping

Subject: Sorting and grouping
From: Navratil Zdenek <z.navratil@xxxxxxxxxxxx>
Date: Tue, 30 Oct 2001 10:33:26 +0100
zdenek navratil
Hi,
can someone help me with the following problem?

I have an unordered list of items: 
<list>
    <item at="...">
        ...
    </item>
    ...
    <item at="...">
        ...
    </item>
</list>

I want to sort this list by an 'at' attribute and then display these
sorted items in groups. 
Each group should consist of a fixed number (let's say 5) of items. I
can solve this problem 
only by first sorting the list into a temporary .xml file and then use
this file for grouping.
What's even worse, I'am not able to handle the problem in one single xsl
transformation file.

To be more specific, one can't do it in one pass like this:
        <xsl:apply-templates select="item">
            <xsl:sort select="@at" order="descending"/>
        </xsl:apply-templates>
	....
        <xsl:template match="item[(position() mod 5) = 1]">
            <xsl:variable name="group"
select=".|following::item[position() &lt; 5]"/>
because last 'select' selects following items in document order (not in
sorted order).

Is there a way to solve that without creating a temporary file?

Thank you for your help.
 Zdenek

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.