diff --git a/shacl12-core/index.html b/shacl12-core/index.html index 0e34e5e5..00ef26a4 100644 --- a/shacl12-core/index.html +++ b/shacl12-core/index.html @@ -2616,7 +2616,7 @@
expr
in the shapes graph.
focusGraph
is a graph, called the focus graph. This is the default query graph for the evaluation of the node expression.focusNode
is a node, called the input focus node. This variable may have no value.scope
is a map from variable names to individual nodes.
+ scope
is a map from (key) nodes to individual (value) nodes.
The empty map is written as {}
.
+ SHACL includes vocabulary terms that can be used to define new node expression functions + by wrapping other (parameterized) node expressions. + This makes it possible to extend the library of available SHACL node expressions without having to + hard-code changes to an engine. +
+ +
+
+ A custom named parameter function is an IRI in a shapes graph
+ that is a SHACL instance of sh:NamedParameterExpressionFunction
and
+ a SHACL subclass of sh:NamedParameterExpression
.
+ It has a single value for sh:bodyExpression
that is a well-formed
+ node expression.
+
+ A custom named parameter function declares one or more parameters as values
+ of sh:parameter
, where each such parameter has exactly one value for
+ sh:path
and that value is an IRI.
+ At least one of the parameters has sh:keyParameter true
, declaring the key parameters
+ for the function.
+ The key parameters of all node expression functions
+ (including the built-in ones from the shnex:
namespace) must be disjoint.
+
+ Custom named parameter functions can reference the declared parameters using an
+ arg expression such as [ shnex:arg ex:param ]
, where the value of shnex:arg
+ matches the IRI of the parameter's sh:path
.
+
+
+ + A custom named parameter expression is a node expression + represented by a blank node that has exactly one value for at least one of + the key parameters. + +
+
+ Let expr
be a custom named parameter expression with the
+ custom named parameter function f
.
+ Let body
be the value of sh:bodyExpression
at f
+ in the shapes graph.
+
+ Let argScope
be a map of (parameter) nodes as keys and (argument) nodes
+ as values, so that each parameter of f
has the value of the parameter's
+ sh:path
from expr
.
+ For example, if f
declares just one parameter with sh:path
ex:param
+ and expr
is [ ex:param 42 ]
then argScope
is { ex:param : 42 }
.
+
+ The output nodes of expr
are computed using
+ evalExpr(expr, focusGraph, focusNode, scope) -> evalExpr(body, focusGraph, focusNode, argScope)
+
The remainder of this section is informative.
+
+ The following example defines a new node expression function ex:AverageExpression
+ that takes another node expression as input using the key parameter ex:average
+ and then calculates the sum of all input nodes and divides it by the number of nodes,
+ returning the average value of these nodes.
+
+ This new node expression function can the be used as follows: +
+ +
+
+ A custom list parameter function is an IRI in a shapes graph
+ that is a SHACL instance of sh:ListParameterExpressionFunction
and
+ a SHACL subclass of sh:ListParameterExpression
.
+ The IRI of a custom list parameter function is its list parameter property.
+ It has a single value for sh:bodyExpression
that is a well-formed
+ node expression.
+
+ Custom list parameter functions can reference the arguments using an
+ arg expression such as [ shnex:arg 0 ]
and [ shnex:arg 1 ]
+ where the xsd:integer
n
corresponds to the n
th member
+ of the arguments list, starting with 0
as the first member.
+
+
+ + A custom list parameter expression is a node expression + represented by a blank node that is the subject of exactly one triple + and the predicate of that triple is the list parameter property of a + custom list parameter function in the shapes graph. + +
+
+ Let expr
be a custom list parameter expression with the
+ custom list parameter function f
.
+ Let body
be the value of sh:bodyExpression
at f
+ in the shapes graph.
+
+ Let argScope
be a map of (parameter index) nodes as keys and (argument) nodes
+ as values, so that each list argument of expr
has the index of the argument as an
+ xsd:integer
as key, starting with 0
for the first argument.
+ For example, if expr
has arguments ( 38 4 )
then the
+ argScope
is { 0 : 38, 1 : 4 }
.
+
+ The output nodes of expr
are computed using
+ evalExpr(expr, focusGraph, focusNode, scope) -> evalExpr(body, focusGraph, focusNode, argScope)
+ where an evaluation failure is reported when there is more than 1 output node.
+
The remainder of this section is informative.
+
+ The following example defines a new node expression function ex:spacedConcat
+ that takes two nodes as input and returns a string concatenating the two nodes with a space in between.
+
+ This new node expression function can the be used as follows: +
+ +
+ Custom node expressions can use shnex:arg
to access the arguments.
+
+
+ A blank node that is the subject of the following properties
+ is called an arg expression with the function name shnex:ArgExpression
:
+
+
+
+
+ Property
+ Constraints
+ Description
+
+
+
+
+
+
+ shnex:arg
+
+
+ sh:or (
+
+ [ sh:nodeKind sh:IRI ]
+ [ sh:datatype xsd:integer ]
+ )
+
+ The argument key, e.g.
+ ex:myParameter
or 1
.
+
+ Let arg
be the value of shnex:arg
in the arg expression.
+ The output nodes of the var expression are computed as follows, in order:
+
arg
is in the scope
and has the value a
then
+ evalExpr(expr, focusGraph, focusNode, scope) -> evalExpr(a, focusGraph, focusNode, {})
+ evalExpr(expr, focusGraph, focusNode, scope) -> []
The remainder of this section is informative.
+
+ Both shnex:arg
and shnex:var
access values from the scope.
+ The difference is that shnex:arg
interprets the values as node expressions, while
+ shnex:var
treats the values as individual nodes.
+ As a result, a custom node expression can evaluate nested node expressions that are passed in as arguments.
+
@@ -2765,7 +3024,7 @@
- During validation, a Dynamic SHACL engine will evaluate the path expression at sh:in
+ During validation, a Dynamic SHACL engine will evaluate the path values expression at sh:in
and use the resulting nodes as members of the allowed values.
Thus, when the value of ex:country
is ex:USA
, it will look up the
state codes that are linked to ex:USA
.
diff --git a/shacl12-vocabularies/shacl.ttl b/shacl12-vocabularies/shacl.ttl
index 71d6333a..ed980e9b 100644
--- a/shacl12-vocabularies/shacl.ttl
+++ b/shacl12-vocabularies/shacl.ttl
@@ -1386,6 +1386,13 @@ sh:ListParameterExpression
rdfs:subClassOf sh:NodeExpression ;
rdfs:isDefinedBy sh: .
+sh:bodyExpression
+ a rdf:Property ;
+ rdfs:label "body expression"@en ;
+ rdfs:comment "A node expression that is the implementation/body of a custom node expression function."@en ;
+ rdfs:domain sh:NodeExpressionFunction ;
+ rdfs:isDefinedBy sh: .
+
# General SPARQL execution support --------------------------------------------