2011-04-28 60 views
6

我试图从linkedgeodata.org查询一个国家内的国家的RDF数据。在RDF是这样表示:在谓词中用冒号进行SPARQL查询

<http://linkedgeodata.org/triplify/node1055351027> <http://linkedgeodata.org/property/is_in%3Acountry> "LT" . 

正如你可能会注意到,谓词包含逃脱结肠,所以“%3A”,而不是“:” 我没能找到这个合适的SPARQL查询,这些都是我的一些尝试

?node lgdp:is_in "LT". 
?node lgdp:is_in:country "LT". 
?node lgdp:is_in%3Acountry "LT". 
?node lgdp:is_in\u003Acountry "LT". 
?node lgdp:is_in"\u003A"country "LT". 

我使用演奏家为我的三联店的开源版本,这是我收到的所有除了第一种形式的errormessage的:

Virtuoso 37000 Error SP030: SPARQL compiler, line 0: Invalid character in SPARQL expression at '\' 

SPARQL query: 
define sql:big-data-const 0 
#output-format:text/html 
define input:default-graph-uri PREFIX lgdo: 
PREFIX lgdp: 
PREFIX lgd: 
PREFIX pos: 
PREFIX rdf: 

SELECT ?node, ?label 
Where { 
?node a lgdo:State . 
?node lgdp:is_in\u003Acountry "LT". 
?node rdfs:label ?label . 
} 

回答

7

在使用名称空间时不允许使用%编码的字符,在这种情况下,您必须直接使用完整的谓词(不带名称空间)。以下查询的工作原理如下:

Prefix lgdo:<http://linkedgeodata.org/ontology/> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
SELECT ?node, ?label 
Where { 
?node a lgdo:State . 
?node <http://linkedgeodata.org/property/is_in%3Acountry> "LT". 
?node rdfs:label ?label 
} 

查看结果here

+2

正如Manuel指出的那样,有一些URI不能压缩成QName风格的表示法,因此您必须始终使用完整的URI。理想情况下,创建数据的人应该避免创建会导致此问题的URI – RobV 2011-04-29 09:00:22