- From: Gregg Kellogg <gregg@greggkellogg.net>
- Date: Wed, 27 Nov 2013 08:49:22 -0800
- To: Ian Dickinson <i.j.dickinson@gmail.com>
- Cc: "public-rdf-ruby@w3.org" <public-rdf-ruby@w3.org>
On Nov 27, 2013, at 8:43 AM, Ian Dickinson <i.j.dickinson@gmail.com> wrote: > Hi all, > I'd like to write a graph that I've created, as Turtle, but using > additional @prefix declarations for the new triples I've added. > > So: > > 2.0.0p247 :006 > g = RDF::Repository.new > => #<RDF::Repository:0xc51354()> > > 2.0.0p247 :007 > v = RDF::Vocabulary.new( "http://foo.com/schema#" ) > => #<RDF::Vocabulary:0xc58258(http://foo.com/schema#)> > > 2.0.0p247 :008 > g << [v.s, v.p, v.o] > => #<RDF::Repository:0xc51354()> > > 2.0.0p247 :009 > g.to_ttl > => "\n<http://foo.com/schema#s> <http://foo.com/schema#p> > <http://foo.com/schema#o> .\n" > > 2.0.0p247 :016 > g.to_ttl( prefixes: {foo: "http://foo.com/schema#"} ) > => "\n<http://foo.com/schema#s> <http://foo.com/schema#p> > <http://foo.com/schema#o> .\n" > > What I'd like to happen is (something like): > > 2.0.0p247 :016 > g.to_ttl( prefixes: {foo: "http://foo.com/schema#"} ) > => "@prefix foo: <http://foo.com/schema#>.\nfoo:s foo:p foo:o .\n" > > Any suggestions? That should be farily straight-forward to do. Note that you can also do the following: 2.0.0-p353 :007 > g.dump(:ttl, prefixes: {foo: "http://foo.com/schema#"} ) => "@prefix foo: <http://foo.com/schema#> .\n\nfoo:s foo:p foo:o .\n" Other things typically used by writers are :base_uri, and :standard_prefixes. Create an issue, or better-yet, a pull request, to get it included. Gregg > Thanks, > Ian >
Received on Wednesday, 27 November 2013 16:49:53 UTC