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
