abaev-basex/xq/make-lookup.xq
2025-03-21 14:14:03 +03:00

24 lines
No EOL
727 B
Text

declare default element namespace "http://www.tei-c.org/ns/1.0";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare namespace abv = "http://ossetic-studies.org/ns/abaevdict";
declare function local:genLookupEntry($doc as document-node())
as element()?
{
let $node := $doc/tei:TEI/tei:text/tei:body/tei:entry
let $phon := $node/tei:form[1]/tei:orth[1]/text()[1]
return element entry {
attribute xml:id { $node/@xml:id },
attribute filename { db:path($doc) },
if ($node/@n) then attribute n {$node/@n} else (),
text { $phon }
}
};
let $tbl := <table>
{for $doc in collection('abaevdict')
return local:genLookupEntry($doc)}
</table>
return db:put('abaevdict_index', $tbl, 'lookup.xml')