declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare namespace abv = "http://ossetic-studies.org/ns/abaevdict";

import module namespace abv-m = 'http://ossetic-studies.org/ns/abaevdict-mod' at './abv-mod.xqm';

let $doc := db:get('abaevdict_en','/xml/entry_az.xml')
return string(abv-m:make-html($doc, 'ru')/article[1]/@id)
(: let $nid := db:node-id($doc/tei:entry[1]/tei:note[1]) :)
(: return $nid :)
(: return xquery:eval('declare namespace tei = "http://www.tei-c.org/ns/1.0";//tei:note',{'': $doc}) :)

(: abv-m:make-html(doc('abaevdict_en/xml/entry_sæpp.xml'), 'en') :)

(: db:node-id(db:get-id('abaevdict_index',1307388)) :)

(: import module namespace api = 'http://ossetic-studies.org/ns/abaevdict-api' at './restx_api.xq'; :)

(: abv-m:make-html(doc('abaevdict_en/xml/entry_az.xml')//tei:mentioned,'en') :)

(: abv-m:langname-by-id('inc-x-old-vaidika','en') :)

(: SERIALIZE AS JSONML :)
(: json:serialize(doc('abaevdict_index/mentioned.xml'), {'format': 'jsonml'}) :)

(: GENERATE MENTIONED INDEX :)
(: let $langs := ('en', 'ru')
for $lang in $langs
let $index := xquery:eval(xs:anyURI('gen-mentioned-index.xq'), {'metalang': $lang})
return db:put('abaevdict_index', $index, `mentioned_{$lang}.xml`) :)

(: GENERATE ENGLISH/RUSSIAN TEI FOR ONE ENTRY :)
(: let $langs := ('en','ru')
for $lang in $langs
for $doc in abv-m:make-lng(doc('abaevdict/abaev_-ston.xml'), $lang)
let $id := $doc/@xml:id
return db:put(`abaevdict_{$lang}`, $doc, `xml/{$id}.xml`) :)

(: GENERATE HTML FOR ONE ENTRY :)
(: let $langs := ('en','ru')
for $lang in $langs
let $doc := abv-m:make-html(doc(`abaevdict_{$lang}/xml/entry_-ston.xml`), $lang)
let $id := $doc/article[1]/@id
return db:put(`abaevdict_{$lang}`, $doc, `html/{$id}.html`) :)

(: TEST HTML GEN :)
(: abv-m:make-html(doc('abaevdict_en/xml/entry_abūxyn.xml'),'en') :)

(: GENERATE ENGLISH/RUSSIAN HTML :)
(: for $doc in abv-m:make-html(collection('abaevdict_ru/xml'), 'ru') 
return db:put('abaevdict_ru', $doc, `html/{$doc/article[1]/@id}.html`) :)

(: TEST GEOMAP FOR ONE ENTRY :)
(: let $doc := doc('abaevdict_en/entry_maryn.xml')
return abv-m:make-geomap($doc,'en') :)

(: PARSE CSV OF LANGNAMES. IF I WILL EVER NEED IT :)
(: let $text := file:read-text('./basex/webapp/csv/langnames.csv')
return db:put('abaevdict_index',
               csv:parse($text, { 'header': true() }),
              'langnames.xml') :)