Nature Quote

There’s a short article in Nature (subscribers only I’m afraid) this week about Google Base and its potential impacts on the science community. In particular whether it might galvanise greater data sharing between scientists.
I’ve been corresponding with Declan Butler, the author of the piece, on this and some related topics recently, and he ended up quoting me:

Open Mapping System?

I’ve been playing with Google Maps a bit for a talk I’m giving on Monday. It’s addictive stuff.
But I’d like to be able to use alternate kinds of maps. E.g. plotting Samuel Pepys’s diaries on a historical map of London, or points on a sonar map of the sea, or views of MMPORG maps.
It’s lead to me to wonder: has anyone written a general purpose front-end similar to Google Maps? Basically all of the Ajax/DHTML magic, but without the actual Google supplied tiles? It’d be interesting to have that and then be able to plugin in different server-supplied tiles, perhaps on the fly (e.g. radar vs satellite images).
The whole client-side framework would be portable I think. It would be an interesting way to explore any data set that can be visualised in two dimensions.
Anyone already done or doing this? Drop me a mail if you are.


Alf Eaton posts today to point to the new WebCite service. This is going to be very useful. Don’t think so? Well there’s plenty of research to show that link atrophy is a big problem in scientific literature:
Persistence of Web References in Scientific Research
See also: A study of missing Web-cites in scholarly articles: towards an evaluation framework which reports that “[a]fter evaluating 2162 bibliographic references it was found that 48.1% (1041) of all citations used in the papers referred to a Web-located resource. A significant number of references to URLs were found to be missing (45.8%)…


I’ve been enjoying a bit of SPARQLing recently and you can now begin to see some of the results: has published the first part of my SPARQL tutorial. The tutorial is backed with a SPARQL query service that I whipped up using Jena. As the documentation explains there are several output options supported by the service including JSON and a quick Javascript hack, so incorporating SPARQL results into your applications (or blog!) has never been easier. The AJAX client is coming along nicely too, although I need to test in Opera and write up some proper examples.
The SPARQL service is part of a wider project to expose a number of markup and Semantic Web tools to the web for people to play with. Implemented, but not yet documented, are some basic RDF graph algebra and a rules engine; basically putting bits of Jena functionality on the web.
I’ve also started implementing an RDF data storage system. Again this involves wrapping up Jena functionality as a web service. Eventually you’ll be able to sign-up and create some triple stores and interact with them using a RESTful API, plus SPARQL queries. In addition I’ve constructed a little language, kind of a Scutterplan++ that describes not only the sources of your store, but some processing to do on it after the data is collected. For example smush it then apply some inferencing. More on that when things are a bit less vapoury.
There’s the obligatory project blog so you can follow along there if you’re interested.

Writing an ARQ Extension Function

The core SPARQL specification provides some hooks for extension in the
form of Extensible
Value Testing
. This allows an application to provide custom functions for
testing variables in a SPARQL query, where the
built-in tests
don’t cover a particular need.

The specification notes that: SPARQL queries using extension functions are likely to have
limited interoperability
, so you should use them with some care. The processing
of implementing a custom function and registering it with your query engine will be bespoke to that API.

Caveats aside, I think it’s likely that once SPARQL sees further adoption a number of
useful functions will be identified by the community. The process of ensuring that such
functions are ported across differing SPARQL implementations could be the job of a
community initiative. Just like the EXSLT initiative
has helped standardise XSLT extensions functions; many of these were incorporated in
the more recent XSLT specifications.

So lets take a quick look at how to implement a custom extension function using

Read More »

Parameterised Queries with SPARQL and ARQ

When writing queries for an application, whether for an SQL or an RDF data source, its common to end up with a core set of queries that are used time and again. Typically these queries vary only in the values of a few variables.

For example, you might have a query to lookup details of a user (name, homepage, etc) with the variable being the value of the user identifier. The same query is used for all users, you just want to substitute a different value for the variable on each execution.

In Java the JDBC API provides support for this usage using a PreparedStatement object. The ARQ SPARQL query API also provides support for this kind of parameterised query. Here’s some example code that illustrates the technique.

Note: to make use of this technique you’ll have to grab the latest CVS version of ARQ. One of the classes below (QuerySolutionMap) only got added this weekend.

First up lets create a sample SPARQL query, to extract the name of a foaf:Person based on the URL of their weblog:

PREFIX foaf: <>
SELECT ?name
?x foaf:name ?name.
?x foaf:weblog ?blog.}

You can see that we’ve got two triple patterns in the query. One to match the person’s name, the other to match their weblog URL.

Here’s a code snippet to show how to execute the query and supply the value of the blog variable at runtime:

//create a Jena model to query against
Model model = ...
//create a node for our variable
RDFNode blog =
//store the node in a QuerySolutionMap
QuerySolutionMap initialBindings = new QuerySolutionMap();
initialBindings.add("blog", blog);
//here's the query
String queryString =
"PREFIX foaf: <>" +
"SELECT ?name " +
"WHERE {" +
"?x foaf:name ?name." +
"?x foaf:weblog ?blog.}";
//create the query object
Query query = QueryFactory.create(queryString);
//execute the query over the model, providing the
//initial bindings for all variables
QueryExecution exec =
QueryExecutionFactory.create(query, model, initialBindings);
ResultSet results = exec.execSelect();
//now format the results...

The code snippet is a fairly typical example of running a SELECT query using ARQ. The key difference is the use of a QuerySolutionMap. This class implements the QuerySolution interface, and when used in this context, i.e. as a parameter to the QueryExecutionFactory.create() method, provides the initial bindings for variables in the query.

The class is basically a map of variable names to RDFNode objects, so you can add as many of them as you like.

Using this style of query usage means that you can reuse queries, thereby avoiding the need to do string concatentation or API methods to construct the query dynamically.

While I’m at it, here’s another useful tip for folk working with FOAF data. The ARQ function library contains a little function to calculate the sha1sum of a literal or resource value.

Here’s an example query that uses the function:

PREFIX jfn: <java:com.hp.hpl.jena.query.function.library.>
PREFIX foaf: <>
SELECT ?name
?x foaf:name ?name.
?x foaf:mbox_sha1sum ?sha1.
FILTER ( ?sha1 = jfn:sha1sum(?email) )}

As before we can provide an initial binding that will set the value of the email variable when the query is executed

//create initial binding for email variable
RDFNode mbox = model.createResource("");
QuerySolutionMap map = new QuerySolutionMap();
map.add("email", mbox);
//as before, create and execute query..

First Jena User Conference

HP Labs have announced the first Jena User Conference to be held at the labs in Bristol on 10th-11th May 2006.
As the website notes, the conference will include presentations on:

  • applications and tools developed by Jena users
  • demos
  • in-depth explorations of Jena features
  • tutorials
  • discussions about the future development of Jena

See the call for submissions for details of how to submit a demo, position or workshop paper.
Should be a fun couple of days. It’s the week before XTech 2006 so no clashes for those of you who might want to attend both.