Skip to content
Snippets Groups Projects
Commit bb654744 authored by Jakob Schmidt's avatar Jakob Schmidt
Browse files

update from upstream

parent 54f65403
No related branches found
No related tags found
No related merge requests found
......@@ -139,22 +139,24 @@ declare
: @param $key the key to look for in the current $model. Multiple keys must be separated by whitespace only
: @param $wrap whether to include the current node in the output (defaults to 'yes')
: @param $or whether to check with an logical OR when mulitple keys are given (defaults to 'yes')
: @return the processed $node if the ckech was succesful, the empty sequence otherwise
: @return the processed $node if the check was succesful, the empty sequence otherwise
:)
declare
%templates:default("wrap", "yes")
%templates:default("or", "yes")
function app-shared:if-not-exists($node as node(), $model as map(*), $key as xs:string, $wrap as xs:string, $or as xs:string) as node()? {
let $thisOr := $or = ('yes', 'true')
let $tokens := tokenize($key, '\s+')
let $output := function() {
if($wrap = 'yes') then
element {node-name($node)} {
$node/@*,
$app-shared:templates-process($node/node(), $model)
}
else $app-shared:templates-process($node/node(), $model)
}
let $thisOr :=
if($or castable as xs:boolean) then xs:boolean($or)
else false()
let $tokens := tokenize($key, '\s+')
let $output := function() {
if($wrap = 'yes') then
element {node-name($node)} {
$node/@*,
$app-shared:templates-process($node/node(), $model)
}
else $app-shared:templates-process($node/node(), $model)
}
return
if($thisOr) then
if(some $token in $tokens satisfies not(wega-util-shared:has-content($model($token)))) then $output()
......
......@@ -19,7 +19,16 @@ import module namespace functx="http://www.functx.com";
: @return xs:string
:)
declare function str:normalize-space($string as xs:string?) as xs:string {
normalize-unicode(normalize-space(replace($string, ' | | | ', ' ')))
normalize-unicode(
normalize-space(
replace(
(: diverse Control Codes entsorgen, siehe https://en.wikipedia.org/wiki/List_of_Unicode_characters :)
replace($string, '||€', ''),
(: diversen Whitespace entsorgen, siehe https://en.wikipedia.org/wiki/Whitespace_character :)
' | | | ', ' '
)
)
)
};
(:~
......@@ -41,30 +50,14 @@ declare function str:join-path-elements($segs as xs:string*) as xs:string {
: @author Peter Stadler
: @return xs:string
:)
declare function str:printFornameSurname($name as xs:string?) as xs:string? {
declare function str:print-forename-surname($name as xs:string?) as xs:string? {
let $clearName := str:normalize-space($name)
return
if(functx:number-of-matches($clearName, ',') eq 1) then
if(ends-with($clearName, ' d’')) then normalize-space(string-join(reverse(tokenize($clearName, ','))))
else normalize-space(string-join(reverse(tokenize($clearName, ',')), ' '))
if(functx:number-of-matches($clearName, ',') eq 1)
then normalize-space(string-join(reverse(tokenize($clearName, ',')), ' '))
else $clearName
};
(:~
: Print forename surname from a TEI persName element
: In contrast to str:printFornameSurname() this function checks the appearance of forenames, i.e.
: <persName type="reg"><forename>Eugen</forename> <forename>Friedrich</forename> <forename>Heinrich</forename>, <roleName>Herzog</roleName> <nameLink>von</nameLink> Württemberg</persName>
: is turned into "Eugen Friedrich Heinrich, Herzog von Württemberg" rather than "Herzog von Württemberg Eugen Friedrich Heinrich"
:
: @param $name a tei persName element
: @author Peter Stadler
: @return xs:string
:)
declare function str:printFornameSurnameFromTEIpersName($persName as element(tei:persName)?) as xs:string? {
if(($persName/element()[1])[self::tei:forename]) then str:normalize-space($persName)
else str:printFornameSurname(string($persName))
};
(:~
: Surround a string with typographic double quotes
:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment