http://example.org/vocres/CCC
http://example.org/vocres/DDD
* </pre>
*/
private static void _queryWithInference() {
VirtGraph _graph = new VirtGraph (TEST_GRAPH, _host, _username, _password);
String queryString =
"PREFIX skos: <http://www.w3.org/2004/02/skos/core#> " +
"SELECT ?o WHERE " +
"{ <http://example.org/vocres/AAA> " +
" skos:exactMatch " +
" ?o " +
" OPTION(TRANSITIVE)" + // <<-- Jena triggers error here; but Virtuoso handles it
"} "
;
// with the OPTION(TRANSITIVE) above, Jena triggers syntax error here:
// Query sparql = QueryFactory.create(queryString);
// but passing the string directly to Virtuoso is fine:
VirtuosoQueryExecution vqe = VirtuosoQueryExecutionFactory.create(
// sparql,
queryString,
_graph);
// and the result includes the inferred triples:
// RESULT:
// http://example.org/vocres/BBB
// http://example.org/vocres/CCC
// http://example.org/vocres/DDD
ResultSet results = vqe.execSelect();
System.out.println("RESULT:");
while (results.hasNext()) {
QuerySolution result = results.nextSolution();
RDFNode o = result.get("o");
System.out.println(" "+ o );
}
vqe.close();
_graph.close();
}