Skip to content
Snippets Groups Projects
Unverified Commit 6ce89862 authored by Peter Stadler's avatar Peter Stadler Committed by GitHub
Browse files

fix getLinkTarget for MEI 5 work titles (#505)

## Description, Context and related Issue

Remove `mei:titleStmt` when determining the title of the work because in
MEI 5 `mei:title` is a direct child of `mei:work`
Closes #337 

## How Has This Been Tested?

With a BAZ-GA MEI 5 work.

## Types of changes

- Bug fix (non-breaking change which fixes an issue)

## Overview
<!--- Go over all the following points, and DELETE options that are not
relevant. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
- I have performed a self-review of my code, according to the [style
guide](https://github.com/Edirom/Edirom-Online/blob/develop/STYLE-GUIDE.md)
- I have read the
[CONTRIBUTING](https://github.com/Edirom/Edirom-Online/blob/develop/CONTRIBUTING.md)
document.
- I have added tests to cover my changes at
[testing](https://github.com/Edirom/Edirom-Online/tree/develop/testing)

- All new and existing tests passed.
--> will know when the PR has run its tests ;-)
parents 9cbb3a18 d065dfd2
Branches 521-ftrintegration-of-verovio-viewer-web-component
No related tags found
No related merge requests found
......@@ -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
......@@ -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',:)
......@@ -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]), ' | ')
......@@ -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 ============================================================== :)
......
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