|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: sort by predefined order
2008/5/20 Michael Kay <mike@xxxxxxxxxxxx>:
> <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.
I would've tended towards that route anyway - not using sort at all.
So modifying the above a bit you get:
<xsl:key name="element-by-ID" match="element" use="@ID"/>
<xsl:for-each select="for $t in tokenize(/source/sortorder, ',\s*')
return xs:integer($t)">
<xsl:apply-templates select="key('element-by-ID', .)"/>
</xsl:for-each>
or perhaps
<xsl:apply-templates select="for $t in tokenize(/source/sortorder,
',\s*') return key('element-by-ID', xs:integer($t))"/>
--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/
|
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
|

Cart








