Skip to content

Commit 1d4d240

Browse files
authored
Merge pull request #410 from w3c/issue-407-nodekind
feat: #407 add support for sh:TripleTerm to sh:nodeKind and allow lists
2 parents 0e5c84b + 9f8582f commit 1d4d240

File tree

4 files changed

+130
-6
lines changed

4 files changed

+130
-6
lines changed

shacl12-core/index.html

Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3539,24 +3539,36 @@ <h4>sh:nodeKind</h4>
35393539
<tr>
35403540
<td><code>sh:nodeKind</code></td>
35413541
<td>
3542-
The node kind (IRI, blank node, literal or combinations of these) of all value nodes.
3543-
<span data-syntax-rule="nodeKind-in">The values of <code>sh:nodeKind</code> in a shape are one of the following six instances of the class <code>sh:NodeKind</code>:
3544-
<code>sh:BlankNode</code>, <code>sh:IRI</code>, <code>sh:Literal</code>
3545-
<code>sh:BlankNodeOrIRI</code>, <code>sh:BlankNodeOrLiteral</code> and <code>sh:IRIOrLiteral</code>.</span>
3542+
The node kind (IRI, blank node, literal, triple term, or combination of these) of all value nodes.
35463543
<span data-syntax-rule="nodeKind-maxCount">A shape has at most one value for <code>sh:nodeKind</code>.</span>
3544+
The value of <code>sh:nodeKind</code> in a shape is either an IRI or a blank node that is a well-formed SHACL list where all members are IRIs.
3545+
<br /><br />
3546+
<span data-syntax-rule="nodeKind-in">
3547+
If the values of <code>sh:nodeKind</code> are IRIs, then the values of <code>sh:nodeKind</code> in a shape are one of the following seven instances of the class <code>sh:NodeKind</code>:
3548+
<code>sh:BlankNode</code>, <code>sh:IRI</code>, <code>sh:Literal</code>
3549+
<code>sh:BlankNodeOrIRI</code>, <code>sh:BlankNodeOrLiteral</code>, <code>sh:IRIOrLiteral</code>, and <code>sh:TripleTerm</code>.
3550+
<br /><br />
3551+
If the values of <code>sh:nodeKind</code> are well-formed SHACL lists, then members of those lists in a shape are one of the following four instances of the class <code>sh:NodeKind</code>:
3552+
<code>sh:BlankNode</code>, <code>sh:IRI</code>, <code>sh:Literal</code>, and <code>sh:TripleTerm</code>.
3553+
</span>
35473554
</td>
35483555
</tr>
35493556
</tbody></table>
35503557
<div class="def def-text">
35513558
<div class="def-header">TEXTUAL DEFINITION</div>
35523559
<div class="def-text-body" data-validator="NodeKind">
35533560
Let <code>$nodeKind</code> be a <a>parameter value</a> for <code>sh:nodeKind</code>.
3561+
Let <code>$nodeKinds</code> be a set of <a>IRIs</a> so that
3562+
when <code>$nodeKind</code> is an <a>IRI</a> then the set only consists of exactly that IRI,
3563+
and when <code>$nodeKind</code> is a <a>blank node</a> <a>SHACL list</a> then the set consists of
3564+
exactly the members of the list.<br /><br />
35543565
For each <a>value node</a>
3555-
that does not match <code>$nodeKind</code>,
3566+
that matches none of the <code>$nodeKinds</code>,
35563567
there is a <a>validation result</a> with the <a>value node</a> as <code>sh:value</code>.
35573568
Any <a>IRI</a> matches only <code>sh:IRI</code>, <code>sh:BlankNodeOrIRI</code> and <code>sh:IRIOrLiteral</code>.
35583569
Any <a>blank node</a> matches only <code>sh:BlankNode</code>, <code>sh:BlankNodeOrIRI</code> and <code>sh:BlankNodeOrLiteral</code>.
35593570
Any <a>literal</a> matches only <code>sh:Literal</code>, <code>sh:BlankNodeOrLiteral</code> and <code>sh:IRIOrLiteral</code>.
3571+
Any <a>triple term</a> matches only <code>sh:TripleTerm</code>.
35603572
</div>
35613573
</div>
35623574
<p><em>The remainder of this section is informative.</em></p>
@@ -3589,7 +3601,7 @@ <h4>sh:nodeKind</h4>
35893601
<div class="data-graph">
35903602
<div class="turtle">
35913603
ex:Bob ex:knows ex:Alice .
3592-
ex:Alice ex:knows <span class="focus-node-error">"Bob"</span> .
3604+
ex:Alice ex:knows <span class="focus-node-error">"Bob"</span> .
35933605
</div>
35943606
<div class="jsonld">
35953607
<pre class="jsonld">{
@@ -3605,6 +3617,67 @@ <h4>sh:nodeKind</h4>
36053617
}
36063618
}
36073619
]
3620+
}</pre>
3621+
</div>
3622+
</div>
3623+
</aside>
3624+
<p>
3625+
The following example illustrates the list-based syntax, meaning that all values of <code>ex:knows</code>
3626+
need to be IRIs or blank nodes, at any subject.
3627+
</p>
3628+
<aside class="example">
3629+
<div class="shapes-graph">
3630+
<div class="turtle">
3631+
ex:NodeKindExampleShape
3632+
a sh:NodeShape ;
3633+
<span class="target-can-be-skipped">sh:targetObjectsOf ex:knows ;</span>
3634+
sh:nodeKind ( sh:BlankNode sh:IRI ) .
3635+
</div>
3636+
<div class="jsonld">
3637+
<pre class="jsonld">{
3638+
"@id": "ex:NodeKindExampleShape",
3639+
"@type": "sh:NodeShape",
3640+
"sh:nodeKind": {
3641+
"@list": [
3642+
{
3643+
"@id": "sh:BlankNode"
3644+
},
3645+
{
3646+
"@id": "sh:IRI"
3647+
}
3648+
]
3649+
},
3650+
"sh:targetObjectsOf": {
3651+
"@id": "ex:knows"
3652+
}
3653+
}</pre>
3654+
</div>
3655+
</div>
3656+
<div class="data-graph">
3657+
<div class="turtle">
3658+
ex:Bob ex:knows ex:Alice .
3659+
ex:Bob ex:knows _:john .
3660+
ex:Alice ex:knows <span class="focus-node-error">"Bob"</span> .
3661+
</div>
3662+
<div class="jsonld">
3663+
<pre class="jsonld">{
3664+
"@graph": [
3665+
{
3666+
"@id": "ex:Alice",
3667+
"ex:knows": "Bob"
3668+
},
3669+
{
3670+
"@id": "ex:Bob",
3671+
"ex:knows": [
3672+
{
3673+
"@id": "ex:Alice"
3674+
},
3675+
{
3676+
"@id": "_:b1"
3677+
}
3678+
]
3679+
}
3680+
]
36083681
}</pre>
36093682
</div>
36103683
</div>
@@ -7685,6 +7758,7 @@ <h2>Changes between SHACL 1.0 Core and SHACL 1.2 Core</h2>
76857758
<li>Added new <a href="#core-components-list">List constraint components</a>, see <a href="https://github.com/w3c/data-shapes/issues/391">Issue 391</a> and <a href="https://github.com/w3c/data-shapes/issues/414">Issue 414</a></li>
76867759
<li>Added the new value <code>sh:ByTypes</code> for <a href="#ClosedConstraintComponent"><code>sh:closed</code></a>; see <a href="https://github.com/w3c/data-shapes/issues/172">Issue 172</a></li>
76877760
<li>The values of <a href="#ClassConstraintComponent"><code>sh:class</code></a> and <a href="#DatatypeConstraintComponent"><code>sh:datatype</code></a> can now also be lists, indicating a union of choices; see <a href="https://github.com/w3c/data-shapes/issues/160">Issue 160</a></li>
7761+
<li>The values of <a href="#NodeKindConstraintComponent"><code>sh:nodeKind</code></a> can now also be lists, indicating a union of choices; see <a href="https://github.com/w3c/data-shapes/issues/407">Issue 407</a></li>
76887762
<li>Added the new constraint component <a href="#ReifierShapeShapeConstraintComponent"><code>sh:ReifierShape</code></a>; see <a href="https://github.com/w3c/data-shapes/issues/300">Issue 300</a></li>
76897763
<li>Added parameter <a href="#subClassOfInShapesGraph"></a> to look up rdfs:subClassOf triples in the union of the shapes graph and the data graph; see <a href="https://github.com/w3c/data-shapes/issues/185">Issue 185</a></li>
76907764
<li>Generalized <a href="#order"></a> to also allow xsd:integers; see <a href="https://github.com/w3c/data-shapes/issues/479">Issue 479</a></li>

