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

RE: sort / unsort

Subject: RE: sort / unsort
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Fri, 9 Aug 2002 09:56:54 +0100
sort and unsort
XSLT 2.0 solution:

<xsl:sort-key name="sk1">
  <xsl:sort select="."/>
</xsl:sort-key>

<xsl:variable name="first-five"
    select="subsequence(sort($input, 'sk1'), 1, 5)"/>

<xsl:copy-of select="($first-five,
                      $input except $first-five)"/>

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> McKeever, Marty
> Sent: 08 August 2002 20:44
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  sort / unsort
> 
> 
> Interesting problem, i've been wracking my brain to solve.
> 
> From a group of nodes, output the first five in a sorted 
> order, and dump the remainder in document order.
> 
> that is:
> 	<foo>I</foo>
> 	<foo>F</foo>
> 	<foo>E</foo>
> 	<foo>D</foo>
> 	<foo>A</foo>
> 	<foo>C</foo>
> 	<foo>B</foo>
> 	<foo>H</foo>
> 	<foo>G</foo>
> 
> would output:
> 	<foo>A</foo>
> 	<foo>B</foo>
> 	<foo>C</foo>
> 	<foo>D</foo>
> 	<foo>E</foo>
> 	<foo>I</foo>
> 	<foo>F</foo>
> 	<foo>H</foo>
> 	<foo>G</foo>
> note that only the first 5 are sorted.
> the remainder are in document order - less the 5 sorted items.
> 
> TIA,
> Marty
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 


 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.