Only a few weeks after SPARQLing Days I’m now finally ready to report some progress…
2005-05-07: Updated to version 0.3, see changelog below.
As is now common knowledge, one outcome of the great gathering in Tuscany is The Gargonza Experiment, which attempts to create a set of showcases for the Resource Description Framework (RDF) and the SPARQL Query Language for RDF
. Already the “community theatre” has gained a bit of steam and an increasing number of followers, and I’m sure there’ll be more to come as people get the stuff they started working on completed. To keep up-to-date, I suggest y’all subscribe to Planet RDF or at least to the Gargonza Experiment category that Danny Ayers — my gracious host for a few days following the main event — is maintaining.
To assist in that goal, I’ve made a subset of my photo description database available for SPARQL queries via Sparqlette — A SPARQL demo query service. The subset currently contains only descriptions of the photos taken during SPARQLing Days, and not all photos have been through my annotation process, there are still some foaf:depicts triples to be made…
The interface/protocol is based heavily on Dave Beckett’s work, especially his Redland Rasqal RDF Query Demonstration, Redland Rasqal SPARQLing, and protocol design in a screenful on public-rdf-dawg, with a few additional implementation details:
- During SPARQLing days Dave fixed an error in librdf_query_results_to_string in CVS, but I only upgrade my Redland installation every now and then, so in the meantime I am relying on a simple PHP function (in librdfutil, unreleased) to do the job of generating (a subset of) DAWG XML, aka SPARQL Variable Binding Results XML Format (lastest syntax draft not yet supported).
- Just like Dave’s Rasqal demo service, Sparqlette accepts an additional
execute=no
parameter, which is handy for adding to a URI that’s otherwise hard to read — it results in the parameters being shown in the HTML form without the query being executed. - Parameters to the XSLT processor are still being discussed, but I made the decision to simply pass all URI parameters on to the XSLT processor with a
sparql_
prefix (of course, that doesn’t work when the XSLT URI is simply referenced from the returned XML as Andy Seaborne does). I have yet to use them for anything though, perhaps a script that converts to HTML could use them for informational purposes. - There is no sorting at this time, the DAWG is still working on that, but I managed to implement a partial
DISTINCT
by using the fact that I was serializing the results to XML myself — it was then simply a matter of taking note of the returned results, not emitting duplicates. This processing only takes places when the query text matches the regular expression/selects+distinct/i
.
A few additional notes gathered while trying it out with the example queries:
- A grouping function would be handy, to make it possibly to ask for e.g. “all things that are persons and the predicate and object of one of their IFPs, if available”. As it is now, I’d get a result “row” for each IFP for each person, but I can see why the DAWG isn’t prepared to tackle this in the first version.
- No doubt about it,
ORDER BY
,LIMIT
, andOFFSET
are essential for just moderately sized results — if not, I would have made my entire photo description database available, not just a subset… - There seems to be either a lack of understanding on my part or a bug in Rasqal, as the two example queries labeled “buggy?” imply. I’m still not sure about which is which, so I’ll have to ask Dave before filing a bug report.
Other than that, I think I’m getting quite happy with how SPARQL is turning out, even if it may be hard for me to implement a full rewrite-to-SQL implementation…
View source for Sparqlette for the full story.
Note: This entry — as all entries in the Release category — will serve as a changelog (you can subscribe to its RSS feed if you want to make sure you don’t miss out on any updates).
The current version is 0.3 (released 2005-05-07).
See also RDF/XML description of Sparqlette.
- Changes since 0.2:
-
- Removed requirement to pass
&format=xml
to get XML results, and changed default value for the parameter to ‘xml’. - Now accepts
&default-graph-uri=
as alias for&data=
. - Fixed to return
text/plain
for NTriples results, as originally intended. - Added
DESCRIBE
-like special case forSELECT
queries with one binding named cbd and a request for anything other than XML. Such a request now returns a Inverse Functional Concise Bounded Description for each binding that is a bnode or URI (example, show query). - Added above example and one for
ASK
.
- Removed requirement to pass
- Changes since 0.1:
-
- Tweaked to handle boolean results as well.
- Upgraded XML output to new editor’s draft (
$Revision: 1.29 $ of $Date: 2005/05/03 09:58:04 $
) of SPARQL Query Results XML Format. Until the community or DAWG decides on another mechanism, useformat=xml1
to get back the old result format. - Upgraded to CVS version of Redland/Rasqal (per 2005-05-03), resulting in switch to turtley syntax for SPARQL. See Rasqal’s To Do List for more information about current status of supported SPARQL features.
- Changed passed XSLT parameter prefix from
sparql_
tosparql-
, and added special (not prefixed) parameters_uri
,_now
with the current time in W3CDTF format, and_id
with a hash of the supplied query to aid with uniqueness requirements (see SPARQL Conversions XSLT for use case).