1

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

クエリは jena で次のように実行されました。

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
}

多分私は何かを逃しましたか?

4

1 に答える 1

3

で実行を閉じてからqexec.close、結果を繰り返します。ただし、結果は によってクローズされ、qexec.close利用できなくなります。

qexec.closeto をループの後に移動します。

改善:

Object response ==> ResultSet response

于 2013-03-29T10:43:09.063 に答える