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
Issue 481 - move nodeByExpression and expression to Node Expr spec and give better examples (#492)
* #481: Moved sh:expression and sh:nodeByExpression to Node Expression spec
* Added example for sh:expression and changed binding of focusNode and added scope var "value"
* Added example for sh:nodeByExpression
* Fixed tabs vs spaces
* Moved test cases from core into node-expr
* Taking out the ability to specify sh:message in sh:expression
* PR feedback applied
---------
Co-authored-by: Matt Goldberg <[email protected]>
Copy file name to clipboardExpand all lines: shacl12-core/index.html
-283Lines changed: 0 additions & 283 deletions
Original file line number
Diff line number
Diff line change
@@ -2591,8 +2591,6 @@ <h2>Node Expressions</h2>
2591
2591
<ul>
2592
2592
<li>At <ahref="#property-shapes"><code>sh:values</code> and <code>sh:defaultValue</code></a> to derive the value nodes of a property shape.</li>
2593
2593
<li>At <ahref="#targetNode"><code>sh:targetNode</code></a> to dynamically compute the targets of a shape.</li>
2594
-
<li>At <ahref="#NodeByExpressionConstraintComponent"><code>sh:nodeByExpression</code></a> to validate nodes against a dynamically computed set of node shapes.</li>
2595
-
<li>At <ahref="#ExpressionConstraintComponent"><code>sh:expression</code></a> to validate nodes against a condition.</li>
2596
2594
<li>At <ahref="#deactivated"><code>sh:deactivated</code></a> to deactivate certain shapes under specific conditions.</li>
The <a>node shapes</a> that all value nodes need to conform to.
6837
-
<spandata-syntax-rule="nodeByExpression-scope">The <a>values</a> of <code>sh:nodeByExpression</code> in a shape must be <a>well-formed</a><a>node expressions</a>.</span>
Let <code>$expr</code> be a <a>value</a> of <code>sh:nodeByExpression</code>.
6845
-
For each <a>value node</a><code>v</code>: perform a <a>conformance check</a> of
6846
-
<code>v</code> against each <a>output node</a> of <code>evalExpr(expr,
6847
-
<a>data graph</a>, v, {})</code><code>s</code>. A <a>failure</a>
6848
-
MUST be produced if the <a>conformance check</a> of <code>v</code> against
6849
-
<code>s</code> produces a <a>failure</a>. Otherwise, if <code>v</code> does
6850
-
not <a>conform</a> to <code>s</code>, there is a <a>validation result</a>
6851
-
with <code>v</code> as <code>sh:value</code> and a <a>deep copy</a> of
6852
-
<code>s</code> as <code>sh:sourceConstraint</code>.
6853
-
</div>
6854
-
</div>
6855
-
<p><em>The remainder of this section is informative.</em></p>
6856
-
<p>
6857
-
<code>sh:nodeByExpression</code> functions similarly to <code>sh:node</code>, but instead of referencing a fixed <a>node shape</a>,
6858
-
a referenced <a>node expression</a> is used to dynamically compute the set of <a>node shapes</a> to which each <a>value node</a> must conform.
6859
-
</p>
6860
-
<p>
6861
-
There are three key differences between <code>sh:nodeByExpression</code> and <ahref="#NodeConstraintComponent"><code>sh:node</code></a>:
6862
-
<ol>
6863
-
<li>
6864
-
<code>sh:nodeByExpression</code> references a <a>node expression</a> instead of a fixed <a>node shape</a> as <code>sh:node</code> does.
6865
-
</li>
6866
-
<li>
6867
-
<code>sh:nodeByExpression</code> cannot reference a <a>node shape</a> that is a <a>blank node</a> as a value like <code>sh:node</code> can,
6868
-
as a <a>blank node</a> would be interpreted as a <a>node expression</a>.
6869
-
</li>
6870
-
<li>
6871
-
<a>Results</a> generated by <code>sh:nodeByExpression</code> additionally include a value for `sh:sourceConstraint`.
6872
-
</li>
6873
-
6874
-
</ol>
6875
-
</p>
6876
-
<p>
6877
-
Note that <code>sh:node</code> and <code>sh:nodeByExpression</code> exhibit the same behavior when given a <a>value</a> that is an <a>IRI</a> of a <a>node shape</a>.
6878
-
In this case, <code>sh:node</code> directly validates against the specified <a>node shape</a>, whereas <code>sh:nodeByExpression</code> interprets the <a>IRI</a>
6879
-
as an <a>IRI expression</a> that evaluates to a set containing the same <a>node shape</a>.
6880
-
</p>
6881
-
<p>
6882
-
In the following example, all values of the property <code>ex:address</code> must fulfill the
6883
-
constraints expressed by the <a>shape</a><code>ex:AddressShape</code>.
6884
-
</p>
6885
-
<asideclass="example">
6886
-
<divclass="shapes-graph">
6887
-
<divclass="turtle">
6888
-
ex:AddressShape
6889
-
a sh:NodeShape ;
6890
-
sh:property [
6891
-
sh:path ex:postalCode ;
6892
-
sh:datatype xsd:string ;
6893
-
sh:maxCount 1 ;
6894
-
] .
6895
-
6896
-
ex:PersonShape
6897
-
a sh:NodeShape ;
6898
-
sh:targetClass ex:Person ;
6899
-
sh:property [ # _:b1
6900
-
sh:path ex:address ;
6901
-
sh:minCount 1 ;
6902
-
sh:nodeByExpression ex:AddressShape ;
6903
-
] .
6904
-
</div>
6905
-
<divclass="jsonld">
6906
-
<preclass="jsonld">{
6907
-
"@graph": [
6908
-
{
6909
-
"@id": "ex:AddressShape",
6910
-
"@type": "sh:NodeShape",
6911
-
"sh:property": {
6912
-
"sh:datatype": {
6913
-
"@id": "xsd:string"
6914
-
},
6915
-
"sh:maxCount": {
6916
-
"@type": "xsd:integer",
6917
-
"@value": "1"
6918
-
},
6919
-
"sh:path": {
6920
-
"@id": "ex:postalCode"
6921
-
}
6922
-
}
6923
-
},
6924
-
{
6925
-
"@id": "ex:PersonShape",
6926
-
"@type": "sh:NodeShape",
6927
-
"sh:property": {
6928
-
"sh:minCount": {
6929
-
"@type": "xsd:integer",
6930
-
"@value": "1"
6931
-
},
6932
-
"sh:nodeByExpression": {
6933
-
"@id": "ex:AddressShape"
6934
-
},
6935
-
"sh:path": {
6936
-
"@id": "ex:address"
6937
-
}
6938
-
},
6939
-
"sh:targetClass": {
6940
-
"@id": "ex:Person"
6941
-
}
6942
-
}
6943
-
]
6944
-
}</pre>
6945
-
</div>
6946
-
</div>
6947
-
<divclass="data-graph">
6948
-
<divclass="turtle">
6949
-
ex:Bob a ex:Person ;
6950
-
ex:address ex:BobsAddress .
6951
-
6952
-
ex:BobsAddress
6953
-
ex:postalCode "1234" .
6954
-
6955
-
<spanclass="focus-node-error">ex:Reto</span> a ex:Person ;
6956
-
ex:address ex:RetosAddress .
6957
-
6958
-
ex:RetosAddress
6959
-
ex:postalCode 5678 .
6960
-
</div>
6961
-
<divclass="jsonld">
6962
-
<preclass="jsonld">{
6963
-
"@graph": [
6964
-
{
6965
-
"@id": "ex:Bob",
6966
-
"@type": "ex:Person",
6967
-
"ex:address": {
6968
-
"@id": "ex:BobsAddress"
6969
-
}
6970
-
},
6971
-
{
6972
-
"@id": "ex:BobsAddress",
6973
-
"ex:postalCode": "1234"
6974
-
},
6975
-
{
6976
-
"@id": "ex:Reto",
6977
-
"@type": "ex:Person",
6978
-
"ex:address": {
6979
-
"@id": "ex:RetosAddress"
6980
-
}
6981
-
},
6982
-
{
6983
-
"@id": "ex:RetosAddress",
6984
-
"ex:postalCode": {
6985
-
"@type": "xsd:integer",
6986
-
"@value": "5678"
6987
-
}
6988
-
}
6989
-
]
6990
-
}</pre>
6991
-
</div>
6992
-
</div>
6993
-
<divclass="results-graph">
6994
-
<divclass="turtle">
6995
-
[ a sh:ValidationReport ;
6996
-
sh:conforms false ;
6997
-
sh:result [
6998
-
a sh:ValidationResult ;
6999
-
sh:resultSeverity sh:Violation ;
7000
-
sh:focusNode ex:Reto ;
7001
-
sh:resultPath ex:address ;
7002
-
sh:value ex:RetosAddress ;
7003
-
sh:resultMessage "Value does not conform to shape ex:AddressShape." ;
Let <code>$expr</code> be a <a>value</a> of <code>sh:expression</code>.
7452
-
For each <a>value node</a><code>v</code>
7453
-
where <code>evalExpr(expr, <a>data graph</a>, v, {})</code>
7454
-
does not return the list consisting of exactly <code>true</code> as its <a>output nodes</a>,
7455
-
there is a <a>validation result</a> that has <code>v</code> as its <code>sh:value</code>
7456
-
and a <a>deep copy</a> of <code>$expr</code> in the results graph as its <code>sh:sourceConstraint</code>.
7457
-
If the <code>$expr</code> has <a>values</a> for <code>sh:message</code> in the <a>shapes graph</a>,
7458
-
then these <a>values</a> become the (only) values for <code>sh:resultMessage</code> in the
7459
-
<a>validation result</a>.
7460
-
</div>
7461
-
</div>
7462
-
</section>
7463
7182
</section>
7464
7183
</section>
7465
7184
@@ -7963,8 +7682,6 @@ <h2>Changes between SHACL 1.0 Core and SHACL 1.2 Core</h2>
7963
7682
<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>
7964
7683
<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>
7965
7684
<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>
7966
-
<li>Added the new constraint component <ahref="#ExpressionConstraintComponent"><code>sh:expression</code></a>; see <ahref="https://github.com/w3c/data-shapes/issues/357">Issue 357</a></li>
7967
-
<li>Added the new constraint component <ahref="#NodeByExpressionConstraintComponent"><code>sh:nodeByExpression</code></a>, see <ahref="https://github.com/w3c/data-shapes/issues/408">Issue 408</a></li>
7968
7685
<li>Added new <ahref="#core-components-list">List constraint components</a>, see <ahref="https://github.com/w3c/data-shapes/issues/391">Issue 391</a> and <ahref="https://github.com/w3c/data-shapes/issues/414">Issue 414</a></li>
7969
7686
<li>Added the new value <code>sh:ByTypes</code> for <ahref="#ClosedConstraintComponent"><code>sh:closed</code></a>; see <ahref="https://github.com/w3c/data-shapes/issues/172">Issue 172</a></li>
7970
7687
<li>The values of <ahref="#ClassConstraintComponent"><code>sh:class</code></a> and <ahref="#DatatypeConstraintComponent"><code>sh:datatype</code></a> can now also be lists, indicating a union of choices; see <ahref="https://github.com/w3c/data-shapes/issues/160">Issue 160</a></li>
0 commit comments