W3C home > Mailing lists > Public > public-rdf-ruby@w3.org > August 2011

Re: loading rdf/xml from file

From: Gregg Kellogg <gregg@kellogg-assoc.com>
Date: Fri, 5 Aug 2011 12:45:12 -0400
To: Dan Brickley <danbri@danbri.org>
CC: "public-rdf-ruby@w3.org" <public-rdf-ruby@w3.org>
Message-ID: <537ABB45-6A8B-4EE4-8CD7-34735C585A8B@kellogg-assoc.com>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 5 August 2011 16:45:55 GMT