Sam Ruby has come up with an XSLT stylesheet, which transforms Atom XML into RDF/XML. Sam said it was hard, which led to Sjoerd Visscher's creating a simpler version which takes advantage of his generic XML -> RDF mapping system XR.
All very laudable - I do think XSLT can be great tool for matching XML to RDF. But it's worth noting that it isn't always necessary to use RDF/XML to use the RDF model with XML. A direct mapping from the XML to the RDF model can be specified without actually having to carry out any transform. As long as it is clearly asserted that the data is RDF, the information can be extracted programmatically (e.g. parsing Atom directly into an RDF store) without having to explicitly transform every time. The XML effectively becomes a limited, task-specific syntax for RDF. Similarly the XML syntax (Atom or whatever) can be generated directly by applying simple queries to the model.
The XSLT mapping approach is used in the Simple Semantic Resolution module for RSS 2.0.
Uche Ogbuji is an advocate of the transformation approach (and
has a system in which to do it :
4suite, note also their
Versa RDF
query language).
In an
article
he goes as far as to assert :
"There is no syntax"
. (This came up in
comments
only yesterday).
Although XSLT is useful, the programmatic approach can be easier
and more efficient.
Let's say we've got the serialization bit of our Atom code,
something like :
String createEntry(String content){
...
}
(mightily simplified over the true syntax for demonstration
purpose, and this would probably be done in an entry
class…)
To get this bit of the Atom syntax we might just return
something like :
return "<entry>"+content+"</entry>";
But as we build up the Atom syntax string, we could
simultaneously pass a call to an RDF API such as
Jena :
resource = model.createResource();
resource.addProperty(ATOM.content, content);
(the Model class is used to hold the RDF model data,
ATOM.content will be a static property type)
When done, we can get the serialization of the RDF model from the API with built in method calls, or process the RDF model internally - Jena has some very cool query and inference facilities.
Similarly, we could could load data into an RDF tool like Jena using either a custom parser for the Atom syntax, or by adding a filter incorporating lines like those above to create different parts of the model as e.g. a SAX-like parser encountered different elements in the Atom syntax.
[Danny Ayers]