ahn-ens-lyon / synopsx

Full XML corpus publishing system using BaseX XML database
Other
7 stars 11 forks source link

sorting rises an error if there is no key 'sorting' #61

Open emchateau opened 9 years ago

emchateau commented 9 years ago

The current sorting mechanism rise an error when there is no key 'sorting' in the request.

for $content in $contents
  order by (: @see http://jaketrent.com/post/xquery-dynamic-order/ :)
    if ($order = 'descending') then map:get($content, $sorting) else () ascending,
    if ($order = 'descending') then () else map:get($content, $sorting) descending

as the dynamic sorting can be tricky, how to solve it ?

see http://en.wikibooks.org/wiki/XQuery/Searching,Paging_and_Sorting

emchateau commented 9 years ago

Waiting a nicer solution, could be solved with the following

let $sorting := if (map:get($queryParams, 'sorting')) 
    then map:get($queryParams, 'sorting') 
    else ''