Skip to content

Commit 9272a74

Browse files
Merge pull request #254 from w3c/issue-212-ShapeClass
#212: Added sh:ShapeClass
2 parents a62647f + e4dd040 commit 9272a74

File tree

4 files changed

+95
-3
lines changed

4 files changed

+95
-3
lines changed

shacl12-core/index.html

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ <h4>Class-based Targets (sh:targetClass)</h4>
11221122
</section>
11231123

11241124
<section id="implicit-targetClass">
1125-
<h4>Implicit Class Targets</h4>
1125+
<h4>Implicit Class Targets and sh:ShapeClass</h4>
11261126
<p>
11271127
Informally, if a <a>shape</a> is also declared to be a <a>class</a> in the <a>shapes graph</a> then
11281128
all <a>SHACL instances</a> of this class are a target for the shape.
@@ -1138,6 +1138,19 @@ <h4>Implicit Class Targets</h4>
11381138
in a <a>shapes graph</a> <code>SG</code> and <code>s</code> is also a <a>SHACL instance</a> of <code>rdfs:Class</code>
11391139
in <code>SG</code> then the set of <a>SHACL instances</a> of <code>s</code> in a data graph <code>DG</code> is a <a>target</a> from <code>DG</code> for <code>s</code> in <code>SG</code>.
11401140
</div>
1141+
<p id="ShapeClass">
1142+
The SHACL namespace includes a dedicated class <code>sh:ShapeClass</code> that can serve as a syntactic shortcut for the implicit class targets pattern.
1143+
</p>
1144+
<div class="def">
1145+
<div class="def-header">TEXTUAL DEFINITION</div>
1146+
The class <code>sh:ShapeClass</code> is an <code>rdfs:subClassOf</code> of both <code>sh:NodeShape</code> and <code>rdfs:Class</code>.
1147+
If <code>s</code> is a <a>SHACL instance</a> of <code>sh:ShapeClass</code> in a <a>shapes graph</a> <code>SG</code>
1148+
then the set of <a>SHACL instances</a> of <code>s</code> in a data graph <code>DG</code> is a <a>target</a> from <code>DG</code> for <code>s</code> in <code>SG</code>.
1149+
</div>
1150+
<p>
1151+
Please keep in mind that <code>sh:ShapeClass</code> may not be understood to be a subclass of <code>rdfs:Class</code> by some SHACL-unaware implementations.
1152+
It is therefore recommended (but not required) that graphs that use <code>sh:ShapeClass</code> include an <code>owl:imports sh:</code> statement.
1153+
</p>
11411154
<p><em>The remainder of this section is informative.</em></p>
11421155
<p>
11431156
In the following example, <code>ex:Alice</code> is a focus node, because it is a <a>SHACL instance</a> of
@@ -1157,6 +1170,18 @@ <h4>Implicit Class Targets</h4>
11571170
</div>
11581171
</div>
11591172
</aside>
1173+
<p>
1174+
In the following variation of the example above, <code>ex:Person</code> is declared as an instance of <code>sh:ShapeClass</code>,
1175+
with the same interpretation.
1176+
</p>
1177+
<aside class="example">
1178+
<div class="shapes-graph">
1179+
<div class="turtle">
1180+
ex:Person
1181+
<b>a sh:ShapeClass</b> .</pre>
1182+
</div>
1183+
</div>
1184+
</aside>
11601185
</section>
11611186

