epimorphics / qonsole

A simple console for running SPARQL queries and displaying results
Other
16 stars 2 forks source link

error with SPARQL AS #8

Closed seralf closed 10 years ago

seralf commented 10 years ago

Hi, while trying to execute the query:

SELECT ?class str(?label) AS ?label ?description
WHERE {
    ?class a owl:Class.
    optional { ?class rdfs:label ?label}
    optional { ?class rdfs:comment ?description}
}

I've received the error:

Error 400: Parse error: [...] Encountered " "as" "AS "" at line 12, column 27. [...]

der commented 10 years ago

This is nothing to do with qonsole. You have an incorrect SPARQL query. See sparql.org for a validator which will allow you to check your query.

In fact you have at least two errors in the query, the AS statement should be in parens and you can't use AS to bind to a variable that you've already bound. Try:

PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema# PREFIX owl: http://www.w3.org/2002/07/owl#

SELECT ?class (str(?label) AS ?labels) ?description WHERE { ?class a owl:Class. optional { ?class rdfs:label ?label} optional { ?class rdfs:comment ?description} }

seralf commented 10 years ago

uhm ok thanks, I generally use this syntax without problems:

http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=%0D%0A%0D%0ASELECT+%3Fclass+str%28%3Flabel%29+AS+%3Flabel+%3Fdescription%0D%0AWHERE+%7B%0D%0A%3Fclass+a+owl%3AClass.%0D%0Aoptional+%7B+%3Fclass+rdfs%3Alabel+%3Flabel%7D%0D%0Aoptional+%7B+%3Fclass+rdfs%3Acomment+%3Fdescription%7D%0D%0A%7D%0D%0A&format=text%2Fhtml&timeout=30000&debug=on

but probably Jena doesn't accept it

thanks again :-)

der commented 10 years ago

On 26/04/14 12:41, Alfredo Serafini wrote:

uhm ok thanks, I generally use this syntax without problems:

http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=%0D%0A%0D%0ASELECT+%3Fclass+str%28%3Flabel%29+AS+%3Flabel+%3Fdescription%0D%0AWHERE+%7B%0D%0A%3Fclass+a+owl%3AClass.%0D%0Aoptional+%7B+%3Fclass+rdfs%3Alabel+%3Flabel%7D%0D%0Aoptional+%7B+%3Fclass+rdfs%3Acomment+%3Fdescription%7D%0D%0A%7D%0D%0A&format=text%2Fhtml&timeout=30000&debug=on

but probably Jena doesn't accept it

I'd phrase it differently ...

Jena doesn't accept it because it is not legal according to the W3C specification, at least that's what I believe the sparql.org validator is telling us.

The fact that the dbpedia endpoint chooses to accept it is not something we can control :)

Dave