Each "orderspec" is an expression, and the expression can be any XQuery 
expression (for example an if/then/else):

http://www.w3.org/TR/xquery/#prod-xquery-OrderByClause

This will work for many things, but not if you want to manipulate more than the 
expression.  But you can get a long way with if/then/else.

If you want to do something more complex, then David's xdmp:value suggestion is 
a good one, where you construct a string that is your new flwor expression and 
evaluate it with xdmp:value.

-Danny

From: [email protected] 
[mailto:[email protected]] On Behalf Of David Steiner
Sent: Friday, May 22, 2009 8:51 AM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] Can an xquery order by clause be 
constructed?

You could always construct the entire for clause as a string and pass it to 
xdmp:value(...).
The MarkLogic folk probably have a better solution though.

From: [email protected] 
[mailto:[email protected]] On Behalf Of Tim Meagher
Sent: Friday, May 22, 2009 8:16 AM
To: 'General Mark Logic Developer Discussion'
Subject: [MarkLogic Dev General] Can an xquery order by clause be constructed?


Hi folks,



I would like to know if the order by clause can be programmatically 
constructed. For example, given a query such as the following:



for $el in cts:search(xdmp:directory("/SomeDir/","infinity")/SomeNode,

  cts:element-value-query(xs:QName("SomeElement"), "SomeElementValue",

  ("case-insensitive", "punctuation-insensitive", "diacritic-insensitive")))



  let $id := string($e/@ID)

  let $author := string($el/author[1])

  let $title := string($el/title[1])



  order by $id, $title, $author



  return $el



I would like to be able to programmatically construct the order clause to be 
something like "$author, $title" instead of "$id, $title, $author".



Thank you!



Tim - aaom consulting


NOTICE: This email message is for the sole use of the intended recipient(s) and 
may contain confidential and privileged information. Any unauthorized review, 
use, disclosure or distribution is prohibited. If you are not the intended 
recipient, please contact the sender by reply email and destroy all copies of 
the original message.
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to