11621187
<section id="targetSubjectsOf">
@@ -4305,7 +4330,7 @@ <h2>Acknowledgements</h2>
43054330
<section class="appendix informative">
43064331
<h2>Revision History</h2>
43074332
<p>
4308-
The detailed list of changes and their diffs can be found in the Git repository.
4333+
The detailed list of changes and their diffs can be found in the <a href="https://github.com/w3c/data-shapes">Git repository</a>.
43094334
</p>
43104335
<ul>
43114336
<li><b>2024-02-14</b>: New work started by cloning the main SHACL spec and splitting it into SHACL Core and SHACL-SPARQL</li>
@@ -4317,9 +4342,10 @@ <h2>Changes between SHACL 1.0 Core and SHACL 1.2 Core</h2>
43174342
<ul>
43184343
<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>
43194344
<li>Added the new constraint component <a href="#SingleLineConstraintComponent"><code>sh:singleLine</code></a>, see <a href="https://github.com/w3c/data-shapes/issues/177">Issue 177</a></li>
4345+
<li>Added the new class <a href="#ShapeClass"><code>sh:ShapeClass</code></a> for implicit class targets, see <a href="https://github.com/w3c/data-shapes/issues/212">Issue 212</a></li>
43204346
<li>Moved SPARQL-based validators from Core to an Appendix of SHACL-SPARQL, see <a href="https://github.com/w3c/data-shapes/issues/271">Issue 271</a></li>
43214347
</ul>
4322-
</section>
4348+
</section>
43234349
</body>
43244350

43254351
<script type="text/javascript">

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
mf:include <multipleTargets-001.ttl> ;
99
mf:include <targetClass-001.ttl> ;
1010
mf:include <targetClassImplicit-001.ttl> ;
11+
mf:include <targetClassImplicit-002.ttl> ;
1112
mf:include <targetNode-001.ttl> ;
1213
mf:include <targetObjectsOf-001.ttl> ;
1314
mf:include <targetSubjectsOf-001.ttl> ;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
@prefix dash: <http://datashapes.org/dash#> .
2+
@prefix ex: <http://datashapes.org/sh/tests/core/targets/targetClassImplicit-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:InvalidInstance
12+
rdf:type ex:SubClass ;
13+
rdfs:label "Invalid instance" ;
14+
.
15+
ex:SubClass
16+
rdf:type rdfs:Class ;
17+
rdfs:label "Sub class" ;
18+
rdfs:subClassOf ex:SuperClass ;
19+
.
20+
ex:SuperClass
21+
a sh:ShapeClass ;
22+
rdfs:label "Super class" ;
23+
sh:in (
24+
ex:ValidInstance
25+
) ;
26+
.
27+
ex:ValidInstance
28+
rdf:type ex:SubClass ;
29+
rdfs:label "Valid instance" ;
30+
.
31+
<>
32+
rdf:type mf:Manifest ;
33+
mf:entries (
34+
<targetClassImplicit-002>
35+
) ;
36+
.
37+
<targetClassImplicit-002>
38+
rdf:type sht:Validate ;
39+
rdfs:label "Verify that sh:ShapeClass is interpreted as implicit class target" ;
40+
mf:action [
41+
sht:dataGraph <> ;
42+
sht:shapesGraph <> ;
43+
] ;
44+
mf:result [
45+
rdf:type sh:ValidationReport ;
46+
sh:conforms "false"^^xsd:boolean ;
47+
sh:result [
48+
rdf:type sh:ValidationResult ;
49+
sh:focusNode ex:InvalidInstance ;
50+
sh:resultSeverity sh:Violation ;
51+
sh:sourceConstraintComponent sh:InConstraintComponent ;
52+
sh:sourceShape ex:SuperClass ;
53+
sh:value ex:InvalidInstance ;
54+
] ;
55+
] ;
56+
mf:status sht:approved ;
57+
.

shacl12-vocabularies/shacl.ttl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ sh:PropertyShape
5858
rdfs:subClassOf sh:Shape ;
5959
rdfs:isDefinedBy sh: .
6060

61+
sh:ShapeClass
62+
a rdfs:Class ;
63+
rdfs:comment "A shape class is a class that is also a node shape. sh:ShapeClass can be used as rdf:type instead of the combination of rdfs:Class and sh:NodeShape."@en ;
64+
rdfs:label "Shape class"@en ;
65+
rdfs:subClassOf rdfs:Class ;
66+
rdfs:subClassOf sh:NodeShape ;
67+
rdfs:isDefinedBy sh: .
68+
6169
sh:deactivated
6270
a rdf:Property ;
6371
rdfs:label "deactivated"@en ;

0 commit comments

Comments
 (0)