6

我正在尝试从linkedgeodata.org 查询某个国家/地区的州的RDF 数据。在 RDF 中,它表示为:

<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".

我正在使用 virtuoso 的开源版本作为我的三重存储,这是我收到的错误消息,除了第一种形式:

    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 .
} 
4

1 回答 1

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
}

在这里查看结果。

于 2011-04-28T20:15:04.003 回答