This is a demo of the reasoning capabilities described elsewhere. To
work through the demo, you need to have a Quaestor service running
inside a Tomcat server: I'll take that to be running at http://localhost:8080/quaestor. You need at least Quaestor v0.3.
The Quaestor interface is documented on the front page of the
Quaestor server. It uses the HTTP protocol commands to manipulate
then query the server, so you need curl or some other
tool which can generate HTTP GET, PUT and
POST commands (the wget program can do
POST, but not PUT). Or you can just talk
HTTP yourself, using telnet.
The HTTP demo
First, create a new knowledgebase, with a PUT
command. Call the knowledgebase `testing', and read a simple metadata
string from stdin:
% curl --upload-file - \
--header content-type:text/plain \
http://localhost:8080/quaestor/kb/testing
My test knowledgebase
^D
%
Note that we have to tell Quaestor that the input is plain text. As an alternative, you can describe the new knowledgebase using RDF.
If you add the --verbose flag to the curl
command line, you will see (instructive?) protocol chatter, as well as
the 204 (no content) return code from the server.
Retrieving the URL http://localhost:8080/quaestor/kb,
either using curl or in a web browser, will show you that
you have created this knowledgebase. You can delete the knowledgebase
with the HTTP DELETE operation, though you have to do
this by hand, since curl doesn't support this:
% telnet localhost 8080Trying ::1... Connected to localhost. Escape character is '^]'.DELETE /quaestor/kb/testing HTTP/1.0HTTP/1.1 204 No Content Server: Apache-Coyote/1.1 Date: Thu, 13 Apr 2006 10:02:53 GMT Connection: close Connection closed by foreign host.%
Now you can add to the knowledgebase the three sets of assertions
contained in files access-control.owl,
instances.n3 and identity.n3. Add these to
the knowledgebase submodels ontology,
people and identities respectively (the
names are arbitrary, and you can use alternatives if you wish).
% curl --upload-file access-control.owl \
http://localhost:8080/quaestor/kb/testing/ontology \
--header content-type:application/rdf+xml
% curl --upload-file instances.n3 \
'http://localhost:8080/quaestor/kb/testing/people?instances'
% curl --upload-file identity.n3 \
http://localhost:8080/quaestor/kb/testing/identities
%
The two .n3 files are written in Notation 3; this
is the default MIME type which Quaestor expects. The
access-control.owl file, however, is written in the
RDF/XML serialisation, and so we must add an appropriate
Content-Type header to the upload.
The instances.n3 file is uploaded with a
?instances query attached -- this tells the reasoner that
these are assertions about individuals rather than types; this
distinction is currently important.
If you now look again at http://localhost:8080/quaestor/kb you will see the
knowledgebase and its submodels listed.
You can retrieve the individual submodels from the Quaestor service:
% curl http://localhost:8080/quaestor/kb/testing/people
will respond with the contents of the people submodel
in the default Notation3 format (MIME type text/rdf+n3),
and if you add --header accept:application/rdf+xml to the
curl command, you'll
get it in RDF/XML again. If you retrieve
http://localhost:8080/quaestor/kb/testing you'll get the
union of the three submodels.
There are several SPARQL queries in the demo for you to try. The
query access-all.rq is:
prefix : <http://eurovotech.org/access-control.owl#>
select ?person
where { ?person a :CanSeeAllData }
You can post this file with an HTTP POST request:
% curl --header content-type:application/sparql-query \
--data-binary @access-all.rq \
http://localhost:8080/quaestor/kb/testing
[...]
%
This should respond with an XML document which conforms to the SPARQL response
scheme. If you add --header accept:text/plain or
--header accept:text/csv to the
command, the reasoner will produce a response in the corresponding
format. There are several other queries you can try:
norman@astro.gla.ac.uk is allowed to see all the data.construct query to obtain a query
result in RDF.Finally, you can delete the knowledgebase with the HTTP
DELETE command, as illustrated above.
The XML-RPC demo
Quaestor also has an XML-RPC interface, with an endpoint at
http://localhost:8080/quaestor/xmlrpc, though it has
rather less functionality at present.
The file xmlrpc-get-model.xml
contains an XML-RPC method call:
<methodCall> <methodName>get-model</methodName> <params> <param><value><string>testing</string></value></param> </params> </methodCall>
You can post this to the server as follows:
% curl --header content-type:text/xml \
--data-binary @xmlrpc-get-model.xml \
http://localhost:8080/quaestor/xmlrpc
%
and get a response which simply indicates that you should dereference another URL.
Slightly more useful is the query-model method,
illustrated in xmlrpc-query-model.xml. This makes a
SPARQL query against the model, and returns a URL which can be
dereferenced to pick up the query results.
Links
There are SPARQL tutorials at
http://www-128.ibm.com/developerworks/xml/library/j-sparql/
and
http://jena.sourceforge.net/ARQ/Tutorial/.
The (rather informal) XML-RPC spec is at
http://www.xmlrpc.com/spec.