Subject: RE: order-by vs xsl:sort
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 29 Apr 2005 14:00:28 +0100
|
> Not really. It models it as a sequence of integers of length M*N and
> calculates the sort key (and data needed for the result) by
> calculating
> the equivalent indexes into the original sequences using mod and idiv.
>
> given the general 2 variable case:
>
>
> for $i in $is, $j in $js
> order by f($i,$j)
> return
> g($i,$j)
>
> for some functions f and g then I think you can always replace this by
>
> let $ci :=count($is) return
> let $cj :=count($js) return
> for $n in (0 to $ci * $cj)
> let $i :=$is[$n mod $ci)+1]
> let $j := $js[($n idiv $ci) +1]
> order by f($i, $j)
> return
> g($i,$j)
>
> and once you have just a single for and order by, converting
> that to xsl
> for-each and sort is just syntax.
>
Nice result. Perhaps I can get rid of those horrible tuples in my
implementation!
Michael Kay
http://www.saxonica.com/
|