How to encode URI with blank space in VOS isql service?

妖精的绣舞 提交于 2019-12-24 10:00:25

问题


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.

来源:https://stackoverflow.com/questions/49418156/how-to-encode-uri-with-blank-space-in-vos-isql-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!