-
Notifications
You must be signed in to change notification settings - Fork 10
/
centre.xqm
55 lines (45 loc) · 1.69 KB
/
centre.xqm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
xquery version "3.0";
module namespace centre="http://clarin.ids-mannheim.de/standards/centre";
import module namespace recommendation = "http://clarin.ids-mannheim.de/standards/recommendation-model"
at "recommendation-by-centre.xqm";
(: Define the methods for accessing centre data
@author margaretha
:)
(:declare variable $centre:centres := doc('/db/apps/clarin/data/centres.xml')/centres/centre;:)
declare variable $centre:centres := $recommendation:centres/header/centre;
declare variable $centre:ids := data($centre:centres/@id);
declare variable $centre:names := $centre:centres/name/text();
declare function centre:get-centre($id as xs:string){
$centre:centres[@id=$id]
};
declare function centre:get-statutes(){
let $statuses := fn:distinct-values($centre:centres/nodeInfo/ri/@status)
let $flat :=
for $status in $statuses
return
if (fn:contains($status,","))
then (
for $s in fn:tokenize($status,",")
return fn:normalize-space($s)
)
else fn:normalize-space($status)
return fn:distinct-values($flat)
};
declare function centre:get-centre-ids-by-ri($ri as xs:string){
data($centre:centres[nodeInfo/ri=$ri]/@id)
};
declare function centre:get-centre-by-research-infrastructure($ri as xs:string,
$status as xs:string){
for $c in $centre:centres[nodeInfo/ri=$ri]
let $c-status := $c/nodeInfo/ri/@status
return
if (contains($c-status,$status))
then $c
else ()
};
declare function centre:get-distinct-research-infrastructures(){
fn:distinct-values($centre:centres/nodeInfo/ri)
};
declare function centre:get-deposition-centres($ri){
$centre:centres[nodeInfo/ri=$ri and @deposition=1]
};