简体   繁体   English

在谓词中使用冒号的SPARQL查询

[英]SPARQL Query with colon in predicate

I am trying to query the RDF Data from linkedgeodata.org for States within a Country. 我试图从linkedgeodata.org查询一个国家内的国家的RDF数据。 In RDF it is represented as such: 在RDF中,它表示如下:

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

As you might notice, the predicate contains an escaped colon, so "%3A" instead of ":" I was not able to find a suitable SPARQL query for this, these are some of my attempts 您可能会注意到,谓词包含一个转义冒号,所以“%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".

I am using the opensource version of virtuoso as my triple store, this is the errormessage I receive with all except the first form: 我使用开源版的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 .
} 

Characters encoded with % are not allowed when using namespaces, in this case you'll have to use the full predicate directly (without the namespace). 使用命名空间时,不允许使用%编码的字符,在这种情况下,您必须直接使用完整谓词(不使用命名空间)。 The following query works: 以下查询有效:

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
}

see the results here . 这里看到结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM