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

Use VALUES as a templating mechanism?

From: Neubert, Joachim <J.Neubert@zbw.eu>
Date: Sat, 8 Nov 2014 16:50:25 +0000
To: "public-sparql-dev@w3.org" <public-sparql-dev@w3.org>
Message-ID: <4E3518D35BC4E14B802A8CAE0E8819CF39E29F18@lhun.zbw-nett.zbw-kiel.de>
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?

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 16:50:51 UTC

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