Re: loading rdf/xml from file

Dan, you probably want to use the 'linkeddata' gem [1][2][3], which includes RDF.rb and a bunch of parsers, including RDF::RDFXML. The decision was made some time ago to leave RDF.rb lean, with only support for NTriples, and use separate gems to add capabilities (RDFa, N3, RDF/XML, TriX, SPARQL, etc.). The linkeddata gem basically exists to require the basic types.

Try the following:

require 'linkeddata'

g = RDF::Graph.load("http://greggkellogg.net/foaf.rdf", :format => :rdfxml)

:format is only necessary if it can't be intuited from the mime type or extension.

You can also just include the processors you need:

require 'rdf'
require 'rdf/rdfxml'

Gregg

[1] http://rubygems.org/gems/linkeddata
[2] https://github.com/datagraph/linkeddata
[3] http://rubydoc.info/gems/linkeddata/0.3.1/file/README

On Aug 5, 2011, at 8:54 AM, Dan Brickley wrote:

OK, simple question. I want to use rdf.rb to parse some RDF/XML files
in my filesystem. The docs at http://rdf.rubyforge.org/ don't quite
get me there, but I'm sure it must be possible.

I'm left unsure whether Redland/Raptor is needed or not; the existence
of rdf-rdfxml suggests not.

Any chance of a quick code-snippet? I'm sure I can't be the first with
this use case...

cheers,

Dan

Received on Friday, 5 August 2011 16:45:54 UTC