Skip to content

Commit 44955e0

Browse files
committed
feat: #407 add support for sh:TripleTerm to sh:nodeKind and allow lists
1 parent a932976 commit 44955e0

File tree

4 files changed

+123
-6
lines changed

4 files changed

+123
-6
lines changed

shacl12-core/index.html

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3432,24 +3432,30 @@ <h4>sh:nodeKind</h4>
34323432
<tr>
34333433
<td><code>sh:nodeKind</code></td>
34343434
<td>
3435-
The node kind (IRI, blank node, literal or combinations of these) of all value nodes.
3436-
<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>:
3437-
<code>sh:BlankNode</code>, <code>sh:IRI</code>, <code>sh:Literal</code>
3438-
<code>sh:BlankNodeOrIRI</code>, <code>sh:BlankNodeOrLiteral</code> and <code>sh:IRIOrLiteral</code>.</span>
3435+
The node kind (IRI, blank node, literal, triple term or combinations of these) of all value nodes.
34393436
<span data-syntax-rule="nodeKind-maxCount">A shape has at most one value for <code>sh:nodeKind</code>.</span>
3437+
The value of sh:nodeKind in a shape is either an IRI or a blank node that is a well-formed SHACL list where all members are IRIs.
3438+
<span data-syntax-rule="nodeKind-in">The values or members of <code>sh:nodeKind</code> in a shape are one of the following seven instances of the class <code>sh:NodeKind</code>:
3439+
<code>sh:BlankNode</code>, <code>sh:IRI</code>, <code>sh:Literal</code>
3440+
<code>sh:BlankNodeOrIRI</code>, <code>sh:BlankNodeOrLiteral</code>, <code>sh:IRIOrLiteral</code> and <code>sh:TripleTerm</code>.</span>
34403441
</td>
34413442
</tr>
34423443
</table>
34433444
<div class="def def-text">
34443445
<div class="def-header">TEXTUAL DEFINITION</div>
34453446
<div class="def-text-body" data-validator="NodeKind">
34463447
Let <code>$nodeKind</code> be a <a>parameter value</a> for <code>sh:nodeKind</code>.
3448+
Let <code>$nodeKinds</code> be a set of <a>IRIs</a> so that
3449+
when <code>$nodeKind</code> is an <a>IRI</a> then the set only consists of exactly that IRI,
3450+
and when <code>$nodeKind</code> is a <a>blank node</a> <a>SHACL list</a> then the set consists of
3451+
exactly the members of the list.<br /><br />
34473452
For each <a>value node</a>
3448-
that does not match <code>$nodeKind</code>,
3453+
that matches none of the <code>$nodeKinds</code>,
34493454
there is a <a>validation result</a> with the <a>value node</a> as <code>sh:value</code>.
34503455
Any <a>IRI</a> matches only <code>sh:IRI</code>, <code>sh:BlankNodeOrIRI</code> and <code>sh:IRIOrLiteral</code>.
34513456
Any <a>blank node</a> matches only <code>sh:BlankNode</code>, <code>sh:BlankNodeOrIRI</code> and <code>sh:BlankNodeOrLiteral</code>.
34523457
Any <a>literal</a> matches only <code>sh:Literal</code>, <code>sh:BlankNodeOrLiteral</code> and <code>sh:IRIOrLiteral</code>.
3458+
Any <a>triple term</a> matches only <code>sh:TripleTerm</code>.
34533459
</div>
34543460
</div>
34553461
<p><em>The remainder of this section is informative.</em></p>
@@ -3480,7 +3486,7 @@ <h4>sh:nodeKind</h4>
34803486
<div class="data-graph">
34813487
<div class="turtle">
34823488
ex:Bob ex:knows ex:Alice .
3483-
ex:Alice ex:knows <span class="focus-node-error">"Bob"</span> .
3489+
ex:Alice ex:knows <span class="focus-node-error">"Bob"</span> .
34843490
</div>
34853491
<div class="jsonld">
34863492
<pre class="jsonld">{
@@ -3496,6 +3502,67 @@ <h4>sh:nodeKind</h4>
34963502
}
34973503
}
34983504
]
3505+
}</pre>
3506+
</div>
3507+
</div>
3508+
</aside>
3509+
<p>
3510+
The following example illustrates the list-based syntax, meaning that all values of <code>ex:knows</code>
3511+
need to be IRIs or blank nodes, at any subject.
3512+
</p>
3513+
<aside class="example">
3514+
<div class="shapes-graph">
3515+
<div class="turtle">
3516+
ex:NodeKindExampleShape
3517+
a sh:NodeShape ;
3518+
<span class="target-can-be-skipped">sh:targetObjectsOf ex:knows ;</span>
3519+
sh:nodeKind ( sh:BlankNode sh:IRI ) .
3520+
</div>
3521+
<div class="jsonld">
3522+
<pre class="jsonld">{
3523+
"@id": "ex:NodeKindExampleShape",
3524+
"@type": "sh:NodeShape",
3525+
"sh:nodeKind": {
3526+
"@list": [
3527+
{
3528+
"@id": "sh:BlankNode"
3529+
},
3530+
{
3531+
"@id": "sh:IRI"
3532+
}
3533+
]
3534+
},
3535+
"sh:targetObjectsOf": {
3536+
"@id": "ex:knows"
3537+
}
3538+
}</pre>
3539+
</div>
3540+
</div>
3541+
<div class="data-graph">
3542+
<div class="turtle">
3543+
ex:Bob ex:knows ex:Alice .
3544+
ex:Bob ex:knows _:john .
3545+
ex:Alice ex:knows <span class="focus-node-error">"Bob"</span> .
3546+
</div>
3547+
<div class="jsonld">
3548+
<pre class="jsonld">{
3549+
"@graph": [
3550+
{
3551+
"@id": "ex:Alice",
3552+
"ex:knows": "Bob"
3553+
},
3554+
{
3555+
"@id": "ex:Bob",
3556+
"ex:knows": [
3557+
{
3558+
"@id": "ex:Alice"
3559+
},
3560+
{
3561+
"@id": "_:b1"
3562+
}
3563+
]
3564+
}
3565+
]
34993566
}</pre>
35003567
</div>
35013568
</div>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
mf:include <minLength-001.ttl> ;
3232
mf:include <node-001.ttl> ;
3333
mf:include <nodeKind-001.ttl> ;
34+
mf:include <nodeKind-002.ttl> ;
3435
mf:include <not-001.ttl> ;
3536
mf:include <not-002.ttl> ;
3637
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)