任何人都可以告诉我这个SPARQL QUERY有什么问题吗?

时间:2017-05-10 13:27:22

标签: sparql rdf semantic-web ontology apache-jena

我正在使用Eclipse和Jena。我已经提出了一些有效的查询,但我找不到这个错误。这是我的代码:

// Create a SPARQL query from the given string.
String queryString = //"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "+
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>  "+
//"PREFIX owl: <http://www.w3.org/2002/07/owl#>" +
//"PREFIX ab: <http://learningsparql.com/ns/addressbook#> " +
"PREFIX foaf: <http://xmlns.com/foaf/0.1/> "+
"PREFIX dc: <http://purl.org/dc/elements/1.1/> " +
"SELECT ?name " +
"where { "+
"?person foaf:weblog \""+"http://ldodds.com/blog/"+"\" . "+
"?person foaf:name ?name . "+
"?person rdf:type ?Person . "+
//"\"<http://ldodds.com/blog/>\""+" dc:title ?title ."+
"} \n ";

仅查询:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>  
PREFIX owl: <http://www.w3.org/2002/07/owl#>" 
PREFIX ab: <http://learningsparql.com/ns/addressbook#> 
PREFIX foaf: <http://xmlns.com/foaf/0.1/> 
PREFIX dc: <http://purl.org/dc/elements/1.1/> 

SELECT ?name 
where { 
    ?person foaf:weblog "http://ldodds.com/blog/"
    ?person foaf:name ?name
    ?person rdf:type ?Person
    "<http://ldodds.com/blog/>" dc:title ?title
    }

This是我正在使用的本体链接,这是我要回答的查询:

  

编写一个SPARQL查询,该查询检索一个人的名字,该人的名字是人的类型,其博客地址是http://ldodds.com/blog,并且还检索他/她的博客的标题。

1 个答案:

答案 0 :(得分:1)

查看您的数据。属性foaf:weblog使用RDF中表示的资源作为对象而不是字符串文字:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>   
SELECT ?name WHERE { 
   ?person foaf:weblog <http://ldodds.com/blog/> . 
   ?person foaf:name ?name . 
   ?person rdf:type ?Person . 
}