Thank you Martynas, I got it...  It confused me slightly because it was my
first time I executed CONSTRUCT using Jena code.


On Fri, Aug 25, 2017 at 12:00 AM, Martynas Jusevičius <
marty...@atomgraph.com> wrote:

> Because there are 2 forms of SPARQL queries:
> - ASK and SELECT return ResultSet (table of variable bindings)
> - CONSTRUCT and DESCRIBE return Model (RDF graph = triples)
>
> On Thu, Aug 24, 2017 at 10:58 PM, javed khan <javedbtk...@gmail.com>
> wrote:
>
> > Hello Martynas, it finally showed the result.
> >
> > But I did not understand the code. Why we assign the result to a Model?
> Why
> > not resultset.
> >
> > Model results =  qexec.execConstruct() ;
> >
> > On Thu, Aug 24, 2017 at 11:44 PM, Martynas Jusevičius <
> > marty...@atomgraph.com> wrote:
> >
> > > This means your query hasn't matched anything.
> > >
> > > Show us your data.
> > >
> > > On Thu, Aug 24, 2017 at 10:42 PM, javed khan <javedbtk...@gmail.com>
> > > wrote:
> > >
> > > > 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();
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
>

Reply via email to