On 2/19/15 4:49 PM, Patrick van Kleef wrote:
Hi Chris,

>In the DBpedia SPARQL endpoint [1], running
>
>PREFIX dc: <http://purl.org/dc/elements/1.1/
> >
>PREFIX : <
>http://dbpedia.org/resource/
> >
>PREFIX dbpedia2: <
>http://dbpedia.org/property/
> >
>
>SELECT ?a (3+3 AS ?y)
>WHERE
>{
>    ?a dc:description "English footballer" .
>    ?a dbpedia2:placeOfBirth :Merseyside .
>}
>
>Shows all English Footballers who were born in Merseyside, with column y just 
displaying the value 6 on every row [result link]; however, the same query on the 
SNORQL endpoint displays an error:
>
>Virtuoso 37000 Error SP030: SPARQL compiler, line 16: syntax error at '3'
>before 'AS' SPARQL query: define sql:big-data-const 0 #output-
>format:application/sparql-results+json define input:default-graph-uri PREFIX
>owl: PREFIX xsd: PREFIX rdfs: PREFIX rdf: PREFIX foaf: PREFIX dc: PREFIX :
>PREFIX dbpedia2: PREFIX dbpedia: PREFIX skos: PREFIX pos: PREFIX dbo: SELECT
>?a (3 3 AS ?y) WHERE { ?a dc:description "English footballer" . ?a
>dbpedia2:placeOfBirth :Merseyside . }
>
>Even more strangely, using any of the other 3 arithmetic operators does work 
in the SNORQL endpoint (e.g. with division [5])
>
>A previous question [6] on Stackoverflow has implied that the SPARQL and 
SNORQL endpoints should return the same result, so what's going on here?!
>
>Cheers,
>Chris
>
>1:http://dbpedia.org/sparql/
>2:http://dbpedia.org/sparql/?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=++++PREFIX+dc%3A+%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%3E%0D%0A++++PREFIX+%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2F%3E%0D%0A++++PREFIX+dbpedia2%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fproperty%2F%3E%0D%0A%0D%0A++++SELECT+%3Fa+%283%2B3+AS+%3Fy%29%0D%0A++++WHERE+%0D%0A++++%7B+%0D%0A+++++++%3Fa+dc%3Adescription+%22English+footballer%22+.%0D%0A+++++++%3Fa+dbpedia2%3AplaceOfBirth+%3AMerseyside+.%0D%0A++++%7D&format=text%2Fhtml&timeout=30000&debug=on
>3:http://dbpedia.org/snorql/?query=PREFIX+pos%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2003%2F01%2Fgeo%2Fwgs84_pos%23%3E%0D%0APREFIX+dbo%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2F%3E%0D%0A%0D%0ASELECT+%3Fa+%283%2B3+AS+%3Fy%29%0D%0AWHERE+%0D%0A%7B+%0D%0A+++++%3Fa+dc%3Adescription+%22English+footballer%22+.%0D%0A+++++%3Fa+dbpedia2%3AplaceOfBirth+%3AMerseyside+.%0D%0A%7D
>4:http://dbpedia.org/snorql/
>5:http://dbpedia.org/snorql/?query=PREFIX+pos%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2003%2F01%2Fgeo%2Fwgs84_pos%23%3E%0D%0APREFIX+dbo%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2F%3E%0D%0A%0D%0ASELECT+%3Fa+%283%2F3+AS+%3Fy%29%0D%0AWHERE+%0D%0A%7B+%0D%0A+++++%3Fa+dc%3Adescription+%22English+footballer%22+.%0D%0A+++++%3Fa+dbpedia2%3AplaceOfBirth+%3AMerseyside+.%0D%0A%7D
>6:http://stackoverflow.com/a/15658884/889604
The snorql code was using the wrong method to encode the query string before 
calling the real /sparql interface.

It was using the very old 'escape()' javascript function which does not encode 
the + character as a special character.

It then uses that escaped string to call the real /sparql endpoint.

When the /sparql endpoint decodes the &query=XXXX3+3YYYYY string it decodes the 
+ character as a space thereby creating a syntax error in your query.

I fixed the snorql code onhttp://dbpedia.org  to use the encodeURIComponent 
function which is the proper way of embedding a query as a parameter argument 
in a URL.

Fix confirmed:
http://dbpedia.org/snorql/?query=PREFIX+pos%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2003%2F01%2Fgeo%2Fwgs84_pos%23%3E%0D%0APREFIX+dbo%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2F%3E%0D%0A%0D%0ASELECT+%3Fa+%283%2B3+AS+%3Fy%29%0D%0AWHERE+%0D%0A%7B+%0D%0A+++++%3Fa+dc%3Adescription+%22English+footballer%22+.%0D%0A+++++%3Fa+dbpedia2%3AplaceOfBirth+%3AMerseyside+.%0D%0A%7D

Hopefully, someone could help closing out the case on Stackoverflow [1] ?

[1] http://linkeddata.uriburner.com/about/id/entity/http/stackoverflow.com/questions/28611127/dbpedias-sparql-and-snorql-returning-different-results .

--
Regards,

Kingsley Idehen 
Founder & CEO
OpenLink Software
Company Web: http://www.openlinksw.com
Personal Weblog 1: http://kidehen.blogspot.com
Personal Weblog 2: http://www.openlinksw.com/blog/~kidehen
Twitter Profile: https://twitter.com/kidehen
Google+ Profile: https://plus.google.com/+KingsleyIdehen/about
LinkedIn Profile: http://www.linkedin.com/in/kidehen
Personal WebID: http://kingsley.idehen.net/dataspace/person/kidehen#this


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Dbpedia-discussion mailing list
Dbpedia-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion

Reply via email to