module namespace page = 'http://ossetic-studies.org/ns/abaevdict-site';
declare namespace tei = "http://www.tei-c.org/ns/1.0";
import module namespace abv-m = 'http://ossetic-studies.org/ns/abaevdict-mod' at './abv-mod.xqm';
declare variable $page:items as xs:integer := 20;
declare %rest:path("{$lang}/dict/page{$p}")
(: %rest:GET :)
%output:method("html")
%output:html-version('5')
function page:dict($lang, $p) {
let $pagetotal := ceiling(count(collection('abaevdict_en')) div $page:items)
let $sorted := abv-m:sort-collection(collection(`abaevdict_{$lang}`))
return
Abaev
{for $doc at $i in $sorted
where $i > ($p - 1) * $page:items and $i <= $p * $page:items
let $html := xslt:transform($doc,
doc('../xsl/abaev2html.xsl'), {'lang': $lang})
return $html}
};
declare %rest:path("{$lang}/dict/by-id/{$id}")
(: %rest:GET :)
%output:method("html")
%output:html-version('5')
function page:by-id($lang, $id) {
let $seq := abv-m:sort-collection(collection(`abaevdict_{$lang}`))
let $doc-index := index-of($seq, $seq[tei:entry[@xml:id=`{$id}`]])
let $pagenum := ceiling($doc-index div $page:items)
return web:redirect(`../page{$pagenum}`, {}, web:decode-url($id))
};
declare %rest:path("{$lang}/dict/map-info/{$entry}")
%rest:produces("application/json")
%rest:GET function page:map-info($lang, $entry) {
let $ments := abv-m:make-geomap(doc(`abaevdict_{$lang}/{$entry}.xml`),
$lang)
return json:serialize($ments, {'format': 'xquery'})
};