Can you elaborate on 'static'? This seems to work just fine:

for $x in (1,3,2,5)
order by if( fn:true() ) then $x else () ascending
return $x

Kind regards,
Geert

> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:general-
> [email protected]] Namens Michael Blakeley
> Verzonden: woensdag 27 maart 2013 21:17
> Aan: MarkLogic Developer Discussion
> Onderwerp: Re: [MarkLogic Dev General] How to program the order by
> clause in FLWOR?
>
> The order by clause has to be static. You can play some games with
simple
> cases, but for complex cases you pretty much have to build a string and
call
> xdmp:value on it. The search:search function and its resolve cousins do
this
> for you, or you can build it yourself.
>
> -- Mike
>
> On 27 Mar 2013, at 12:19 , "Tim" <[email protected]> wrote:
>
> > Hi Folks,
> >
> > Is there a simple way to program the order by clause in FLWOR to make
it
> optional based on parameters?  I have a web page that I want to sort as
> indicated by the user.
> >
> > For example, this code illustrates what I'd like to do but doesn't
work:
> >
> > let $sort-option := "a descending"
> > return
> > for $row in $rows
> > let $a := $row/a/text()
> > let $b := $row/b/text()
> > order by {if ($sort-option eq "a ascending") then $a ascending else
> $default}
> > return <tr><td>{$a}</td><td>{$b}</td></tr>
> >
> > Thanks!
> >
> > Tim Meagher
> >
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://developer.marklogic.com/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to