Skip to content

Commit

Permalink
replace collection calls
Browse files Browse the repository at this point in the history
with dedicated function `edition:collection#1`
  • Loading branch information
peterstadler committed Dec 11, 2024
1 parent 01aa130 commit 0a4676e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
18 changes: 6 additions & 12 deletions add/data/xql/getAnnotationInfos.xql
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,28 @@ xquery version "3.1";
(: IMPORTS ================================================================= :)

import module namespace annotation = "http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm";

import module namespace edition = "http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm";
import module namespace eutil = "http://www.edirom.de/xquery/eutil" at "../xqm/eutil.xqm";


(: NAMESPACE DECLARATIONS ================================================== :)

declare namespace mei = "http://www.music-encoding.org/ns/mei";

declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare namespace request = "http://exist-db.org/xquery/request";


(: OPTION DECLARATIONS ===================================================== :)

declare option output:method "json";

declare option output:media-type "application/json";


(: VARIABLE DECLARATIONS =================================================== :)

declare variable $uri := request:get-parameter('uri', '');

declare variable $edition := request:get-parameter('edition', '');

declare variable $edition_path := eutil:getPreference('edition_path', $edition);


(: FUNCTION DECLARATIONS =================================================== :)

Expand Down Expand Up @@ -89,13 +83,13 @@ declare function local:getDistinctPriorities($annots as element()*) as xs:string

(: QUERY BODY ============================================================== :)

let $mei := doc($uri)/root()

let $annots := collection($edition_path)//mei:annot[matches(@plist, $uri)] | $mei//mei:annot
let $mei := doc($uri)
let $editionCollection := edition:collection($edition_path)
let $annots := $editionCollection//mei:annot[matches(@plist, $uri)] | $mei//mei:annot

let $categories :=
for $category in local:getDistinctCategories($annots)
let $categoryElement := (collection($edition_path)/id($category)[mei:label or mei:name])[1]
let $categoryElement := ($editionCollection/id($category)[mei:label or mei:name])[1]
let $name := annotation:category_getName($categoryElement, eutil:getLanguage($edition))
order by $name
return
Expand All @@ -106,7 +100,7 @@ let $categories :=

let $prios :=
for $priority in local:getDistinctPriorities($annots)
let $name := annotation:getPriorityLabel((collection($edition_path)//id($priority)[mei:label or mei:name])[1])
let $name := annotation:getPriorityLabel(($editionCollection/id($priority)[mei:label or mei:name])[1])
order by $name
return
map {
Expand Down
10 changes: 2 additions & 8 deletions add/data/xql/getAnnotationsOnPage.xql
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,24 @@ xquery version "3.1";

import module namespace functx = "http://www.functx.com";

import module namespace edition = "http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm";
import module namespace eutil = "http://www.edirom.de/xquery/eutil" at "../xqm/eutil.xqm";


(: NAMESPACE DECLARATIONS ================================================== :)

declare namespace ft = "http://exist-db.org/xquery/lucene";

declare namespace mei = "http://www.music-encoding.org/ns/mei";

declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare namespace request = "http://exist-db.org/xquery/request";

declare namespace svg = "http://www.w3.org/2000/svg";

declare namespace xlink = "http://www.w3.org/1999/xlink";

declare namespace xmldb = "http://exist-db.org/xquery/xmldb";


(: OPTION DECLARATIONS ===================================================== :)

declare option output:method "json";

declare option output:media-type "application/json";


Expand Down Expand Up @@ -108,7 +102,7 @@ declare function local:findAnnotations($edition as xs:string, $uri as xs:string,

(: TODO: search in other documents and in other collections :)
(: TODO: check if annotations hold URIs or IDRefs :)
let $annots := collection(eutil:getPreference('edition_path', $edition))//mei:annot
let $annots := edition:collection($edition)//mei:annot
let $ret :=
for $id in $elemIds

Expand Down
2 changes: 1 addition & 1 deletion add/data/xqm/annotation.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ declare function annotation:toJSON($anno as element(), $edition as xs:string) as
if(doc-available($p)) then
(doc($p))
else
(collection(eutil:getPreference('edition_path', $edition))//id($p)/root())
edition:collection($edition)/id($p)/root()
return
if ($pDoc//mei:sourceDesc/mei:source/mei:identifier[@type = 'siglum']) then
($pDoc//mei:sourceDesc/mei:source/mei:identifier[@type = 'siglum']/text())
Expand Down

0 comments on commit 0a4676e

Please sign in to comment.