我使用以下代码列出了Punk Rock乐队的乐队成员:
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema>
SELECT distinct ?bandname ?bandmembername where {
?band
foaf:name ?bandname;
dbo:genre dbr:Punk_Rock.
?bandmember
dbo:bandMember ?bandmember;
rdfs:label ?bandmembername.
}
我需要任何Punk_Rock
乐队的乐队成员。
答案 0 :(得分:0)
没有语法错误。
查询中有2个错误。
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema>
应该是PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
dbo:bandMember ?bandmember
谓词和对象应该描述?band
(具有成员),而不是描述?bandmember
(是的成员)
有了这些修复程序in the query,您应该会看到the results您所希望的-
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?bandname ?bandmembername
WHERE
{
?band
foaf:name ?bandname ;
dbo:bandMember ?bandmember ;
dbo:genre dbr:Punk_Rock .
?bandmember
rdfs:label ?bandmembername .
}