eXist/Mondial Example Queries Page
Here, a collection of example queries for the LinXIS
XML database prototype can be found. The software prototype is based on the open-source native XML database
eXist. The prototype is able to process distributed XML instances linked with
XLink as proposed within the LinXIS.
The Data
The chosen scenario for the database prototype is a distributed version of the Mondial
XML database, with the following distribution:
The Queries
In the moment, the only interface with full XLink/XQuery capabilities is HTTP-GET, which is supported in a REST-style syntax.
In the following, some example queries are given, using the Simple Link and Extended Link features of the system.
Feel free to change the query expressions in your browser's URL line (but keep in mind that the software is a prototype
that (1) covers only a part of the functionality proposed in LinXIS, (2) even in the implemented parts, it may contain numbers
of bugs, and (3) it might be a little bit slow sometimes. ;-)
Simple Links
The names of all german provinces ("Bundesländer")
http://linxis02.ifi.informatik.uni-goettingen.de:8080/exist/servlet/db/LinXIS/countries.xml?_query=/countries/country[name='Germany']/province/name&_linxis=yes&_howmany=10000
The capital of Belgium
http://linxis02.ifi.informatik.uni-goettingen.de:8080/exist/servlet/db/LinXIS/countries.xml?_query=/countries/country[name='Belgium']/id(@capital)&_linxis=yes&_howmany=10000
All neighbor countries of neighbor countries of Spain
query:
for $n in /countries/country[name='Spain']/neighbor return
<neighbor>
{$n/name}
{for $n2name in $n/neighbor/name return
<neighborneighbor>{$n2name/text()}</neighborneighbor>
}
</neighbor>
</a>
send query
Extended Links / 3rd Party Links
As "linkbase" serves a preprocessed
memberships.xml
relating a country from countries.xml
with an organization from organizations.xml
where the country is a member of.
Which are the organizations where Germany is a member of?
http://linxis02.ifi.informatik.uni-goettingen.de:8080/exist/servlet/db/LinXIS/countries.xml?_query=/countries/country[name='Germany']/membership/organization/name&_linxis=yes&_linkbase=yes&_howmany=10000
Which are the organizations where both France and Germany are a members of?
query:
let $germany:=/countries/country[name='Germany']
let $france:=/countries/country[name='France']
let $forgs:=$france/membership/organization
let $gorgs:=$germany/membership/organization
return $forgs[name=$gorgs/name]
send query
(takes about 2 minutes)
Tool
Typing complex XQueries into the URL line of the browser might become somewhat uncomfortable over time, especially for queries that consist of more than one line.
here, you can download a small java class (as source code) for sending XQuery statements to the database prototype from the command line/DOS prompt,
using the REST syntax.
Usage:
java ShootXQuery <url> <xqueryfile>
Example:
java ShootXQuery http://linxis02.ifi.informatik.uni-goettingen.de:8080/exist/servlet/db/LinXIS/countries.xml blah.xq
with blah.xq being a local textfile containing the XQuery expression to be sent to the database at the given URL.
Download ShootXQuery.java here.
Have fun!
written by Oliver Fritzen, 19. Sept. 2007