Skip to content
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

Client#query detecting wrong format? #5

Closed
cldwalker opened this issue Jun 8, 2010 · 3 comments
Closed

Client#query detecting wrong format? #5

cldwalker opened this issue Jun 8, 2010 · 3 comments
Labels

Comments

@cldwalker
Copy link
Contributor

I get the following error:
>> client = SPARQL::Client.new('http://data.linkedmdb.org/sparql')
>> result = client.query('DESCRIBE ?kb WHERE { ?kb http://data.linkedmdb.org/resource/movie/actor_name "Kevin Bacon" . }')
>> result.map {|e| e.to_hash }
RDF::ReaderError: expected subject in #StringIO:0x19b37f4 line 2
from /Library/Ruby/Gems/1.8/gems/rdf-0.1.10/lib/rdf/reader.rb:177:in fail_subject' from /Library/Ruby/Gems/1.8/gems/rdf-0.1.10/lib/rdf/ntriples/reader.rb:176:inread_triple'
from /Library/Ruby/Gems/1.8/gems/rdf-0.1.10/lib/rdf/ntriples/reader.rb:170:in loop' from /Library/Ruby/Gems/1.8/gems/rdf-0.1.10/lib/rdf/ntriples/reader.rb:170:inread_triple'
from /Library/Ruby/Gems/1.8/gems/rdf-0.1.10/lib/rdf/reader.rb:165:in `read_statement'

I printed debug statements and found the error was occurring on the first line of the result on @prefix. Here's the results returned by the above query. Since @prefix is n3 notation, it seems @client.query is detecting the wrong format in @client.parse_rdf_serialization. I have rdf-n3 installed but it doesn't seem to be picking it up. This may be the website's fault for returning the wrong content type. If that's the case, perhaps @client.query should take an option to explicitly set the reader in @client.parse_rdf_serialization.

Thoughts?

@artob
Copy link
Member

artob commented Jun 12, 2010

The problem seems to be that the SPARQL server in question is specifying an incorrect content type for the results returned. That is, it is returning RDF data in Turtle format but with a content type of "text/plain" (which indicates N-Triples) instead of the correct "text/turtle".

So, yes, it does indeed seem that we will need to add a way to manually specify the parser to be used for dealing with broken servers like this one.

Note, btw, that you can use either of the rdf-raptor or the rdf-n3 gems to parse Turtle data.

@cldwalker
Copy link
Contributor Author

Thanks for confirming the broken server response. I've forked and pulled.

cldwalker added a commit that referenced this issue Apr 18, 2011
@cldwalker
Copy link
Contributor Author

This has also been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants