You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Robert Vesse <rv...@cray.com> on 2011/12/16 22:53:29 UTC

Automatically selecting how to parse SPARQL Results from Content-Type?

Hey All

I'm working on some code that creates a modified version of QueryEngineHttp that allows me to control what Accept header I send for different kinds of SPARQL query and thus I have to modify the code that parses the responses to parse according to the received format.  The problem I've encountered is that I can't find any way to automatically parse SPARQL Results based on content type.

For RDF formats I can do this with WebContent.contentTypeToLang() and then calling Model.read() and providing the language name derived from the Lang object I got

For SPARQL Result formats I can't find any equivalent, there is a ResultsFormat.guessSyntax() but this only guesses based on file extension which is of no use to me.  Is there some equivalent to my preceding example for SPARQL Result formats?

Cheers,

Rob

ps. I will likely contribute this as a patch to ARQ at some point when I have it working reliably

Re: Automatically selecting how to parse SPARQL Results from Content-Type?

Posted by Andy Seaborne <an...@apache.org>.
On 16/12/11 21:53, Robert Vesse wrote:
> Hey All
>
> I'm working on some code that creates a modified version of QueryEngineHttp that allows me to control what Accept header I send for different kinds of SPARQL query and thus I have to modify the code that parses the responses to parse according to the received format.  The problem I've encountered is that I can't find any way to automatically parse SPARQL Results based on content type.
>
> For RDF formats I can do this with WebContent.contentTypeToLang() and then calling Model.read() and providing the language name derived from the Lang object I got
>
> For SPARQL Result formats I can't find any equivalent, there is a ResultsFormat.guessSyntax() but this only guesses based on file extension which is of no use to me.  Is there some equivalent to my preceding example for SPARQL Result formats?
>
> Cheers,
>
> Rob
>
> ps. I will likely contribute this as a patch to ARQ at some point when I have it working reliably

There isn't anything currently.

I have some half(or less) finished code to wrap up issuing an HTTP 
operation and sorting out the returned content type.  The whole conneg 
thing needs to be handled properly in several places and this, + rework 
the FileManager to provide typed streams, was my plan (but I have a lot 
of plans ...)

org.openjena.riot.web

   HttpOp
   HttpResponseLib.HttpCaptureResponseResultSet

This is work-in-progress to replace result set reading and graph reading.

All the constants should be in org.openjena.riot.WebContent.

	Andy