From e10536e6a336e790455b1e8445416d385966828c Mon Sep 17 00:00:00 2001 From: Simon Sendler Date: Thu, 25 Apr 2019 11:40:59 +0200 Subject: [PATCH 1/2] Improve lemma selection to include parentheses. --- modules/fontane/stellenkommentar.xqm | 30 +++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/modules/fontane/stellenkommentar.xqm b/modules/fontane/stellenkommentar.xqm index 2e6e9b55..22070456 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,17 @@ as xs:string default return "register.html?e=" || $id }; + +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)], "") +}; -- GitLab From 56e31eacc75e8e5de39bad018691dcfc459f9a19 Mon Sep 17 00:00:00 2001 From: Simon Sendler Date: Thu, 23 May 2019 10:57:19 +0200 Subject: [PATCH 2/2] add documentation --- modules/fontane/stellenkommentar.xqm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/fontane/stellenkommentar.xqm b/modules/fontane/stellenkommentar.xqm index 22070456..903c9d41 100644 --- a/modules/fontane/stellenkommentar.xqm +++ b/modules/fontane/stellenkommentar.xqm @@ -222,6 +222,11 @@ as xs:string "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 { -- GitLab