You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* #288: Added sh:SelectExpression, with test cases and TTL changes
* #222, #288: Update SHACL-SHACL for general NodeExpression and SelectExpression
Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
* #222, #288: Undo update SHACL-SHACL for general NodeExpression and SelectExpression
This patch undoes commit 8632a3e. This was done manually instead of with `git revert`.
Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
* Update shacl12-vocabularies/shacl.ttl
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
* #301: Switched node expressions from sh:path to sh:values and sh:defaultValue
* Update shacl12-core/index.html
Co-authored-by: Tomasz Pluskiewicz <tpluscode@users.noreply.github.com>
* Apply suggestions from code review
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
* Update shacl12-core/index.html
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
* Update shacl12-core/index.html
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
* Update shacl12-sparql/index.html
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
* Update shacl12-core/index.html
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
* Update shacl12-core/index.html
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
* Update shacl12-core/index.html
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
* Moved example to after the evaluation part
* Attempted to clarify that the "or" is not either-or
* Update shacl12-core/index.html
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
---------
Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
Co-authored-by: Alex Nelson <alexander.nelson@nist.gov>
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
Co-authored-by: Tomasz Pluskiewicz <tpluscode@users.noreply.github.com>
<spandata-syntax-rule="PropertyShape">A <dfndata-lt="property shapes">property shape</dfn> is a <a>shape</a> in the <a>shapes graph</a>
1448
1448
that is the <a>subject</a> of a <a>triple</a> that has <code>sh:path</code> as its <a>predicate</a>.</span>
1449
1449
<spandata-syntax-rule="path-maxCount">A shape has at most one <a>value</a> for <code>sh:path</code>.</span>
1450
-
<br/><br/>
1451
-
<spandata-syntax-rule="path-node">The <a>value</a> of <code>sh:path</code> in a property shape is either a <a>well-formed</a>
1452
-
<a>SHACL property path</a> or a <a>well-formed</a><a>node expression</a>.</span>
1453
-
<spandata-syntax-rule="path-expr-order">The syntax rules for <a>SHACL property paths</a> take precedence over <a>node expressions</a>;
1454
-
for example, this means that an <a>IRI</a> will be interpreted as a <a>predicate path</a> instead of an <a>IRI expression</a>.</span>
1455
-
<spandata-syntax-rule="path-not-literal">The <a>value</a> of <code>sh:path</code> cannot be a <a>literal</a>.</span>
1450
+
<spandata-syntax-rule="path-node">The <a>value</a> of <code>sh:path</code> in a property shape is a <a>well-formed</a>
1451
+
<a>SHACL property path</a>.</span>
1456
1452
<br/><br/>
1457
1453
It is recommended, but not required, for a <a>property shape</a> to be declared as a <a>SHACL instance</a> of <code>sh:PropertyShape</code>.
1458
1454
<spandata-syntax-rule="PropertyShape-path-minCount"><a>SHACL instances</a> of <code>sh:PropertyShape</code> have one <a>value</a> for the property <code>sh:path</code>.</span>
1455
+
<br/><br/>
1456
+
<spandata-syntax-rule="path-values">A <a>property shape</a> has at most one <a>value</a> for the property <code>sh:values</code> and this <a>value</a> is a <a>well-formed</a><a>node expression</a>.</span>
1457
+
<spandata-syntax-rule="path-defaultValue">A <a>property shape</a> has at most one <a>value</a> for the property <code>sh:defaultValue</code> and this <a>value</a> is a <a>well-formed</a><a>node expression</a>.</span>
1458
+
<spandata-syntax-rule="path-values-iri">A <a>property shape</a> can only have <a>values</a> for <code>sh:values</code> and/or <code>sh:defaultValue</code> when its <a>value</a> for <code>sh:path</code> is a <ahref="#property-path-predicate">Predicate Path</a>.</span>
1459
1459
</p>
1460
1460
<p>
1461
1461
Informally, property shapes specify constraints that need to be met with respect to <a>nodes</a> that can be reached from the
1462
-
<a>focus node</a> either by directly following a given property (specified as an <a>IRI</a>) or any other <a>SHACL property path</a>,
1463
-
specified using <code>sh:path</code>.
1462
+
<a>focus node</a> by either (a) directly following a given property (specified as an <a>IRI</a>), (b) directly following any other <a>SHACL property path</a>
1463
+
(specified using <code>sh:path</code>), (c) evaluating the node expression (specified using <code>sh:values</code>),
1464
+
or, (d) if no other values exist, evaluating the node expression (specified using <code>sh:defaultValue</code>).
1464
1465
</p>
1465
1466
<p>
1466
-
If the <code>sh:path</code> is not a <a>well-formed</a> property path, it must be a <a>node expression</a>
1467
-
and the constraints will be validated against the <a>output nodes</a> of this node expression.
1468
-
Note that support for node expressions is not required by SHACL Core,
1467
+
Note that support for <code>sh:values</code> and <code>sh:defaultValue</code> is not required by SHACL Core,
1469
1468
but is necessary for extensions such as [[shacl12-sparql]].
1470
1469
</p>
1471
1470
<p>
@@ -1514,8 +1513,9 @@ <h2>SHACL Expressions</h2>
1514
1513
SHACL Core supports such expressions in the following features:
1515
1514
</p>
1516
1515
<ul>
1516
+
<li>Property paths can be used at <ahref="#property-shapes"><code>sh:path</code></a> to derive the value nodes of a property shape.</li>
1517
+
<li>Node expressions can be used at <ahref="#property-shapes"><code>sh:values</code> and <code>sh:defaultValue</code></a> to derive the value nodes of a property shape.</li>
1517
1518
<li>Node expressions can be used at <ahref="#targetNode"><code>sh:targetNode</code></a> to dynamically compute the targets of a shape.</li>
1518
-
<li>Property paths and node expressions can be used at <ahref="#property-shapes"><code>sh:path</code></a> to derive the value nodes of a property shape.</li>
1519
1519
<li>Node expressions can be used as parameter values of most <ahref="#core-components">constraint components</a> to represent constraints that may be different depending on each focus node. <spanclass="todo">TODO: This change needs to be made still.</span></li>
1520
1520
</ul>
1521
1521
@@ -1678,21 +1678,37 @@ <h3>Node Expressions</h3>
1678
1678
Each of these parameters has an <a>IRI</a>.
1679
1679
One of these parameters can be the <dfn>key parameter</dfn> that uniquely identifies the <a>function name</a>.
1680
1680
</div>
1681
+
<divclass="def" id="node-expression-evaluation">
1682
+
<divclass="def-header">EVALUATION OF NODE EXPRESSIONS</div>
1683
+
The <dfn>evaluation</dfn> of a node expression is defined as a function <code>eval(expr, activeGraph, scope) -> outputNodes</code>
1684
+
where
1685
+
<ul>
1686
+
<li><code>expr</code> is a <a>node expression</a> that is the <a>subject</a> of <a>triples</a> where the <a>predicates</a> are the <a>node expression parameters</a>,
1687
+
optional for any but the <a>key parameter</a> unless stated otherwise in the definition of the node expression function.</li>
1688
+
<li><code>activeGraph</code> is a <a>graph</a>, called the <dfn>active graph</dfn>.</li>
1689
+
<li><code>scope</code> is a map from <ahref="https://www.w3.org/TR/sparql12-query/#defn_QueryVariable">variable names</a> to individual <a>nodes</a>.
1690
+
The value of the variable <code>focusNode</code> (if it exists) is called the <dfn>input focus node</dfn>.
1691
+
</li>
1692
+
</ul>
1693
+
The result of the evaluation of a node expression is a list of <a>nodes</a> (possibly empty and with duplicates) called the <dfn>output nodes</dfn>.
1694
+
The evaluation may also result in an <dfn>evaluation failure</dfn>.
1695
+
</div>
1681
1696
<p>
1682
-
The following example illustrates the syntax of a node expression, used as a blank node value of <code>sh:path</code>:
1697
+
The following example illustrates the syntax of a node expression, used as a blank node value of <code>sh:values</code>:
1683
1698
</p>
1684
1699
<asideclass="example" title="A dynamically computed property using a node expression based on a SPARQL query">
1685
1700
<p>
1686
1701
Here is an example use of a node expression based on <adata-cite="shacl12-sparql#SelectExpression">SHACL-SPARQL</a>, computing
1687
-
the values of a property shape for the property "full name" as the concatenation of <code>ex:firstName</code>,
1688
-
a space and the <code>ex:lastName</code>.
1702
+
the values of a property shape for the property "full name" as the concatenation of the <code>ex:firstName</code>,
1703
+
a space, and the <code>ex:lastName</code>.
1689
1704
</p>
1690
1705
<divclass="shapes-graph">
1691
1706
<divclass="turtle">
1692
1707
ex:Person-fullName
1693
1708
a sh:PropertyShape ;
1694
1709
sh:name "full name" ;
1695
-
sh:path <b>[
1710
+
sh:path ex:fullName ;
1711
+
sh:values <b>[
1696
1712
sh:select """
1697
1713
PREFIX ex: <http://example.org/ns#>
1698
1714
SELECT ?fullName
@@ -1711,23 +1727,8 @@ <h3>Node Expressions</h3>
1711
1727
and the <a>function name</a> is (as defined by SHACL-SPARQL) is <code>sh:SelectExpression</code>.
1712
1728
</p>
1713
1729
</aside>
1714
-
<divclass="def" id="node-expression-evaluation">
1715
-
<divclass="def-header">EVALUATION OF NODE EXPRESSIONS</div>
1716
-
The <dfn>evaluation</dfn> of a node expression is defined as a function <code>eval(expr, activeGraph, scope) -> outputNodes</code>
1717
-
where
1718
-
<ul>
1719
-
<li><code>expr</code> is a <a>node expression</a> that is the <a>subject</a> of <a>triples</a> where the <a>predicates</a> are the <a>node expression parameters</a>,
1720
-
optional for any but the <a>key parameter</a> unless stated otherwise in the definition of the node expression function.</li>
1721
-
<li><code>activeGraph</code> is a <a>graph</a>, called the <dfn>active graph</dfn>.</li>
1722
-
<li><code>scope</code> is a map from <ahref="https://www.w3.org/TR/sparql12-query/#defn_QueryVariable">variable names</a> to individual <a>nodes</a>.
1723
-
The value of the variable <code>focusNode</code> (if it exists) is called the <dfn>input focus node</dfn>.
1724
-
</li>
1725
-
</ul>
1726
-
The result of the evaluation of a node expression is a list of <a>nodes</a> (possibly empty and with duplicates) called the <dfn>output nodes</dfn>.
1727
-
The evaluation may also result in an <dfn>evaluation failure</dfn>.
1728
-
</div>
1729
1730
<p>
1730
-
This SHACL Core specification only defines exactly the <a>node expression functions</a> from the following two sections.
1731
+
This SHACL Core specification only exactly defines the <a>node expression functions</a> from the following two subsections.
1731
1732
Other specifications such as [[shacl12-sparql]] introduce additional functions.
1732
1733
Therefore <a>node expressions</a> serve as an extension point of SHACL.
1733
1734
<spanclass="todo">TODO: Add link to shacl12-node-expr once that is stable.</span>
Validation results may have a value for the property <code>sh:resultPath</code> pointing at a <a>well-formed</a><a>SHACL property path</a>
2093
-
or <a>node expression</a>.
2093
+
Validation results may have a value for the property <code>sh:resultPath</code> pointing at a <a>well-formed</a><a>SHACL property path</a>.
2094
2094
For results produced by a <a>property shape</a>, this <a>SHACL property path</a> is equivalent to the <a>value</a> of <code>sh:path</code> of the shape,
2095
2095
unless stated otherwise. <!-- sh:closed is an exception -->
2096
+
If the <code>sh:path</code><code>p</code> is a <a>blank node</a>, then the <code>sh:resultPath</code> is a "deep copy"
2097
+
of <code>p</code> and any <a>triples</a> that can be reached by transitively traversing the <a>blank nodes</a>
2098
+
that appear in the <a>object</a> position of these triples.
2099
+
See the <ahref="https://www.w3.org/submissions/CBD/">Concise Bounded Description</a>.
2096
2100
</p>
2097
2101
</section>
2098
2102
<sectionid="results-value">
@@ -2167,22 +2171,23 @@ <h4>Value Nodes of Node Shapes</h4>
2167
2171
<h4>Value Nodes of Property Shapes</h4>
2168
2172
<p>
2169
2173
For <a>property shapes</a> with a <a>value</a> for <code>sh:path</code><code>p</code> the
2170
-
<a>value nodes</a> are defined as follows.
2171
-
</p>
2172
-
<p>
2173
-
If <code>p</code> is a <a>SHACL property path</a>, then its value nodes are the set of <a>nodes</a> in the <a>data graph</a>
2174
-
that can be reached from the <a>focus node</a> with the <a>path mapping</a> of <code>p</code>.
2175
-
</p>
2176
-
<p>
2177
-
If <code>p</code> is a <a>node expression</a>, then its value nodes are the set of <a>output nodes</a> of
2178
-
<code>eval(p, <a>data graph</a>, scope)</code> where <code>scope</code> contains the <a>focus node</a> as value of the variable <code>focusNode</code>.
2179
-
</p>
2180
-
<p>
2181
-
Unless stated otherwise, the value of <code>sh:resultPath</code> of each validation result is a "deep copy"
2182
-
of <code>p</code> and any <a>triples</a> that can be reached by transitively traversing the <a>blank nodes</a>
2183
-
that appear in the <a>object</a> position of these triples.
2184
-
See the <ahref="https://www.w3.org/submissions/CBD/">Concise Bounded Description</a>.
2174
+
set of <a>value nodes</a> is produced by the following steps:
2185
2175
</p>
2176
+
<ol>
2177
+
<li>
2178
+
Add all <a>nodes</a> in the <a>data graph</a> that can be reached from the <a>focus node</a> with the <a>path mapping</a> of <code>p</code>.
2179
+
</li>
2180
+
<li>
2181
+
If <code>e</code> is the <a>value</a> of <code>sh:values</code> at the <a>property shape</a>,
2182
+
then add the <a>output nodes</a> of <code>eval(e, <a>data graph</a>, scope)</code> where <code>scope</code>
2183
+
contains the <a>focus node</a> as the value of the variable <code>focusNode</code>.
2184
+
</li>
2185
+
<li>
2186
+
If the set is still empty and <code>d</code> is the <a>value</a> of <code>sh:defaultValue</code> at the <a>property shape</a>,
2187
+
then add the <a>output nodes</a> of <code>eval(d, <a>data graph</a>, scope)</code> where <code>scope</code>
2188
+
contains the <a>focus node</a> as the value of the variable <code>focusNode</code>.
2189
+
</li>
2190
+
</ol>
2186
2191
</section>
2187
2192
</section>
2188
2193
</section>
@@ -4158,16 +4163,6 @@ <h3>sh:group</h3>
4158
4163
Groups may also have an <code>sh:order</code> property to indicate
4159
4164
the relative ordering of groups within the same form.
4160
4165
</p>
4161
-
</section>
4162
-
<sectionid="defaultValue">
4163
-
<h3>sh:defaultValue</h3>
4164
-
<p>
4165
-
Property shapes may have a single value for <code>sh:defaultValue</code>.
4166
-
The default value does not have fixed semantics in SHACL,
4167
-
but MAY be used by user interface tools to pre-populate input widgets.
4168
-
The value type of the <code>sh:defaultValue</code> SHOULD align with
4169
-
the specified <code>sh:datatype</code> or <code>sh:class</code> of the same shape.
4170
-
</p>
4171
4166
<p>
4172
4167
The following example illustrates the use of these various features together.
<h2>Changes between SHACL 1.0 Core and SHACL 1.2 Core</h2>
4342
4337
<ul>
4343
-
<li>Introduced <a>node expressions</a> as an extension point to dynamically compute lists of nodes. Generalized <code>sh:targetNode</code> and <code>sh:path</code> to support node expressions.</li>
4338
+
<li>Introduced <a>node expressions</a> as an extension point to dynamically compute lists of nodes. Generalized <code>sh:targetNode</code> and <code>sh:defaultValue</code>, and introduced <code>sh:values</code> to support node expressions.</li>
4344
4339
<li>Added the new constraint component <ahref="#SingleLineConstraintComponent"><code>sh:singleLine</code></a>, see <ahref="https://github.com/w3c/data-shapes/issues/177">Issue 177</a></li>
4345
4340
<li>Added the new class <ahref="#ShapeClass"><code>sh:ShapeClass</code></a> for implicit class targets, see <ahref="https://github.com/w3c/data-shapes/issues/212">Issue 212</a></li>
4346
4341
<li>Moved SPARQL-based validators from Core to an Appendix of SHACL-SPARQL, see <ahref="https://github.com/w3c/data-shapes/issues/271">Issue 271</a></li>
0 commit comments