Thanks so much for your prompt response, Holger. After taking a
closer look at the API and [1], I was able to query with a couple of
SPIN templates. Thank you!
In case this helps anyone, here's the (edited) code I used to call a
SPIN template that wraps a SPARQL SELECT query and that takes one
argument:
String NS = "http://example.org/Test#";
OntResource r = ontModel.getOntResource(NS + "nameOfTemplate");
Query q = ARQFactory.get().createQuery((Select)
(SPINFactory.asTemplate(r).getBody()));
QueryExecution qexec = ARQFactory.get().createQueryExecution(q,
ontModel);
QuerySolutionMap varBindings = new QuerySolutionMap();
RDFNode arg1 = ontModel.getOntResource(NS + "myInputArgument");
varBindings.add("arg1", arg1);
qexec.setInitialBinding(varBindings);
ResultSet results = qexec.execSelect();
ResultSetFormatter.out(System.out, results);
[1]
http://groups.google.com/group/topbraid-users/browse_thread/thread/17d27cfc4d862ab6/9ed1c24e651d7a8b
Thanks again,
Brian
On Jan 26, 12:41 am, Holger Knublauch <[email protected]> wrote:
> On Jan 26, 2012, at 2:26 AM, Brian wrote:
>
> > Hi everyone:
>
> > I'm having some problems storing and retrieving SPARQL queries in/from
> > my RDF SPIN model. I would like to store a set of SPARQL queries in
> > my model and call them in my Java application to test for conditions
> > and to add triples on demand. I tried to attach a spin:query to a
> > resource, but the query was stored in a blank node. Can I access a
> > blank node resource as a SPIN query in my Java code?
>
> Yes, but you will need the SPIN API for that
>
> http://topbraid.org/spin/api/1.2.0/index.html
>
> Once you have the blank node, turn it into a Query instance using
> SPINFactory.asQuery()
>
> http://topbraid.org/spin/api/1.2.0/spin/apidocs/org/topbraid/spin/mod...)
>
> > Is there a way
> > to store named queries (e.g.http://example.org/MyProject#myQuery)?
>
> I would convert them to SPIN templates for that - this not only gives the
> query a URI but also allows you to pass in arguments and thus reuse the same
> query in different contexts.
>
> http://composing-the-semantic-web.blogspot.com/2009/01/understanding-...
>
> You can then traverse all instances of spin:Template and get their spin:body.
> Then do the asQuery stuff above.
>
> Regards,
> Holger
--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary
Network (EVN), TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en