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

getLinkTarget.xql fails if window title not found for mei:work #337

Open
bwbohl opened this issue Jun 13, 2023 · 6 comments
Open

getLinkTarget.xql fails if window title not found for mei:work #337

bwbohl opened this issue Jun 13, 2023 · 6 comments

Comments

@bwbohl
Copy link
Member

bwbohl commented Jun 13, 2023

declare function local:getWindowTitle($doc as node()+, $type as xs:string) as xs:string {

e.g. in MEI 4.0.1 work does no longer contain titleStmt

@bwbohl bwbohl added this to the 1.0.0-beta.6 milestone Feb 6, 2024
@bwbohl
Copy link
Member Author

bwbohl commented Jun 20, 2024

if (exists($doc//mei:mei) and exists($doc//mei:workDesc/mei:work) and not(exists($doc//mei:perfMedium)))

fails for MEI 4 upward because mei:workDesc was replaced with mei:workList

@riedde riedde self-assigned this Sep 4, 2024
@riedde riedde modified the milestones: 1.0.0-beta.6, 1.0.0 Sep 4, 2024
@peterstadler peterstadler changed the title getLinkTarget.xql fails if window title not foud for mei:work getLinkTarget.xql fails if window title not found for mei:work Sep 5, 2024
@peterstadler
Copy link
Member

Is the function failing by throwing an error or is it returning "unknown" where you would expect some title text?

@riedde
Copy link
Contributor

riedde commented Sep 11, 2024

I have tested this with an MEI 5 file. I hade to delete a lot of titles before nothing was returned, but I was not able to force a fail. At the end an emptry string was retuned.

Since @bwbohl mentioned #118 here: Special characters and hard linebreaks have been a problem since I can remember. The linebreak issue was simply fixed by normalizing the space.
But also with a title containing the apostrophe I am not able to reproduce this case. @bwbohl Could you provide me a title-Container that I can copy&paste into my test set?

@bwbohl
Copy link
Member Author

bwbohl commented Sep 11, 2024

The current implelemtation

(:~
: Returns the window title for an edirom-object
:)
declare function local:getWindowTitle($doc as node()+, $type as xs:string) as xs:string {
(: Work :)
if (exists($doc//mei:mei) and exists($doc//mei:workDesc/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))
(: Recording :)
else if (exists($doc//mei:mei) and exists($doc//mei:recording)) then
(eutil:getLocalizedTitle($doc//mei:fileDesc/mei:titleStmt[1], $lang))
(: Source / Score :)
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())
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]), ' | ')
=> normalize-space())
(: 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
(eutil:getLocalizedTitle($doc//tei:fileDesc/tei:titleStmt[1], $lang))
(: HTML :)
else if ($type = 'html') then
($doc//head/data(title))
else
(string('unknown'))
};

As we can see from the above, normalize-space() is only called for source objects
We should apply it to all object types

@riedde
Copy link
Contributor

riedde commented Sep 11, 2024

The normalisation already happens in eutil:getLocalizedTitle()

@bwbohl
Copy link
Member Author

bwbohl commented Sep 11, 2024

hmm… please test #103 it fails in my local instance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

4 participants