New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content negotiation in RDF.rb clients #12
Comments
It would be great if multiple HTTP clients were supported, for example http://github.com/toland/patron |
Readers/format classes should implement simple Regexp test on content to be parsed, if format not detected from extension, mime-type or explicit request. For instance:
|
Related issue #24 (with regards to improving the HTTP client functionality). |
More from a recent email response to hellekin at cepheide.org: RDF::Reader.for needs to be somewhat smarter. The symbol case is limited to using an element of the classname (e.g. RDF::RDFXML => :rdfxml). It would be nice to specify alternate symbols (e.g., :rdf). Of course, this can be done through for(:extension => "rdf"). Heuristically detect the input streamdef detect_format(stream) Got to look into the file to seeif stream.respond_to?(:rewind) This could instead be found by looping through available Format subclasses and looking for a #match method. Within RDFXML::Format, I could perform the following: class Format < RDF::Format content_type 'text/turtle', :extension => :ttl reader { RDF::N3::Reader } def match(content) In RDF::Reader.open, first look for a reader using the options. Then, failing that, open the file and look for a mime-type, failing that, loop through Format instances and see if the Format matches the string content. In most cases, this will do what the user expects. |
RestClient may be of interest: |
This one looks pretty interesting too: |
Recently I needed to re-visit this issue in RdfContext to support RDFa 1.1 profiles. Profiles are a mechanism for defining RDF prefixes and terms in a separate document. The spec encourages implementer to cache these vocabularies, for obvious reasons. I implemented this using a ConjunctiveGraph, which is a graph over all quads within a Store (or Repository). When I see a profile, I look for it as a context within the ProfileGraph and download, parse it and add it to the store as necessary. To do this in RDF.rb is difficult, because RDF::Reader.open inverts finding the reader and opening the resource. Ideally, the resource should be opened first so that, for example, mime-type can be retrieved to perform content-negotation, and the resource can be inspected to see if it is up-to-date. The following is a potential refactor of RDF::Reader.open that extracts the open and provides the same simple Kernel.open implementation. This makes it easier for another module to override this, or perhaps to register an alternative reader to provide better HTTP semantics. module RDF
end There still remains the question of how best to implement this in RDF::RDFa, but that is a different conversation. |
Since 0.3.4, RDF.rb can perform format detection in RDF::Reader.for (or RDF::Format.for with :sample option or a block which returns a sample). Of course, content-negotiation is handled using rack-linkeddata or sinatra-linkeddata (and soon rack-sparql or sinatra-sparql). |
Try running the specs in Ruby 2.0.0 and head
http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0024.html
Implement content negotiation in RDF.rb clients. Ideally with q= values for each of the supported parsers.
I would like to be able to do this:
The text was updated successfully, but these errors were encountered: