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

Re: loading rdf/xml from file

From: Dan Brickley <danbri@danbri.org>
Date: Sat, 6 Aug 2011 13:45:28 +0200
Message-ID: <CAFNgM+YnNy9r2+NBZU5u2uM-XLyMhrT_h+9S2jtcZuafJeFwGA@mail.gmail.com>
To: Gregg Kellogg <gregg@kellogg-assoc.com>
Cc: "public-rdf-ruby@w3.org" <public-rdf-ruby@w3.org>
On 5 August 2011 18:45, Gregg Kellogg <gregg@kellogg-assoc.com> wrote:
> 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.

Thanks for the tip! Can you also explain this a bit more in
http://rdf.rubyforge.org/ ? At the moment that page also gives
impression of RDF.rb being a major Ruby hub for Linked Data apps, ...
I had to ask to find out what to do.

Oh, second part of my question: how to load from a file in a
subdirectory...:   graph = RDF::Graph.load("file:rdf/#{pid}.rdf")
...wasn't doing it... but when I removed the file: part, it was fine.
Is it worth supporting file: URIs perhaps?

Anyway, it's working now, thanks! I can get
http://www.w3.org/2001/12/rubyrdf/intro.html updated if folks here
give me suggestions for which newer things I should point to.
Obviously RDF.rb and linkeddata gems; anything else?


> 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 Saturday, 6 August 2011 11:45:56 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:02:15 UTC