A 在接收 SPARQL 响应时遇到问题。一个问题是方法
((ResultSet) response).hasNext()
返回false
,尽管响应不应该为空。
请求是:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ontology: <http://www.semanticweb.org/kseniia/ontologies/2013/1/untitled-ontology-12#> SELECT ?x
WHERE {?x rdfs:subClassOf ontology:Visual}
这在 Protege 中正常工作并返回 3 个对象:
Location
Relation
Descriptive
查询是在耶拿这样执行的:
Query query = QueryFactory.create(queryString);
QueryExecution qexec = QueryExecutionFactory.create(query, model);
Object response = qexec.execSelect();
qexec.close();
for ( ; ((ResultSet) response).hasNext(); ) { // always false
QuerySolution soln = ((ResultSet) response).nextSolution();
// etc
}
也许我错过了什么?