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

How to provide overridable default values?

From: Neubert, Joachim <J.Neubert@zbw.eu>
Date: Sat, 6 Dec 2014 09:20:14 +0000
To: "public-sparql-dev@w3.org" <public-sparql-dev@w3.org>
Message-ID: <4E3518D35BC4E14B802A8CAE0E8819CF39E8523D@lhun.zbw-nett.zbw-kiel.de>
I'm injecting input values into sparql queries via a VALUES clause. However, in some cases, I want to provide a computed default in the query which may or may not be overridden by injected input. The solution beyond works, but feels a bit clumsy.

Can somebody suggest a more elegant one?

Cheers, Joachim


  # input value (optionally set by user input)
  VALUES ( ?varInput ) {
    ( undef )

  # default value (computed via some sparql pattern/subquery)
  :someRessource :someProperty ?varDefault

  # use default value, overridden by input (if set)
  BIND(coalesce(?varInput, ?varDefault) AS ?var)

  ?s ?p ?var
Received on Saturday, 6 December 2014 09:20:42 UTC

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