ruby-rdf / rdf-turtle

Turtle reader/writer for Ruby
http://rubygems.org/gems/rdf-turtle
The Unlicense
31 stars 9 forks source link

Implicit base_url #4

Closed nyarly closed 11 years ago

nyarly commented 11 years ago

I'm not clear if this is within the Turtle specification, but it seems impossible to produce a turtle document with an implicit base_url - in other words, rdf-turtle will always emit an @base directive.

The use case is a turtle document served over HTTP, where the initial base_url is related to the server's IRI - where e.g. a proxy might change the client's understanding of the IRI, while still presenting sensible relationships between terms.

gkellogg commented 11 years ago

From the code, if base_uri is empty, it will not write out an @base declaration. Can you reproduce the use-case that's giving you problems?

If you don't set the :base_uri option, or you set it to nil, it should not output an @base declaration, but then it won't output relative IRIs either. If you want to output IRIs relative to an @base, it will also output the @base; I'm not sure how you would suppress this; perhaps filtering the output would be easiest? Do you have any specific suggestions of how you see this working?

nyarly commented 11 years ago

Filtering the output is what I'm looking at at the moment - json-ld does something with having a base_uri as well as another attribute for the base-of-relative-uris: the one defaults to the other, but you can force them to appropriate values to get URI relativization as well as leaving the base implicit.