module namespace index = 'http://ossetic-studies.org/ns/abaevdict-site/index';
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';
(: GET LANGUAGE LIST :)
declare %rest:path("{$lang}/index/languages")
%rest:GET
%rest:produces("text/html")
%output:method("html")
%output:html-version('5')
function index:languages($lang as xs:string) {
let $mlangs := doc(`abaevdict_index/langnames.xml`)/csv[1]/record
for $mlang in $mlangs
let $mlang-id := $mlang/code/text()
let $mlang-name := if ($lang = 'ru') then $mlang/ru/text() else $mlang/en/text()
where $mlang-name != ''
order by $mlang-name
return
};
declare %rest:path("/index/languages")
%rest:GET
%rest:produces("text/html")
%output:method("html")
%output:html-version('5')
function index:languages() {
index:languages('en')
};
(: FORM LIST :)
declare %rest:path("{$lang}/index/forms")
%rest:query-param("flang", "{$flang}")
%rest:GET
%rest:produces("text/html")
%output:method("html")
%output:html-version('5')
function index:forms($lang as xs:string, $flang as xs:string) {
let $ments := doc(`abaevdict_index/mentioned_{$lang}.xml`)
/lang-index[1]/lang[@id=$flang]/word
for $w in $ments
let $txt := string($w/@text)
return
};
declare %rest:path("index/forms")
%rest:query-param("flang", "{$flang}")
%rest:GET
%rest:produces("text/html")
%output:method("html")
%output:html-version('5')
function index:forms($flang as xs:string) {
index:forms('en',$flang)
};
(: RELATED ENTRY LIST :)
declare %rest:path("{$lang}/index/entries")
%rest:query-param("flang", "{$flang}")
%rest:query-param("word", "{$word}")
%rest:GET
%rest:produces("text/html")
%output:method("html")
%output:html-version('5')
function index:entries($lang as xs:string,
$flang as xs:string,
$word as xs:string) {
let $entries := doc(`abaevdict_index/mentioned_{$lang}.xml`)
/lang-index[1]/lang[@id=$flang]/word[@text=$word]/entry
for $e in $entries
let $id := $e/@id
let $txt := abv-m:entry-form-by-id($id)
let $query := `./@xml:id = '{$id}' and .//text() contains
text '{$word}' using diacritics sensitive`
return
};
declare %rest:path("index/entries")
%rest:query-param("flang", "{$flang}")
%rest:query-param("word", "{$word}")
%rest:GET
%rest:produces("text/html")
%output:method("html")
%output:html-version('5')
function index:entries($flang as xs:string,
$word as xs:string) {
index:entries('en',$flang,$word)
};
(: THE MAIN INDEX VIEW :)
declare function index:content($lang as xs:string) {
{if ($lang = 'ru') then 'Глоссы' else 'Gloss'}
{if ($lang = 'ru') then 'Лексема' else 'Lemma'}
{if ($lang = 'ru') then 'Перевод' else 'Translation'}