Ivan’s private site

June 11, 2007

“Friendly talks”, a.k.a. I had some fun with SPARQL and Exhibit…

Filed under: Semantic Web,Work Related — Ivan Herman @ 14:25

David Huynh sent me a mail on a cool feature he has just added to Exhibit 2.0: he’s put a shortcut to the Babel service. What this means is that one can refer to an RDF/XML, Excel, or a BibTex file instead of the JSON code, and Exhibit will convert it to RDF on the fly. So, to try it out, I put together a small example: the list of the W3C related talks of my buddies, ie, people whose name appear in my foaf file. And the remarkable thing is that this needed around 20-25 minutes (including chasing some stupid misspelling in the SPARQL query:-). And here is how it works:

First of all, the W3C Talks’ system is based on RDF: all data are stored in (public) RDF files and the interface, the query, etc, is just a front-end to the data. (The links to the relevant RDF files can be found at the bottom of the Talks’ page). I could therefore come up with a SPARQL query which looks more or less as follows (I omitted the namespace declarations from here):

    [] rdf:type talk:Talk;
       dc:date ?date;
       foaf:name ?name;
       talk:event ?event;
       vcard:Locality ?city;
       vcard:Country  ?country;
       dc:title ?title.
FROM <http://www.w3.org/2004/08/TalkFiles/2006/Talks.rdf>
FROM <http://www.w3.org/2004/08/TalkFiles/2006/WWW2006.rdf>
FROM <http://www.w3.org/2004/08/TalkFiles/2006/BeijingEvent.rdf>
FROM <http://www.w3.org/2004/08/TalkFiles/2007/Talks.rdf>
FROM <http://www.w3.org/2004/08/TalkFiles/2007/WWW2007.rdf>
FROM NAMED <http://www.ivan-herman.net/foaf.rdf>
    GRAPH <http://www.ivan-herman.net/foaf.rdf> {
        [] foaf:knows [ foaf:name ?name ].
    ?talk dc:title ?title;
          dc:date ?date;
          talk:presenter ?person;
          talk:event [
              ical:description ?event;
              vcard:Locality   ?city;
              vcard:Country   ?country
    ?person contact:fullName ?name.

This query can be run on a SPARQL endpoint (I used SPARQLer for this one) via the SPARQL Protocol, using a suitable URI. The URI is actually pretty ugly, so I made a tiny url out of it, and I simply plugged this tiny uri as a data source for Exhibit in the HTML header. And, voilà!, the data displays. A bit of tweaks on the Exhibit lenses to make it a little bit nicer, define the facets, that sort of things, and put it on the Web. And the beauty is the typical mashup effect: if I add a new person to my foaf file or a new entry is added to the W3C Talks’ data, the display remains up-to-date… All data used here are pure RDF/XML files but, if the SPARQL endpoint understood, say, GRDDL on the fly, then I could have used my W3C Homepage as a datasource, too…

One issue that I find interesting/important here is the crucial role of the CONSTRUCT facility of SPARQL, which adapts the output of the Query to Exhibit. I have the impression that, when talking about SPARQL, we do not emphasize enough what a great feature this CONSTRUCT is. A SPARQL endpoint acts as an RDF transformation engine which is really powerful.


Blog at WordPress.com.

%d bloggers like this: