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

RE: sort by predefined order

Subject: RE: sort by predefined order
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 20 May 2008 08:42:50 +0100
RE:  sort by predefined order
<xsl:sort select="index-of($sortorder, @ID)"/>


<xsl:variable name="sortorder" 
  select="for $t in tokenize(/source/sortorder, ',\s*') return

This isn't going to be very efficient if sortorder is a long list, in that
case you probably want to use keys to speed it up. 

Michael Kay

> -----Original Message-----
> From: marentxml [mailto:mailing.lists@xxxxxxxxxxxx] 
> Sent: 20 May 2008 07:17
> To: Xsl-List
> Subject:  sort by predefined order
> hi
> is there any way to sort elements by a predefined order? i'd 
> like to come from
> <source>
>    <sortorder>46, 21, 39, 27, 17</sortorder>
>    <elements>
>      <element ID="17"/>
>      <element ID="21"/>
>      <element ID="27"/>
>      <element ID="39"/>
>      <element ID="46"/>
>    </elements>
> </source>
> the most elegant way to
> <target>
>    <elements>
>      <element ID="46"/>
>      <element ID="21"/>
>      <element ID="39"/>
>      <element ID="27"/>
>      <element ID="17"/>
>    </elements>
> </target>
> thanks in advance for any help.
> frank

Current Thread


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.
First Name
Last Name
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.