RDFa in Ruby, a First Stab

A new draft of RDFa [1] has been out for about a month now, and it got me to thinking about RDF again. This time, the geek in me saw the opportunity to use easily use RDF in my Atom based applications. Instead of using embedded micro formats in Atom Entries, I can create semantic relationship using preexisting ontologies (e.g. - DublinCore) in an easy to read format.

The XML generation side had near zero work thanks to Ruby On Rails' rxml format. But I was lacking a parser to read in the RDF statements even though there were a few Ruby RDF Stores available. The only RDFa parser I found was written in Python-- rdfadict.

So, I just set aside parts of the last two days and came up with my own super simple Ruby RDFa parser; I read and reread the RDFa Syntax draft document, which is still far from complete; I skipped implementation of parts of the spec: xml:base, reification, and nested CURIEs; and got something to just work. (Note: rdfadict uses XPath for its implementation. Instead, I used an iterative approach to traverse XML documents).

Basic parsing works; I also made it flexible enough for custom integration; I just need to spend time to write up the documentation and write up more test cases. I'll move forward with it as the RDFa spec develops and when I get feedback from anyone that uses this library.

But for now, the code is hosted here: http://code.google.com/p/ruby-rdfa/.