谁能告诉我这个 SPARQL QUERY 有什么问题吗?
Can anyone tell me whats wrong with this SPARQL QUERY?
我正在使用 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 是我正在使用的 ontology 的 link,这是我要回答的查询:
Write a SPARQL query which retrieves a name of a person which is a type of Person and whose weblog address is http://ldodds.com/blog and also retrieves a title of his/her weblog.
看看你的数据。 属性 foaf:weblog
使用 RDF 中由 URI 表示的资源作为对象而不是字符串文字:
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 .
}
我正在使用 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 是我正在使用的 ontology 的 link,这是我要回答的查询:
Write a SPARQL query which retrieves a name of a person which is a type of Person and whose weblog address is http://ldodds.com/blog and also retrieves a title of his/her weblog.
看看你的数据。 属性 foaf:weblog
使用 RDF 中由 URI 表示的资源作为对象而不是字符串文字:
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 .
}