diff --git a/add/data/xqm/source.xqm b/add/data/xqm/source.xqm index 001ab77cb..812eb1920 100644 --- a/add/data/xqm/source.xqm +++ b/add/data/xqm/source.xqm @@ -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 :) }; (:~