Subject: Proof-of-concept RDF mapping for Atom

From: David Powell <[email-masked]>
Date: Fri, 28 Jan 2005 21:27:11 +0000

I've put together an XSLT stylesheet to map Atom to RDF/XML. It is
just as a proof of concept to see if it is possible. I think it
handles everything except for xml:lang - I'm not sure what's happening
with xml:lang at the moment - but it should be possible to add it in a
similar way to xml:base.

I don't think using an XSLT processor followed by an RDF/XML parser
would be much fun in practise - a SAX based convertor would be much
simpler.

The RDF vocabulary was just constructed ad-hoc - like I said, it is
just a proof of concept.  It uses a separate namespace to Atom and
defines some new terms, which solves any problems with non-unique
attributes.

Here are the main features:

 * Implements draft-04 with PaceExtensionConstruct. Doesn't handle
   xml:lang at the moment, because I think we need to clarify that a bit.

 * Preserves Structured Extension Constructs as XML Literals, for
   round-tripping.

 * Preserves xml:base context for Text, Content, and Structured Extension
   constructs.

 * Handles author defaulting.

 * Resolves URI references using xml:base

There are some more comments at the top of the file.

You need <http://djpowell.net/tmp/atom2rdf.zip> - which contains:

atom2rdf.xsl - the transform
urires.xsl   - URIRef resolver used by the transformer
example.xml  - an example feed

You can run the transform using Xalan
<http://xml.apache.org/xerces2-j/> using:

java -jar xalan.jar -IN example.xml -XSL atom2rdf.xsl -OUT rdf.xml

Part of the implementation is an XSLT based URIRef resolver - you can
try that here in your browser: <http://djpowell.net/tmp/uritest.xml>

-- 
Dave

---

From: David Powell <[email-masked]>
Date: Fri, 28 Jan 2005 22:17:18 +0000

Friday, January 28, 2005, 9:27:11 PM, you wrote:

Sorry, that version created duplicate rdf:nodeIDs. I've fixed it now,
the new version is 9826 bytes.

-- 
Dave

---

From: Danny Ayers <[email-masked]>
Date: Sat, 29 Jan 2005 12:13:51 +0100

On Fri, 28 Jan 2005 21:27:11 +0000, David Powell 

> with xml:lang at the moment - but it should be possible to add it in a

Marvellous! 

> would be much fun in practise - a SAX based convertor would be much

Hmm, that's actually quite an interesting question...

> defines some new terms, which solves any problems with non-unique

That makes sense. Hopefully it should be possible to narrow down the
terms in a way that they can all coexist in the Atom namespace.

One question - do you have a permanent URI for this?

Cheers,
Danny.

-- 

http://dannyayers.com

---

From: Sam Ruby <[email-masked]>
Date: Sat, 29 Jan 2005 20:10:18 -0500

> would be much fun in practise - a SAX based convertor would be much

Those two are not incompatible.

Example: Xalan can accept a SAX input stream and can produce a SAX input 
stream.  Jena can accept a SAX input stream.

Some XSLT constructs (example: sort) can effectively render this moot, 
but overall Xalan tries really, really hard to stream.

- Sam Ruby

---

From: David Powell <[email-masked]>
Date: Sun, 30 Jan 2005 01:31:58 +0000

> but overall Xalan tries really, really hard to stream.

I meant, although:

  XML --[XSLT]--> RDF/XML --[RDF/XML-parser]--> RDF-model

...is an ok reference implementation for demonstrating an RDF mapping,
the mapping should be defined in prose, because:

  XML --[SAX]--> RDF-model

...would be a lot more efficient and doesn't have so many
dependencies. So basically you could navigate the Atom document, and
add appropriate statements to an RDF model using the model API.

-- 
Dave

---

From: Robert Sayre <[email-masked]>
Date: Sat, 29 Jan 2005 20:56:07 -0500

David Powell wrote:

>...would be a lot more efficient 
>

I think the mapping should be normatively defined w/ XSLT. It meets the 
cross-platform requirements of the IETF and is unambiguous. Of course, 
it had better be really good! If someone wants to optimize with a SAX 
version, they still can.

