module namespace entries = 'http://ossetic-studies.org/ns/abaevdict-site/entries'; 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'; (: MAIN DICTIONARY VIEW COMPONENT :) (: GET INDIVIDUAL ENTRY :) declare %rest:path("{$lang}/entries/{$id}") %rest:query-param("query", "{$query}") %rest:GET %rest:produces("text/html") %output:method("html") %output:html-version('5') function entries:entry($lang as xs:string, $id as xs:string, $query as xs:string?) { if (count($query) = 0) then doc(`abaevdict_{$lang}/html/{$id}.html`) (: abv-m:make-html(doc(`abaevdict_{$lang}/xml/{$id}.xml`),$lang) :) else let $xml := doc(`abaevdict_{$lang}/xml/{$id}.xml`)/tei:entry[1] let $marked := ft:mark( xquery:eval( `declare namespace tei = "http://www.tei-c.org/ns/1.0"; declare namespace abv = "http://ossetic-studies.org/ns/abaevdict"; .[{$query}]`, {'': $xml}) ) return abv-m:make-html($marked,$lang) }; declare %rest:path("/entries/{$id}") %rest:query-param("query", "{$query}") %rest:GET %rest:produces("text/html") %output:method("html") %output:html-version('5') function entries:entry($id as xs:string, $query as xs:string?) { entries:entry('en', $id, $query) }; (: GET ENTRIES CATALOG :) declare %rest:path("{$lang}/entries") %rest:query-param("per-chunk", "{$per-chunk}", 5) %rest:query-param("query", "{$query}") %rest:GET %rest:produces("text/html") %output:method("html") %output:html-version('5') function entries:entries($lang as xs:string, $per-chunk as xs:integer, $query as xs:string?) { let $docs := abv-m:collection($lang,'xml')/tei:entry let $chosen := if($query) then xquery:eval(`declare namespace tei = "http://www.tei-c.org/ns/1.0"; declare namespace abv = "http://ossetic-studies.org/ns/abaevdict"; .[{$query}]`, {'': $docs})/string(@xml:id) for tumbling window $w in abv-m:lookups() start at $s when true() only end at $e when $e - $s eq ($per-chunk - 1) return