Hi László,

I have just added a small example of the SPIN API to create and invoke a SPIN 
template.

The key idea is to use pre-binding of variables in the Jena QueryExecution:

com.hp.hpl.jena.query.Query arq = 
ARQFactory.get().createQuery((Select)template.getBody());
QueryExecution qexec = ARQFactory.get().createQueryExecution(arq, model);
QuerySolutionMap arqBindings = new QuerySolutionMap();
arqBindings.add("predicate", RDFS.label);
qexec.setInitialBinding(arqBindings); // Pre-assign the arguments
ResultSet rs = qexec.execSelect();

The full source code is attached. Please follow up if this doesn't cover your 
use case.

Regards,
Holger


On Jul 1, 2011, at 11:21 PM, László Török wrote:

> Hi Scott,
> 
> thanks, I think I'm sufficiently comfortable with TBC. What I don't quite 
> grok yet, is how to do even simple things programmatically.
> 
> Given the example SPIN template below, I'd like to replace the template 
> variable with an actual property (which is a resource).
> 
> Well, I can surely call toString() on Template to get the SPARQL query as 
> string and do some regex magic, but there has to be a more elegant way. The 
> javadoc is not very intuitive unfortunatelly. Any pointers how to do that? 
> (TBC must be doing it somehow too.. :), no I'm not developing a TBC clone :) )
> 
> Thanks,
> 
> Las
> 
> 2011/7/1 Scott Henninger <[email protected]>
> Las; You should be able to run the SPARQL query against an endpoint
> using the SERVICE keyword.  E.g.:
> 
> CONSTRUCT{
>    _:b0 a spin:ConstraintViolation .
>    _:b0 spin:violationRoot ?s .
>    _:b0 spin:violationPath ?arg1 .
> }
> WHERE{
>    SERVICE <service-uri>
>    {  ?s ?arg1 ?value .
>       FILTER (!regex(str(?value), "^[0-9]{5}$"^^xsd:string))
>    }
> }
> 
> If you're overwhelmed by the SPIN API, you may want to download TBC-SE/
> ME/Free (http://www.topquadrant.com/products/TB_install.php) to
> experiment with SPIN features before jumping headlong into the API.
> 
> -- Scott
> 
> 
> On Jul 1, 5:45 am, Las <[email protected]> wrote:
> > Hi,
> >
> > just started playing with SPIN 1.2, and I'm a bit overwhelmed.
> >
> > Basically, I've managed to load a serialized SPIN template. [1] I'd
> > like to set the free template variables and run it against a SPARQL
> > endpoint without loading all it's triples into memory (Jena Model).
> >
> > Can anybody give me some pointers how to do that?
> >
> > Thx,
> > Las
> >
> > [1]http://semwebquality.org/ontologies/dq-constraints#FiveDigitNumericAll
> 
> --
> You received this message because you are subscribed to the Google
> Group "TopBraid Suite Users", the topics of which include 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
> 
> 
> 
> -- 
> László Török
> 
> Skype: laczoka2000
> Twitter: @laczoka
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Group "TopBraid Suite Users", the topics of which include 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
-- 
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include 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

Attachment: TemplateExample.java
Description: Binary data

Reply via email to