now index and display subentries

This commit is contained in:
Oleg Belyaev 2025-03-22 00:08:52 +03:00
parent a8c0ea875c
commit 4ef96c50ab
4 changed files with 57 additions and 45 deletions

View file

@ -2,11 +2,13 @@ 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";
import module namespace abv-m = 'http://ossetic-studies.org/ns/abaevdict-mod' at './abv-mod.xqm';
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]
let $phon := normalize-space(data($node/tei:form[1]/tei:orth[1]))
return element entry {
attribute xml:id { $node/@xml:id },
@ -16,9 +18,21 @@ as element()?
}
};
let $entries := for $doc in collection('abaevdict')
return local:genLookupEntry($doc)
let $subentries := for $doc in collection('abaevdict')
for $re in $doc//re
let $etext := normalize-space(data($re/form[1]/orth[1]))
where $etext != '' and not($etext = $entries/text())
and not(starts-with($etext,','))
and string-to-codepoints($etext)[1] != string-to-codepoints(' ')
return <re corresp="{$doc/tei:TEI/tei:text/tei:body/tei:entry/@xml:id}">{$etext}</re>
let $tbl := <table>
{for $doc in collection('abaevdict')
return local:genLookupEntry($doc)}
{for $e in ($entries,$subentries)
order by abv-m:sortKey($e/text())
return $e}
</table>
return db:put('abaevdict_index', $tbl, 'lookup.xml')