> How do you currently proceed?
I have two queries that add attributes to a morphology I am processing. Ideally, I would like each attribute to be added at the end of the attribute list, after any existing attributes.
The first adds an @after attribute if there is a space or punctuation after the token:
declare function local:segs($nodes)
{
if (head($nodes)[self::*:seg])
then concat(string(head($nodes)), local:segs(tail($nodes)))
else ()
};
declare variable $oshb := db:open("oshb-morphology");
for $w in $oshb//*:w
let $next := $w/following-sibling::*[1]
where $next
let $after :=
if ($next[self::*:w]) then " "
else if ($next[self::*:seg]) then local:segs($w/following-sibling::*)
else ""
return
insert node attribute after {$after} into $w
The second adds Book-Chapter-Verse-Word-Part numbering:
let $oshb := db:open("oshb-morphology")
for $verse in $oshb//*:verse
order by local:bcv($verse/@osisID)
for $w at $i in $verse/*[self::*:w or self::*:c]
for $p at $j in local:entities($w)
let $id := local:bcvwp($verse/@osisID, $i, $j)
return (
delete node $p/@n,
insert node attribute n {$id} into $p
)