2
module namespace foaf = "http://www.w3.org/TestModules/foaf";
4
import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";
5
import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";
6
import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl";
7
import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml";
9
declare namespace ann = "http://www.zorba-xquery.com/annotations";
11
declare variable $foaf:network:= xs:QName("foaf:network");
12
declare variable $foaf:person:= xs:QName("foaf:person");
13
declare variable $foaf:age:= xs:QName("foaf:age");
14
declare variable $foaf:friends:= xs:QName("foaf:friends");
16
declare collection foaf:network as object()*;
20
The person index maps each person name with its information.
23
declare %ann:unique %ann:automatic index foaf:person
24
on nodes dml:collection(xs:QName("foaf:network"))
25
by .("name") as xs:string;
29
The person index maps each person name with its information.
32
declare %ann:value-range %ann:automatic index foaf:age
33
on nodes dml:collection(xs:QName("foaf:network"))
34
by xs:integer(.("age")) as xs:integer;
38
The person index maps each person name with its information.
41
declare %ann:manual %ann:general-equality index foaf:friends
42
on nodes dml:collection(xs:QName("foaf:network"))
43
by jn:members(.("friends")) as xs:string*;
47
The person index maps each person with the person of which she is the best friend.
50
declare %ann:manual %ann:general-range index foaf:age-range
51
on nodes dml:collection(xs:QName("foaf:network"))
52
by xs:integer(.("age")) as xs:integer;
56
Create and populate the collection, and then create the indexes
59
declare %ann:sequential function foaf:create-db()
61
ddl:create($foaf:network);
63
dml:insert($foaf:network, (
65
"name" : "James T. Kirk",
68
"friends" : [ "Mister Spock", "Scotty", "Jean-Luc Picard"]
72
"name" : "Jean-Luc Picard",
75
"friends" : [ "James T. Kirk", "Lieutenant Commander Data", "Beverly Crusher" ]
79
"name" : "Beverly Crusher",
82
"friends" : [ "Jean-Luc Picard", "Ensign Crusher" ]
86
"name" : "Lieutenant Commander Data",
88
"gender" : "positronic matrix",
89
"friends" : [ "Geordi La Forge" ]
93
index_ddl:create($foaf:person);
94
index_ddl:create($foaf:age);
95
index_ddl:create($foaf:friends);
99
declare function foaf:probe-point-id($indexName as xs:QName, $id as xs:string)
101
index_dml:probe-index-point-value($indexName, $id)
104
declare function foaf:probe-range-id($indexName as xs:QName, $lower as xs:integer, $upper as xs:integer)
106
index_dml:probe-index-range-value($indexName, $lower, $upper, true(), true(), true(), true())
109
declare function foaf:probe-point-general-id($indexName as xs:QName, $names as xs:string*)
111
index_dml:probe-index-point-general($indexName, $names)