为什么针对SPARQL的Jena API(Java)不会为rdf:type
的查询提供任何结果?其他SPARQL查询工作得很好。例如,此查询无效:
SELECT DISTINCT ?p{
?p rdf:type :AAA
}
完整代码:
String queryString=listOfPrefixesOntNormXML+" \n"
+"SELECT DISTINCT ?p{ ?p rdf:type :AAA }";
System.out.println(queryString);
Query query = QueryFactory.create(queryString);
QueryExecution qExe = QueryExecutionFactory.sparqlService( "http://dbpedia.org/sparql", query );
ResultSet results = qExe.execSelect();
ResultSetFormatter.out(System.out, results, query) ;
完整的queryString:
PREFIX : <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl11: <http://www.w3.org/2006/12/owl11#>
PREFIX pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
PREFIX owl11xml: <http://www.w3.org/2006/12/owl11-xml#>
SELECT DISTINCT ?p{ ?p rdf:type :AAA }
答案 0 :(得分:3)
因为您向DBpedia端点提出查询,要求查找rdf:type
:AAA
的{{1}}并不存在。
如果您将其更改为dbo:Book
,它应该有效,因为DBpedia中存在rdf:type
!