Skip to content

Commit

Permalink
Merge pull request #363 from Edirom/fix/mei-source-version-check
Browse files Browse the repository at this point in the history
Fix MEI version check in source:isSource function
  • Loading branch information
bwbohl authored Feb 8, 2024
2 parents 706d3ab + a8c0994 commit 44c48aa
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions add/data/xqm/source.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,29 @@ declare namespace mei="http://www.music-encoding.org/ns/mei";
import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm";

(:~
: Returns whether a document is a source or not
: Returns whether a document is a source or not. Generally this should work for MEI versions
: 2011-05 through 5.0
:
: @param $uri The URI of the document
: @return Is work or not
:
: @return xs:boolean indicating whether the document referenced by @param $uri
: is considered a music source or not.
:)
declare function source:isSource($uri as xs:string) as xs:boolean {
let $doc := eutil:getDoc($uri)
let $meiVersionRegex := '(([4-9])|(\d+[0-9]))\.\d+\.\d+(-dev)?'
let $meiVersion4To5Regex := '^[4-5](\.\d){1,2}(-dev)?(\+(anyStart|basic|CMN|Mensural|Neumes))?$'
(: 2010-05 pre camelCase :)
(: 2011-05 2012 :)
(: 2013 +meiversion.num 2.1.1:)
(: 3.0.0 :)
(:mei2 and ?3 :)
return
(exists($doc//mei:mei) and exists($doc//mei:source)) (:mei2 and ?3 :)
or
(matches($doc//mei:mei/@meiversion, $meiVersionRegex) and exists($doc//mei:manifestation[@singleton='true'])) (:mei4+ for manuscripts:)
(: MEI 4.0.1 and 5.0 with all dev and cutomization variants :)
(matches($doc//mei:mei/@meiversion, $meiVersion4To5Regex) and exists($doc//mei:manifestation[@singleton='true'])) (:mei4+ for manuscripts:)
or
(matches($doc//mei:mei/@meiversion, $meiVersionRegex) and exists($doc//mei:manifestation//mei:item)) (: mei4+ for prints :)
(matches($doc//mei:mei/@meiversion, $meiVersion4ToRegex) and exists($doc//mei:manifestation//mei:item)) (: mei4+ for prints :)
};

(:~
Expand Down

0 comments on commit 44c48aa

Please sign in to comment.