Use VALUES as a templating mechanism?

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