From 0f2b52c993791585ab736d08208f5d99a857f6d4 Mon Sep 17 00:00:00 2001 From: Peter Stadler Date: Sat, 22 Jun 2024 00:17:51 +0200 Subject: [PATCH] fix missing orgName `substring-before` returns an empty string for non-matches so replaced it with `functx:substring-before-if-contains` which returns the original string for non-matches. --- modules/app.xqm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/app.xqm b/modules/app.xqm index 0b3fc529a..0bb6d15da 100644 --- a/modules/app.xqm +++ b/modules/app.xqm @@ -627,20 +627,20 @@ declare %private function app:createLetterLink($teiDate as element(tei:date)?, $ }; (:~ - : Construct a name from a tei:persName or tei:name element wrapped in a - : If a @key is given on persName the regularized form will be returned, otherwise the content of persName. - : If persName is empty than "unknown" is returned. + : Construct a name from a tei:persName, tei:orgName, or tei:name element wrapped in a + : If a @key is given on the element the regularized form will be returned, otherwise the content of the element. + : If the element is empty than "unknown" is returned. : : @author Peter Stadler - : @param $persName the tei:persName element + : @param $persName the tei:persName, tei:orgName, or tei:name element : @param $lang the current language (de|en) - : @param $order (sf|fs) whether to print "surname, forename" or "forename surname" - : @return + : @param $order (sf|fs|s) whether to print "surname, forename", or "forename surname", or just the surname + : @return a html:span element with the constructed name :) -declare function app:printCorrespondentName($persName as element()?, $lang as xs:string, $order as xs:string) as element() { +declare function app:printCorrespondentName($persName as element()?, $lang as xs:string, $order as xs:string) as element(xhtml:span) { if(exists($persName/@key)) then if ($order eq 'fs') then app:createDocLink(crud:doc($persName/string(@key)), wega-util:print-forename-surname-from-nameLike-element($persName), $lang, ('class=' || config:get-doctype-by-id($persName/@key))) - else if ($order eq 's') then app:createDocLink(crud:doc($persName/string(@key)), substring-before(query:title($persName/@key),','), $lang, ('class=preview ' || concat($persName/@key, " ", config:get-doctype-by-id($persName/@key)))) + else if ($order eq 's') then app:createDocLink(crud:doc($persName/string(@key)), functx:substring-before-if-contains(query:title($persName/@key), ', '), $lang, ('class=preview ' || concat($persName/@key, " ", config:get-doctype-by-id($persName/@key)))) else app:createDocLink(crud:doc($persName/string(@key)), query:title($persName/@key), $lang, ('class=' || config:get-doctype-by-id($persName/@key))) else if(not(functx:all-whitespace($persName))) then if ($order eq 'fs') then {wega-util:print-forename-surname-from-nameLike-element($persName)}