W3C home > Mailing lists > Public > public-sparql-dev@w3.org > October to December 2014

Re: Use VALUES as a templating mechanism?

From: Eric Prud'hommeaux <eric@w3.org>
Date: Sat, 8 Nov 2014 14:47:19 -0500
Message-ID: <CANfjZH3SuKKughR6io=Po2Sr+7PD5Bf7jLaxS_Gqo+ksm4QRhQ@mail.gmail.com>
To: "Neubert, Joachim" <J.Neubert@zbw.eu>
Cc: public-sparql-dev@w3.org
On Nov 8, 2014 5:52 PM, "Neubert, Joachim" <J.Neubert@zbw.eu> wrote:
>
> I’ve started to experimentally use VALUES clauses as a simple mechanism
for SPARQL templating. A VALUES table may provide a location where less
tech-savvy people can find hints where to tweak the query. E.g.
>
>
>
>   # parameters
>
>   VALUES ( ?versionHistoryGraph ?language ) {
>
>     ( <http://zbw.eu/stw/version> "en" )
>
>   }
>
>
>
> Is much easier to recognize than the same values spread over and
literally inserted into the query. Also, programs could parse this clause,
and perhaps, by variable replacement, offer choices, or run queries with
different pre-defined values.
>
>
>
> At the same time, this provides reasonable defaults and leaves the query
in a valid and executable state. In my eyes, that’s a big advantage over
arbitrary placeholders in the query string.
>
>
>
> I wonder what you think of the approach?

It makes sense to me. I use a similar mechanism to inject protocol
information such the authenticated user or client SSL client cert into
variable bindings a SPARQL query.

> Cheers, Joachim
>
>
>
> Query example:
>
>
http://zbw.eu/beta/sparql-gui/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/count_added_labels.rq
>
>
>
> Exploiting the VALUES clause of that query in a still sketchy program:
>
>
https://github.com/jneubert/skos-history/blob/master/bin/create_change_statistics.pl
>
>
Received on Saturday, 8 November 2014 19:47:47 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:15:52 UTC