module namespace entry = 'http://ossetic-studies.org/ns/abaevdict-site/entrypoints'; import module namespace shared = 'http://ossetic-studies.org/ns/abaevdict-site/shared' at './shared/shared.xq'; (: This module includes various ways of accessing dictionary resources by their identifiers. Right now, this only applies to entries, but may apply to other things as well :) (: == ENTRY BY ID == :) (: English as default language :) declare %rest:path("dict/{$id}") %rest:query-param("xpath", "{$xpath}", '') %output:method("html") %output:html-version('5') function entry:by-id($id, $xpath) { entry:by-id('en', $id, $xpath) }; declare %rest:path("{$lang}/dict/{$id}") %rest:query-param("xpath", "{$xpath}", '') %output:method("html") %output:html-version('5') function entry:by-id($lang, $id, $xpath) { let $doc-index := index-where($shared:sorted, fn { ./@xml:id=$id }) let $pagenum := ceiling($doc-index div $shared:items-per-page) return web:redirect('../dict', map:merge(({'page': $pagenum, 'entry': web:decode-url($id)}, if ($xpath != '') then {'xpath': $xpath})), web:decode-url($id)) };