Skip to content
Snippets Groups Projects
Commit 230c54e2 authored by Alexander Nguyen's avatar Alexander Nguyen
Browse files

#31 other relevant cases

parent d2d76593
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,7 @@ xquery version "1.0";
import module namespace annotation="http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm";
import module namespace source="http://www.edirom.de/xquery/source" at "../xqm/source.xqm";
import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm";
import module namespace functx = "http://www.functx.com" at "../xqm/functx-1.0-nodoc-2007-01.xq";
declare namespace request="http://exist-db.org/xquery/request";
declare namespace mei="http://www.music-encoding.org/ns/mei";
......@@ -43,6 +44,7 @@ let $docUri := substring-before($uri, '#')
let $internalId := substring-after($uri, '#')
let $doc := doc($docUri)
let $annot := $doc/id($internalId)
let $workID := substring-before(functx:substring-after-last($docUri, '/'), '.xml')
let $participants := annotation:getParticipants($annot)
......@@ -61,7 +63,7 @@ let $sourcesLabel := if ($lang = 'de')
then (if(count($sources) gt 1)then('Quellen')else('Quelle'))
else(if(count($sources) gt 1)then('Sources')else('Source'))
let $sigla := source:getSiglaAsArray($participants)
let $sigla := source:getSiglaAsArray($participants, $workID)
let $siglaLabel := if ($lang = 'de')
then (if(count($sigla) gt 1)then('Siglen')else('Siglum'))
else(if(count($sigla) gt 1)then('Sources')else('Source'))
......
......@@ -152,6 +152,7 @@ declare function annotation:toJSON($anno as element()) as xs:string {
let $id := $anno/@xml:id
let $title := normalize-space(local:getLocalizedTitle($anno))
let $doc := $anno/root()
let $workID := $doc/mei:mei/@xml:id/string()
let $prio := local:getLocalizedName($doc/id(substring($anno/mei:ptr[@type = 'priority']/@target,2)))
let $pList := distinct-values(tokenize($anno/@plist, ' '))
let $pList := for $p in $pList
......@@ -162,11 +163,13 @@ declare function annotation:toJSON($anno as element()) as xs:string {
for $p in distinct-values($pList)
let $pDoc := doc($p)
where not($pDoc//mei:availability[@type = 'rwaOnline'] = 'hidden')
return if ($pDoc//mei:sourceDesc/mei:source/mei:identifier[@type = 'siglum'])
then $pDoc//mei:sourceDesc/mei:source/mei:identifier[@type = 'siglum']/text()
else if (exists($pDoc//mei:manifestation//mei:relation[@rel = 'isEmbodimentOf']))
then string-join($pDoc//mei:manifestation//mei:relation[@rel = 'isEmbodimentOf']/@label, ',')
else ('ERROR')
return if ($pDoc//mei:sourceDesc/mei:source/mei:identifier[@type eq 'siglum'])
then ($pDoc//mei:sourceDesc/mei:source/mei:identifier[@type eq 'siglum'][1]//text())
else if (exists($pDoc//mei:manifestation//mei:relation[@target = $workID]))
then if ($pDoc//mei:manifestation//mei:relation[@target = $workID]/@label = 'null')
then ()
else $pDoc//mei:manifestation//mei:relation[@target = $workID]/@label/string()
else ($workID)
, ', ')
let $catURIs := tokenize(replace($anno/mei:ptr[@type = 'categories']/@target,'#',''),' ')
let $cats := string-join(
......
......@@ -78,9 +78,9 @@ declare function source:getLabel($source as xs:string) as xs:string {
: @param $sources The URIs of the Sources' documents to process
: @return The sigla
:)
declare function source:getSigla($sources as xs:string*) as xs:string {
declare function source:getSigla($sources as xs:string*, $workID as xs:string) as xs:string {
string-join(
source:getSiglaAsArray($sources)
source:getSiglaAsArray($sources, $workID)
, ', ')
};
......@@ -90,11 +90,11 @@ declare function source:getSigla($sources as xs:string*) as xs:string {
: @param $sources The URIs of the Sources' documents to process
: @return The sigla
:)
declare function source:getSiglaAsArray($sources as xs:string*) as xs:string* {
declare function source:getSiglaAsArray($sources as xs:string*, $workID as xs:string) as xs:string* {
for $source in $sources
where not(doc($source)//mei:availability[@type = 'rwaOnline'] = 'hidden')
return
source:getSiglum($source)
source:getSiglum($source, $workID)
};
(::)
(:~
......@@ -103,12 +103,14 @@ declare function source:getSiglaAsArray($sources as xs:string*) as xs:string* {
: @param $source The URIs of the Source's document to process
: @return The siglum
:)
declare function source:getSiglum($source as xs:string) as xs:string? {
declare function source:getSiglum($source as xs:string, $workID as xs:string) as xs:string? {
let $sourceDoc := doc($source)
return if ($sourceDoc//mei:source/mei:identifier[@type eq 'siglum'])
then ($sourceDoc//mei:source/mei:identifier[@type eq 'siglum'][1]//text())
else if (exists($sourceDoc//mei:manifestation//mei:relation[@rel = 'isEmbodimentOf']))
then string-join($sourceDoc//mei:manifestation//mei:relation[@rel = 'isEmbodimentOf']/@label, ',')
else ('ERROR')
then ($sourceDoc//mei:source/mei:identifier[@type eq 'siglum'][1]//text())
else if (exists($sourceDoc//mei:manifestation//mei:relation[@target = $workID]))
then if ($sourceDoc//mei:manifestation//mei:relation[@target = $workID]/@label = 'null')
then ()
else $sourceDoc//mei:manifestation//mei:relation[@target = $workID]/@label/string()
else ('ERROR')
};
\ No newline at end of file
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