[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: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Tue, 20 May 2008 12:06:13 +0530
Re:  sort by predefined order
Below is a XSLT 2.0 solution for this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

  <xsl:output method="xml" indent="yes" />

  <xsl:template match="/">
    <xsl:variable name="x" select="source" />
        <xsl:for-each select="tokenize($x/sortorder,',')">
          <xsl:copy-of select="$x/elements/element[@ID =
normalize-space(current())]" />


On 5/20/08, marentxml <mailing.lists@xxxxxxxxxxxx> wrote:
> 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

Mukul Gandhi

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.