As we write SPARQL in Virtuoso, it is easy to escape a space within an URI by coding the space with %20
. However, when I run the same query on Virtuoso isql service, the escape fails. Here is my query:
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdno: <http://www.wikidata.org/prop/novalue/>
PREFIX schema: <http://schema.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Items with specific picture
#Note that URL of the filename must be URL encoded.
#added before 2016-10
SELECT ?item ?itemLabel
WHERE
{
?item wdt:P18 <http://commons.wikimedia.org/wiki/Special:FilePath/Flag%20of%20the%20Netherlands.svg>
OPTIONAL{?item rdfs:label ?en . FILTER(LANG(?en) = "en")}
BIND(str(COALESCE(?en,strafter(str(?item),"http://www.wikidata.org/entity/"))) AS ?itemLabel)
}
LIMIT 100
The error says:
*** Error 37000: [Virtuoso Driver][Virtuoso Server]SQ074: Line 22: SP030: SPARQL compiler, line 18: syntax error at '<' before 'http:' at line 0 of Top-Level:
SPARQL PREFIX wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX wdno: <http://www.wikidata.org/prop/novalue/> PREFIX schema: <http://schema.org/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX bd: <http://www.bigdata.com/rdf#> #Items with specific picture #Note that URL of the filename must be URL encoded. #added before 2016-10 SELECT ?item ?itemLabel WHERE { ?item wdt:P18 <http://commons.wikimedia.org/wiki/Special:FilePath/Flag of the Netherlands.svg> OPTIONAL{?item rdfs:label ?en . FILTER(LANG(?en) = "en")} BIND(str(COALESCE(?en,strafter(str(?item),"http://www.wikidata.org/entity/"))) AS ?itemLabel) } LIMIT 100
Isql is not being understood with the %20
because it prints the resource (URI) with white space.