Functions invocation (was: ISSUE-95: Template Simplifications)

On 10/30/2015 3:45, Peter F. Patel-Schneider wrote:
> On 10/28/2015 10:29 PM, Holger Knublauch wrote:
>> On 10/29/2015 14:14, Peter F. Patel-Schneider wrote:
>>> Here is my proposal for a better simplification, based on changes to Part 2 of
> [...]
>>> I here propose several changes the normative bits of the version of Part 2
>>> that was prepared for ISSUE-95,
>>> http://w3c.github.io/data-shapes/shacl/index-ISSUE-95.html, that fix many of
>>> the problems there.  I have not proposed changes for any of the bits marked
>>> non-normative or any of the examples.
> [...]
>>> 9
>>>
>>> [Remove entirely, as there is no defined way to call functions.]
>> This is neither true nor helpful. SHACL functions can be called from every
>> SPARQL query (e.g. constraint or scope). Regardless of whether we keep
>> sh:NodeValidationFunctions, the general mechanism has proven to be extremely
>> successful in SPIN, leading to vastly more compact and better maintainable
>> SPARQL queries. The fact that sh:NodeValidationFunctions are also normal
>> SPARQL functions means that the business logic can be reused in multiple
>> places. There are approved requirements for functions, even "concise language"
>> falls into that category.
> How are these functions called from SPARQL?  I don't see any mechanism for this.

See http://www.w3.org/TR/sparql11-query/#extensionFunctions

which states that new SPARQL functions can be added to the SPARQL core 
and that the IRI of the function identifies the semantics. In the case 
of SHACL this means that SHACL-aware SPARQL processors could 
theoretically look up the function at its IRI, and it would find 
instructions on how to execute it.

The example from 9.1 
http://w3c.github.io/data-shapes/shacl/#an-example-function could be 
used as in

SELECT *
WHERE {
     ?subject ex:someProperty ?someValue .
     FILTER ex:exampleFunction(?someValue, 2) .
}

Holger

Received on Thursday, 29 October 2015 22:40:39 UTC