Category Archives: XML

http://www.w3.org/XML/

SPARQL and SIMILE Timeline

Danny Ayers has been working on getting the SIMILE Timeline to eat SPARQL through the use of its JSON interface and some XSLT, he has notes on the ESW wiki.

While trying to get his work running here, I realized that the trip through XSLT to create JSON output really wasn’t necessary.

Instead, I’ve created a custom SPARQL event source parser, to load SPARQL results directly into the timeline. This way, the SPARQL results format generated by running the query doesn’t need a round trip into either JSON or the custom Timeline XML format.

The SPARQL Timeline demo works with any RSS 1.0 feed (try it with the one from Planet RDF) .

Update: Now also works with “raw” SPARQL results, try it with photos of laptops from The Gargonza Experiment (scroll to April of 2005). Expected variable bindings are date, title, description, and link, although the latter is optional and the first can be replaced by start.

Update: Now really works with “raw” SPARQL results. Due to javascript’s security model, only files on this server worked — until now. Also, a buglet regarding empty literal elements have been fixed.

RDF as XML

Over the last week, Planet RDF has seen more than a few posts and comments on the RDF/XML serialisation syntax, most of them looking into its (almost not enumerable) possible variations.

Danny Ayers has a great overview with reference to the expectations, not an unimportant point — as my boss always tells me: It’s all about controlling expectations.

All in all, I agree with most of the comments on the subject, even parts of the ones that don’t seem to agree with each other.

In short: RDF/XML is just a syntax (it’s the RDF model that counts), and while I generally find it acceptable, the variation is one aspect I hope I would have done different had I been involved. That would make it more accessible to XML tools such as XSLT, leading to easier ways of generating clean XML for other uses.

The subject of RDF/XML variation is as close to being a permathread as it can be, and I’ve participated before myself, mostly with regard to the R3X syntax subset. I’ve been doing a lot of XSLT as well, and three recommendations come to mind when considering a syntactic profile or subset of RDF/XML, to reduce the variation:

Drop the attribute form
Except for aesthetic reasons, it’s not necessary.
Don’t use typed nodes
While it may seem easier and smarter to write <foaf:Person>...</foaf:Person> than <rdf:Description><rdf:type rdf:resource="&foaf;Person"/>...</rdf:Description>, it makes it much harder to deal with nodes that have multiple types (and using named entities can help a lot too).
Sort and group
‘nuf said — don’t break statements about the same subject into different elements, keep them together and don’t nest at all.

That said, I don’t consider the deficiencies of RDF/XML to be serious enough to warrant a new XML syntax — after all, there are plenty of RDF/XML parsers out there by now, and the real challenges lies elsewhere (see: Crisis, LargeTripleStores, and Tagtriples + identity precision).

OWL-S Maker

There’s lots of talk about service descriptions these days, most notably around Tim Bray’s WSDL discussions (which includes SMEX-D), Norm Walsh’s NSDL for WITW, and the DAWG’s Saddle, to be a part of the SPARQL protocol. Phew, acronym overload…

Also in that space is OWL-S, an OWL-based Web service ontology that Danny Ayers has looked at. I though it would be fitting to describe semantic web services with RDF, so I tried it out but ended up feeling quite like Norm after his WSDL endeavour.

I did however manage to get something working, OWL-S Maker, which only uses a subset (and possibly in a wrong way), but is self-powered through its own service description, a PHP class (which currently has too many local dependencies to be worth anything to anyone but myself), and some XSLT. The descriptions could use some more work regarding the “typing” of inputs, but I thank Saddle may eventually provide some insights there. As for the general modelling of services, input, and output, I think I may have to look elsewhere — OWL-S seems too complicated.

As a usage example, see the Sparqlette service description input and the description of nearestAirport for a partially handcrafted example with two profiles.

SPARQL Conversions XSLT

To help develop and test my new Sparqlette service, I hacked a couple of XSLTs that might come in handy here and there…

SPARQL to RSS (lastest version: 0.3)
As its name implies, this XSLT turns a SPARQL Query Results XML Format document (Variable Binding Results) into an RSS channel, making it possible to subscribe to the results of an (almost) standard SPARQL query without using CONSTRUCT. As can be expected, not all query results work, as the RSS specification mandates certain elements. Thus, the value of the channel’s rss:link property is taken from an XSLT parameter named _uri, the variable bindings to use for rss:link and rss:title in each item is determined via some crude heuristics, and only items that have a URI for the chosen rss:link binding are created.

Variable selection heuristics for rss:link / rss:title:

  1. If there’s a variable named rsslink or rsstitle respectively, the bindings for that variable is used for all items.
  2. Otherwise, the first variable that has a binding to a URI is used for rss:link, and the first variable that has a binding to a literal is used for rss:title

For rss:link I wanted to add another option between the two, that would locate a variable that only has bindings to URIs, but I couldn’t get it working with a single XPath expression, so I gave up.
Example RSS (view Sparqlette input parameters).

SPARQL to SPARQL (latest version: 0.1)
This XSLT simply converts documents in the syntax of any of the currently two SPARQL Query Results XML Format draft specifications, W3C Working Draft 21 December 2004 and $Revision: 1.29 $ of $Date: 2005/05/03 09:58:04 $, into the syntax of the latest version, currently the latter. I promise to do my best to stay up to date…

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).

Friendly Reviews

Things have been a bit hectic lately, but I have actually managed to make something that might be worth going public with. (Actually, I’ve already pointed it out on #swig, but that’s another matter.)

Over at FilmTrust they let you not only rate and review movies, but also connect with your friends to see what kind of movies they like. Of course, this being a service from the first site on the Semantic Web, it offers a nice FOAF document, like mine.

As you can see, it contains information about the reviews I’ve written and a list of my friends, with rdfs:seeAlso‘s provided for the latter, which makes it possible to create an RSS feed with some XSLT and use of the document() function, like this: FilmTrust reviews by mortenf and friends. The output is generated via W3C’s XSLT Service — note how at least three URIs are involved in this, that’s (minimal) REST for you. Oh, let’s add another one: Via the Syndication Subscription Service.

A nice addition to the original source FOAF would be dates on the reviews — that’d make it possible to limit the size of the resulting RSS file. As it is, there’s no way to know which are “new”. Also, there are some escaping issues on FilmTrust, I had to remove golbeck and sbp from my friend list to get a running example…

Note that the XSLT takes an optional parameter, user-only. That’s provided in case you’re only interested in your own reviews — I use this to drop them into my personal planet feed.

Try subscribing to reviews from your own social network!