shacl12-test-suite/tests/core/node/manifest.ttl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
mf:include <node-001.ttl> ;
3737
mf:include <nodeByExpression-001.ttl> ;
3838
mf:include <nodeKind-001.ttl> ;
39+
mf:include <nodeKind-002.ttl> ;
3940
mf:include <not-001.ttl> ;
4041
mf:include <not-002.ttl> ;
4142
mf:include <or-001.ttl> ;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@prefix dash: <http://datashapes.org/dash#> .
2+
@prefix ex: <http://datashapes.org/sh/tests/core/node/nodeKind-002.test#> .
3+
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
4+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
5+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
6+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
7+
@prefix sh: <http://www.w3.org/ns/shacl#> .
8+
@prefix sht: <http://www.w3.org/ns/shacl-test#> .
9+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
10+
11+
ex:IRITestShape
12+
rdf:type sh:NodeShape ;
13+
sh:nodeKind ( sh:BlankNode sh:IRI ) ;
14+
sh:targetNode ex:John ;
15+
sh:targetNode _:bob ;
16+
sh:targetNode "true"^^xsd:boolean ;
17+
.
18+
<>
19+
rdf:type mf:Manifest ;
20+
mf:entries (
21+
<nodeKind-002>
22+
) ;
23+
.
24+
<nodeKind-002>
25+
rdf:type sht:Validate ;
26+
rdfs:label "Test of sh:nodeKind at node shape 002" ;
27+
mf:action [
28+
sht:dataGraph <> ;
29+
sht:shapesGraph <> ;
30+
] ;
31+
mf:result [
32+
rdf:type sh:ValidationReport ;
33+
sh:conforms "false"^^xsd:boolean ;
34+
sh:result [
35+
rdf:type sh:ValidationResult ;
36+
sh:focusNode "true"^^xsd:boolean ;
37+
sh:resultSeverity sh:Violation ;
38+
sh:sourceConstraintComponent sh:NodeKindConstraintComponent ;
39+
sh:sourceShape ex:IRITestShape ;
40+
sh:value "true"^^xsd:boolean ;
41+
] ;
42+
] ;
43+
mf:status sht:approved ;
44+
.

shacl12-vocabularies/shacl.ttl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ sh:Literal
166166
rdfs:comment "The node kind of all literals."@en ;
167167
rdfs:isDefinedBy sh: .
168168

169+
sh:TripleTerm
170+
a sh:NodeKind ;
171+
rdfs:label "Triple term"@en ;
172+
rdfs:comment "The node kind of all triple terms."@en ;
173+
rdfs:isDefinedBy sh: .
169174

170175
# Results vocabulary ----------------------------------------------------------
171176

0 commit comments

Comments
 (0)