diff --git a/modules/fontane/stellenkommentar.xqm b/modules/fontane/stellenkommentar.xqm index 2e6e9b55598b2e22332a4a7fae455793b021b4fd..903c9d417632ee450df895516b6ce80d2a10439a 100644 --- a/modules/fontane/stellenkommentar.xqm +++ b/modules/fontane/stellenkommentar.xqm @@ -134,14 +134,16 @@ declare function stk:noteParser($note as node()*) attribute data-ref { $xmlids }, element xhtml:span { attribute class { "target" }, - string-join( - for $xmlid in $xmlids - return - string-join($node/..//*[@xml:id = $xmlid]//text() - [not(parent::tei:expan)], - ""), " " - ) => replace("- |⸗ ", "") + (if (count($xmlids) = 1) then + stk:lemmafinder($node/preceding-sibling::tei:surface[1]//*[@xml:id = $xmlids]) + else + stk:lemmafinder($node/preceding-sibling::tei:surface[1]//*[@xml:id = $xmlids[1]]) + || " <...> " || + stk:lemmafinder($node/preceding-sibling::tei:surface[1]//*[@xml:id = $xmlids[2]]) + ) + => replace("- |⸗ ", "") || "]" + }, element xhtml:ul { element xhtml:li { @@ -219,3 +221,22 @@ as xs:string default return "register.html?e=" || $id }; + +(:~ + : parses a tei-element to a string to be used as lemma + : Uses recursion. + : @param $target A tei-element referenced in a tei:note[@target] + :) +declare function stk:lemmafinder($target as node()*) +as xs:string +{ + if ($target/@next) then + let $nextid := replace($target/@next, "#", "") + let $nextpart := $target/ancestor::tei:surface//*[@xml:id = $nextid] + return + string-join( + (string-join($target//text()[not(parent::tei:expan)], ""), + stk:lemmafinder($nextpart)), " ") + else + string-join($target//text()[not(parent::tei:expan)], "") +};