2013-10-10 32 views
0

在這樣的查詢中,如何避免?p被綁定到rdf:type將屬性限制在rdf中:type

select ?p ?c where { 
    <http://dbpedia.org/resource/Istance_1> ?p ?c. 
    <http://dbpedia.org/resource/Istance_2> ?p ?c. 
} 

回答

0

添加filter到您的查詢:

select ?p ?c where { 
    <http://dbpedia.org/resource/Istance_1> ?p ?c. 
    <http://dbpedia.org/resource/Istance_2> ?p ?c. 
    filter(?p != rdf:type) 
} 

這是典型的使用前綴dbpedia:http://dbpedia.org/resource/,和我預期Istance被假設是Instance,所以有一點清理的,你將有

prefix dbpedia: <http://dbpedia.org/resource> 
select ?p ?c where { 
    dbpedia:Instance_1 ?p ?c . 
    dbpedia:Instance_2 ?p ?c . 
    filter(?p != rdf:type) 
} 

如果您要複製並粘貼到public DBpedia SPARQL endpoint,您w不需要定義該前綴,因爲它和bunch of others are predefined,但如果你將它稱爲其他一些時尚,你將需要。

+0

非常感謝你! – user2837896