[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: sort by predefined order
<xsl:sort select="index-of($sortorder, @ID)"/> where <xsl:variable name="sortorder" select="for $t in tokenize(/source/sortorder, ',\s*') return xs:integer($t)"/> 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 http://www.saxonica.com/ > -----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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|