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

fix getLinkTarget for MEI 5 work titles #505

Merged
merged 14 commits into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 35 additions & 14 deletions add/data/xql/getLinkTarget.xql
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ declare variable $uri := request:get-parameter('uri', '');
(:~
: Returns a view for an edirom object
:)
declare function local:getView($type as xs:string, $docUri as xs:string, $doc as node()+) as map(*)? {
declare function local:getView($type as xs:string, $docUri as xs:string, $doc as document-node()?) as map(*)? {
let $baseMap := map {
'type': substring-after($type, '_'),
'uri':if ($type = ('mei_textView', 'desc_xmlView')) then
Expand Down Expand Up @@ -124,7 +124,7 @@ declare function local:getView($type as xs:string, $docUri as xs:string, $doc as
(:~
: Returns the views for an edirom object
:)
declare function local:getViews($type as xs:string, $docUri as xs:string, $doc as node()+) as map(*)* {
declare function local:getViews($type as xs:string, $docUri as xs:string, $doc as document-node()?) as map(*)* {

let $views := (
(:'desc_summaryView',:)
Expand Down Expand Up @@ -154,23 +154,32 @@ declare function local:getViews($type as xs:string, $docUri as xs:string, $doc a
(:~
: Returns the window title for an edirom-object
:)
declare function local:getWindowTitle($doc as node()+, $type as xs:string) as xs:string {
declare function local:getWindowTitle($doc as document-node()?, $type as xs:string) as xs:string {

(: Work :)
if (exists($doc//mei:mei) and exists($doc//(mei:workDesc|mei:workList)/mei:work) and not(exists($doc//mei:perfMedium))) then
(eutil:getLocalizedTitle(($doc//mei:work)[1]/mei:titleStmt[1], $lang))
else if (exists($doc/root()/mei:work)) then
(eutil:getLocalizedTitle($doc/root()/mei:work, $lang))
if ($type = 'work') then

let $workTitleContainer := (
(: MEI 3 and older :)
($doc//mei:work)[1]/mei:titleStmt,
(: MEI 4 and newer :)
($doc//mei:work)[1]
)[1]

return
eutil:getLocalizedTitle($workTitleContainer, $lang)

(: Recording :)
else if (exists($doc//mei:mei) and exists($doc//mei:recording)) then
else if ($type = 'recording') then
(eutil:getLocalizedTitle($doc//mei:fileDesc/mei:titleStmt[1], $lang))

(: Source / Score :)
(: Source / Score MEI 4 and newer :)
else if ($type = 'source' and exists($doc//mei:manifestation/mei:titleStmt)) then
(string-join((eutil:getLocalizedTitle(($doc//mei:manifestation)[1]/mei:titleStmt[1], $lang),
($doc//mei:manifestation)[1]//mei:identifier[lower-case(@type) = 'shelfmark'][1]), ' | ')
=> normalize-space())

(: Source / Score MEI 3 and older :)
else if ($type = 'source' and exists($doc//mei:source/mei:titleStmt)) then
(string-join((eutil:getLocalizedTitle(($doc//mei:source)[1]/mei:titleStmt[1], $lang),
($doc//mei:source)[1]//mei:identifier[lower-case(@type) = 'shelfmark'][1]), ' | ')
Expand All @@ -179,17 +188,29 @@ declare function local:getWindowTitle($doc as node()+, $type as xs:string) as xs
(: MEI fallback if no title is found :)
else if (exists($doc//mei:mei) and exists(($doc//mei:titleStmt)[1])) then
(eutil:getLocalizedTitle(($doc//mei:titleStmt)[1], $lang))

(: Text :)
else if (exists($doc/tei:TEI)) then
else if ($type = 'text') then
(eutil:getLocalizedTitle($doc//tei:fileDesc/tei:titleStmt[1], $lang))

(: HTML :)
else if ($type = 'html') then
($doc//head/data(title))
else if ($type = 'html' and not(functx:all-whitespace($doc//*:head/*:title))) then
$doc//*:head/*:title => normalize-space()

else if($type = 'unknown') then

let $eventualTitleContainers := ($doc//mei:titleStmt, $doc//tei:titleStmt)
let $eventualTitles := (
for $et in $eventualTitleContainers return
eutil:getLocalizedTitle($et, $lang),
for $t in $doc//*:title return
$t => normalize-space()
)

return $eventualTitles[1]

else
(string('unknown'))
('[No title found!]')
};

(: QUERY BODY ============================================================== :)
Expand Down
Loading