2014-04-01 28 views
0

如何从该查询如何获取资源的值,它是另一种资源在SPARQL查询属性

SELECT ?capital 
WHERE { <http://dbpedia.org/resource/Germany><http://dbpedia.org/ontology/capital> ?capital} 

得到的省会城市不是URI的值名称在上面的查询我获得德国首都的URI .IE http://dbpedia.org/resource/berlin 怎样才能得到只有柏林而不是它的URI

+0

复制在answers.semanticweb.com作为http://answers.semanticweb.com/questions/27340/how-to-get-the-value-of-a-resource-which-is-a-propery-of -another资源功能于SPARQL查询。 –

回答

3

你想要的值实际上是RDFS标签属性的值。如果您使用的public DBpedia SPARQL endpoint,那么你可以使用这样的查询:

select ?label where { 
    dbpedia:Germany dbpedia-owl:capital/rdfs:label ?label . 
    filter langMatches(lang(?label),"en") 
} 

属性路径dbpedia-owl:capital/rdfs:label意味着你得到德国的首都,然后得到的该标签。 filter表达式让您只选择资源的英文标签。当然,您可以删除此过滤器,但您会得到多个结果,因为该资源具有不同语言的标签。

+0

谢谢。请问为什么查询不能在 – user3335188

+1

之类的其他国家使用?我认为您的评论中缺少一些内容。 –

+0

@ user3335188我不确定你在说什么其他国家。我猜想有可能有些国家没有资本,但是不知道你问的是哪一个,我可以有更多的帮助...... –