> Does JENA support JSON for queries ResultSet?
> Do I have to set something somewhere to ask for this?

The remote service invocation expects results set to be in SPARQl XMl results format. It sets the MIME type to

application/sparql-results+xml

so sending JSON back is inappropriate. You'll have to ask the sparqlite people what's going on. Adding more choices is possible, just not done.

ARQ does support the JSON result set format, but not by MIME type negotiation:

ResultSetFactory.fromJSON(...) will read an input stream assuming SPARQL JSON format if you want to open the HTTP connection directly.


        Andy

On 21/03/11 16:42, Christophe Dupriez wrote:
Hi!

I am trying to use JENA ARQ to queryhttp://zbw.eu/beta/sparql which is
powered by sparqlite (http://code.google.com/p/sparqlite/).

But I get this because the result is in JSON:

2011-03-21 17:14:06,367 WARN
com.hp.hpl.jena.sparql.resultset.XMLInputStAX$ResultSetStAX @
XMLStreamException: Unexpected character '{' (code 123) in prolog;
expected '<'
at [row,col {unknown-source}]: [1,1]
com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '{'
(code 123) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1]
at
com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:648)
at
com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2047)

at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1069)
at
com.hp.hpl.jena.sparql.resultset.XMLInputStAX$ResultSetStAX.skipTo(XMLInputStAX.java:303)

at
com.hp.hpl.jena.sparql.resultset.XMLInputStAX$ResultSetStAX.skipTo(XMLInputStAX.java:295)

at
com.hp.hpl.jena.sparql.resultset.XMLInputStAX$ResultSetStAX.init(XMLInputStAX.java:182)

at
com.hp.hpl.jena.sparql.resultset.XMLInputStAX$ResultSetStAX.<init>(XMLInputStAX.java:175)

at
com.hp.hpl.jena.sparql.resultset.XMLInputStAX.worker(XMLInputStAX.java:134)
at
com.hp.hpl.jena.sparql.resultset.XMLInputStAX.<init>(XMLInputStAX.java:97)
at com.hp.hpl.jena.sparql.resultset.XMLInput.make(XMLInput.java:61)
at com.hp.hpl.jena.sparql.resultset.XMLInput.fromXML(XMLInput.java:30)
at com.hp.hpl.jena.sparql.resultset.XMLInput.fromXML(XMLInput.java:25)
at
com.hp.hpl.jena.query.ResultSetFactory.fromXML(ResultSetFactory.java:278)
at
com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngineHTTP.java:143)


My current code is:
Query query = QueryFactory.create(sparql);
// initializing queryExecution factory with remote service.
// **this actually was the main problem I couldn't figure out.**
QueryExecution qexec =
QueryExecutionFactory.sparqlService(server.getUrl(), query);
if (qexec != null) {
ResultSet rs = qexec.execSelect();
if (rs != null) {
for (QuerySolution soln = rs.next(); rs.hasNext(); soln = rs.next() ) {
....


Does JENA support JSON for queries ResultSet?
Do I have to set something somewhere to ask for this?

THANK YOU for your advices!!!

Christophe

Reply via email to