Re: Template language for SPARQL?

If one views the WHERE clause of a SPARQL query as a kind of template, it seems 
a bit superfluous to have a template format for making templates.

Something I've been using to good effect is the variable pre-binding mechanism 
provided by Python rdflib, mentioned by Gunnar Aastrand Grimnes, but 
unfortunately that doesn't help when submitting a SPARQL query via SPARQL 
protocol.  I've been able to simulate the effect of pre-binding variables (but 
not the desired efficiency) buy doing a post-query join with the predefined 
variables.  I didn't fully comprehend the proposals that Andy Seaborne 
mentioned, but it seems then may provide a similar capability.

Ideally, I'd like to specify variable pre-bindings without having to pick apart 
the query with which they will be used, e.g. to construct a modified query, but 
I think that would require an extension to the SPARQL HTTP protocol rather than 
the query language.

#g
--

On 01/06/2012 02:45, David Booth wrote:
> [Resending, as my previous message never showed up.]
>
> I would like to be able to write something like this:
>
>    SELECT ?s
>    WHERE { ?s a ${CLASS} . }
>
> and have ${CLASS} substituted in from an environment variable or other
> parameter, but SPARQL does not currently provide anything like this, and
> it's clearly beyond what the working group could put in SPARQL 1.1.
> So I'm wondering . . .
>
> What have others been using as a template language for SPARQL?
>
> I know TopQuadrant uses an RDF representation for SPARQL CONSTRUCT
> queries in conjunction with SPIN,
> http://www.w3.org/Submission/2011/02/
> but it shreds the SPARQL query into tiny RDF pieces, which is rather
> unfriendly for a human to read.  It would be much nicer to have
> something like the above.
>
> How are others handling the need to parameterize their SPARQL queries
> like this?
>
>
>

Received on Saturday, 2 June 2012 21:12:24 UTC