Dave Beckett's blog

Raptor 1.4.0 - Serializing RDF

2004-10-24 22:32

Today I announced the release of Raptor 1.4.0 which actually adds a new major part of functionality to Raptor - serializing. Although this is a major change but didn't break older APIs so the temptation to call it raptor2 was only slight.

This means Raptor can now do both parsing: syntax to RDF triples and serializing: RDF triples to syntax. All the icky syntax details now available in one library :) I've been able to delete code from Redland which is great.

Or in terms of the command line rapper utility:

$ rapper -i rdfxml -o ntriples file.rdf > file.nt
$ rapper -i ntriples -o rdfxml file.nt > file2.rdf

which won't give the exact same file out, but it will encode the same triples. (the first example above is actually the default with no options)

Ob Metacomment: in an email I sent to redland-dev answering a question earlier this week I said I'd get round to doing serializing sometime I had a free weekend. As it happens, it took only a couple of lunchtimes this week and a few evenings to get it going. The rest of the evenings and this weekend were needed just for testing that it worked with Redland and Redland Bindings and then more testing and release management of Raptor. So right now, the CVS Redland called via the python binding can do:

$ python
>>> import RDF
>>> model=RDF.Model(storage=RDF.MemoryStorage())
>>> model.load("http://planetrdf.com/index.rdf")
>>> print len(model.to_string(name="ntriples"))
>>> print len(model.to_string())

(and for the Pythoneers reading, yes I overload __str__ so print len(str(model) works too)