In response to my question earlier, I replace this ResultSet results = (ResultSet) qexec.execConstruct() ;
with Model results = qexec.execConstruct() ; results.write(System.out, "TURTLE"); But how can I get the require result i.e value of ?z and ?y I expect the following result: Bob hasUncle Lincoln But currently, it just display the prefixes. On Thu, Aug 24, 2017 at 9:20 PM, javed khan <javedbtk...@gmail.com> wrote: > Hello > > What is the problem in this query: 'Male' is string literal here. (The > query works inside Protege) > > CONSTRUCT { ?x mo:hasUncle ?y } WHERE { ?x mo:hasParents ?z .?z > mo:Gender 'Male' . ?z mo:hasBrother ?y} > > Query query = QueryFactory.create(str); > QueryExecution qexec = QueryExecutionFactory.create(query, model) ; > ResultSet results = (ResultSet) qexec.execConstruct() ; > while (results.hasNext()) > { > QuerySolution binding = results.nextSolution(); > Literal lit = binding.get("z").asLiteral(); > > >