Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing: Work title "not found", "fail" etc. #426

Merged
merged 10 commits into from
Oct 11, 2024
45 changes: 33 additions & 12 deletions add/data/xqm/util.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ declare function eutil:getLocalizedName($node, $lang) {
if($node/edirom:names) then
($name)
else
($name => string-join(' ') => normalize-space())
(eutil:joinAndNormalize($name))

};

Expand All @@ -107,26 +107,26 @@ declare function eutil:getLocalizedTitle($node as node(), $lang as xs:string?) a
let $namespace := eutil:getNamespace($node)

let $titleMEI :=
if ($lang != '' and $lang = $node/mei:title/@xml:lang and not($node/mei:title/mei:titlePart)) then
($node/mei:title[@xml:lang = $lang]//text() => string-join() => normalize-space())
else if ($lang != '' and $lang = $node/mei:title/@xml:lang and $node/mei:title/mei:titlePart) then
($node/mei:title[@xml:lang = $lang]/mei:titlePart[1]//text() => string-join() => normalize-space())
if ($lang != '' and $lang = $node/mei:title[mei:titlePart]/@xml:lang) then
(eutil:joinAndNormalize($node/mei:title[@xml:lang = $lang]/mei:titlePart, '. '))
else if ($lang != '' and $lang = $node/mei:title[not(mei:titlePart)]/@xml:lang) then
(eutil:joinAndNormalize($node/mei:title[@xml:lang = $lang]))
else
(($node//mei:title)[1]//text() => string-join() => normalize-space())
(eutil:joinAndNormalize(($node//mei:title)[1]))

let $titleTEI :=
if ($lang != '' and $lang = $node/tei:title/@xml:lang) then
$node/tei:title[@xml:lang = $lang]/text()
eutil:joinAndNormalize($node/tei:title[@xml:lang = $lang])
else
$node/tei:title[1]/text()
eutil:joinAndNormalize($node/tei:title[1])

return
if ($namespace = 'mei') then
if ($namespace = 'mei' and $titleMEI != '') then
($titleMEI)
else if ($namespace = 'tei') then
else if ($namespace = 'tei' and $titleTEI != '') then
($titleTEI)
else
('unknown')
('[No title found!]')

};
(:~
Expand Down Expand Up @@ -240,7 +240,7 @@ declare function eutil:getPartLabel($measureOrPerfRes as node(), $type as xs:str
upper-case($i)

return
normalize-space(string-join(($label, $numbering),' '))
eutil:joinAndNormalize(($label, $numbering))

};

Expand Down Expand Up @@ -398,3 +398,24 @@ declare function eutil:request-lang-preferred-iso639() as xs:string {
"en"

};

(:~
: Returns one joined and normalized string
:
: @param $strings The string(s) to be processed
: @return The string (joined with whitespace and normalized space)
:)
declare function eutil:joinAndNormalize($strings as xs:string*) as xs:string {
$strings => string-join(' ') => normalize-space()
};

(:~
: Returns one joined and normalized string
:
: @param $strings The string(s) to be processed
: @param $separator One ore more characters as separators for joining the string
: @return The string (joined and normalized space)
:)
declare function eutil:joinAndNormalize($strings as xs:string*, $separator as xs:string) as xs:string {
$strings => string-join($separator) => normalize-space()
};