Robert Sayre

---

From: Sam Ruby <[email-masked]>
Date: Sat, 29 Jan 2005 21:23:59 -0500

> add appropriate statements to an RDF model using the model API.

If one were to package Jena and Xalan into a single jar, you get 
something very much like your latter picture above.  Expanding it, you get:

   XML --[Xalan]--> SAX --[Jena]--> RDF-model

Note: you never produce an complete intermediate RDF/XML representation 
(either as a DOM or as a string), everything is via pipelined SAX 
processing.

An example of an application which leverages such an approach (as well 
as sophisticated caching) can be found at http://cocoon.apache.org/2.0/

- Sam Ruby

---

From: Henry Story <[email-masked]>
Date: Sun, 30 Jan 2005 11:49:30 +0100

On 30 Jan 2005, at 02:31, David Powell wrote:
> [snip]

This sounds very much like saying that it would be easiest if one
could interpret Atom directly to be RDF, as proposed by AtomAsRDF.

This can be brought back to the question of how to choose the a
model to map Atom to. Here are some initial possibilities:

	- choose RSS1.0 or RSS1.1 as the model. Being so flexible it
       should be quite easy to map Atom to those flavors of RSS. If
       that were possible, then this would be just another way of
       saying: anything you can say in Atom you can say in RSS1.x
     - create some new model to map atom to: in which case you have
       to invent a whole new model and go through all the problems of
       working out the consistency of your model that this group has
       gone through with Atom.

In any case the model you come up will either be:
      a. more expressive than Atom: you can express more in the
         model than you can in Atom.
      b. less expressive: when mapping from Atom to this model you
         will loose information
      c. isomorphic with Atom: you can map from atom to your model
         and back without information loss either way.

If your model is a. more expressive or b. then this will not prove to
be a good foundation for explaining extensibility clearly, since you
will loose information either by mapping to the model or by mapping back
to Atom. So really what we require is an isomorphic model. And the
isomorphic model that would be the easiest to understand would clearly
be the identity model where Atom can be interpreted as RDF.

We are not quite there. There is a mapping from Atom to something very 
close
to Atom, so close I argue that the Atom working group could easily take
a few steps to make the mapping be the identity map.

Henry Story
http://bblfish.net/

---

From: Bill de hÓra <[email-masked]>
Date: Sun, 30 Jan 2005 16:05:57 +0000

Robert Sayre wrote:

> I think the mapping should be normatively defined w/ XSLT. 

+1. I have no problem with defining the mapping in XSLT. Executable 
specs are a wonderful idea.

cheers
Bill

---

From: Danny Ayers <[email-masked]>
Date: Sun, 30 Jan 2005 18:00:54 +0100

> specs are a wonderful idea.

+1.

There still quite a margin for error but XSLT could very neatly
provide something deterministic, and ties in nicely with GRDDL. The
mapping won't really be complete without an RDF/OWL schema (and
probably not even then, given some of the Atom constructs), I would
expect that to form part of the I-D (or however it's presented).

 Another benefit of XSLT is that it should be pretty easy to hook onto
a Atom/XML validator to pass to the W3C RDF validator.

Cheers,
Danny.
-- 

http://dannyayers.com

---

From: David Powell <[email-masked]>
Date: Sun, 30 Jan 2005 18:51:58 +0000

> terms in a way that they can all coexist in the Atom namespace.

Possibly, but I'm not sure how important it would be.  Being able to
globally identify an XML attribute, isn't all that useful.

Being able to globally identify the property that the XML attribute
implies is more useful - and that is what an RDF mapping would enable.

The RDF mapping is going to need to reserve terms under a namespace
for Classes and other concepts that don't directly appear in the
Atom/XML syntax - so using a separate namespace doesn't seem like a
bad idea.

> One question - do you have a permanent URI for this?

I've just made a page: http://djpowell.net/atomrdf/0.1/

I fixed a couple of bugs since I last posted.  I've also made an RDFS
for it.

Dan Brickley pointed out that you can test the XSLT using the W3C's
XSLT service, rather than having to download an XSLT processor.

http://www.w3.org/2001/05/xslt

-- 
Dave