Hello Andy!

The more I learn, the more I realize how little I know :)
I think his code's gist expired, but FWIW here is another gist from my local 
copy [1]. 
Thank you!Bruno
[1] https://gist.github.com/kinow/f36c7cf989a4ee1b5478
 
      From: Andy Seaborne <[email protected]>
 To: [email protected] 
 Sent: Wednesday, November 26, 2014 7:10 AM
 Subject: Re: Valid JSON keys in SPARQL endpoint response for Describe queries
   
On 25/11/14 23:49, Bruno P. Kinoshita wrote:
> Hi all,
> Yesterday I was lurking in #jena's channel as I often do, when a user posted 
> that his query
> PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>PREFIX rdfs: 
> <http://www.w3.org/2000/01/rdf-schema#>PREFIX rdf: 
> <http://www.w3.org/1999/02/22-rdf-syntax-ns#>PREFIX res: 
> <http://www.w3.org/2005/sparql-results#>describe * where  {?movie rdf:type 
> dbpedia-owl:Film.?movie rdfs:label ?label.?movie rdfs:label 
> ?movie_title.FILTER langMatches(lang(?movie_title), "EN") .filter regex( 
> ?label, "Inglourious Basterds", "i").}
> against DBpedia SPARQL endpoint was failing with
> Exception in thread "main" 
> com.hp.hpl.jena.sparql.resultset.ResultSetException: Expected only object 
> keys [type, value, xml:lang, datatype] but encountered 'lang'
>
> I got the same Exception in my Eclipse workspace. While debugging with 
> jena-2.12.0, I found that the Exception occurred in this code in jena-arq 
> JSONInput [1]
> Now, what intrigued me, was that in JSONResultsKW [2], there are constants 
> that are used to filter the keys returned in JSON, IIUC. When the error is 
> raised, these possible values include "xml:lang", as in the W3C 
> documentation. However, DBpedia Virtuoso seems to be using "lang" as the key, 
> without the xml prefix [3].
> Is it a bug in arq, is DBpedia endpoint not following the specification, or 
> is the error somewhere else? Reading the W3C page it doesn't mention describe 
> queries, so not sure if it doesn't apply for this kind o query. Replacing 
> describe by select the query seems to works (didn't look what's happening 
> with his filter).
> Here's the code he used [4]
> Thanks!
> ps: sent it hours ago, but I couldn't find it in the archives so re-sending 
> it now.
> [1] 
> https://github.com/apache/jena/blob/6ed1c766e74861db3a2219f9e7eb84ecc1ea8ef0/jena-arq/src/main/java/com/hp/hpl/jena/sparql/resultset/JSONInput.java#L266
> [2] 
> https://github.com/apache/jena/blob/6ed1c766e74861db3a2219f9e7eb84ecc1ea8ef0/jena-arq/src/main/java/com/hp/hpl/jena/sparql/resultset/JSONResultsKW.java#L23
> [3] 
> http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=PREFIX+dbpedia-owl%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2F%3E%0D%0APREFIX+rdfs%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0D%0APREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0D%0APREFIX+res%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2005%2Fsparql-results%23%3E%0D%0Adescribe+*+where++%7B%0D%0A%3Fmovie+rdf%3Atype+dbpedia-owl%3AFilm.%0D%0A%3Fmovie+rdfs%3Alabel+%3Flabel.%0D%0A%3Fmovie+rdfs%3Alabel+%3Fmovie_title.%0D%0AFILTER+langMatches%28lang%28%3Fmovie_title%29%2C+%22EN%22%29+.%0D%0Afilter+regex%28+%3Flabel%2C+%22Inglourious+Basterds%22%2C+%22i%22%29.%0D%0A%7D&format=application%2Fsparql-results%2Bjson&timeout=30000&debug=on
> [4] http://rdf.pastebay.net/1531054

(can't see that code)



[3] is a SPARQL Result set, for SELECT queries.  Format 
application/sparq-results+json.

The request is a DESCRIBE query, not a SELECT

The Virtuoso request has "format=application/sparql-results+json" 
Setting the Accept header has the same effect.

A DESCRIBE query is an RDF graph and conneg should be for any RDF graph 
format.  JSON-LD or RDF/JSON [A] being JSON possibilities for encoding 
an RDF graph in JSON.

ARQ expects a graph to a graph request (DESCRIBE, CONSTRUCT).  A result 
set is not a graph.

Virtuoso sends a result set of (s,p,o) rows not a graph but you don't 
know it's (s,p,o) from the response.  (Somewhat tricky because you have 
to open the results first.)  Looks like a virtuoso special.

Content negotiation should have generated a "406 Not Acceptable" - the 
request is not compatible with the resource.  418 is also acceptable.

    Andy


[A] Non standard but reasonably common
We have a copy of the documentation as the Talis site isn't available 
any more.

http://jena.apache.org/documentation/io/rdf-json.html


   

Reply via email to