Skip to content

Commit 5224879

Browse files
#212: Added sh:ShapeClass
1 parent 8fb9f59 commit 5224879

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

shacl12-core/index.html

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,16 @@ <h4>Implicit Class Targets</h4>
11571157
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>
11581158
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>.
11591159
</div>
1160+
<p id="ShapeClass">
1161+
The SHACL namespace includes a dedicated metaclass <code>sh:ShapeClass</code> that can serve as a syntactic shortcut for the implicit class targets pattern.
1162+
</p>
1163+
<div class="def">
1164+
<div class="def-header">TEXTUAL DEFINITION</div>
1165+
The class <code>sh:ShapeClass</code> is an <code>rdfs:subClassOf</code> of both <code>sh:NodeShape</code> and <code>rdfs:Class</code>.
1166+
<code>sh:ShapeClass</code> has itself as its <code>rdf:type</code>.
1167+
If <code>s</code> is a <a>SHACL instance</a> of <code>sh:ShapeClass</code> in a <a>shapes graph</a> <code>SG</code>
1168+
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>.
1169+
</div>
11601170
<p><em>The remainder of this section is informative.</em></p>
11611171
<p>
11621172
In the following example, <code>ex:Alice</code> is a focus node, because it is a <a>SHACL instance</a> of
@@ -1168,6 +1178,13 @@ <h4>Implicit Class Targets</h4>
11681178
<pre class="example-data">
11691179
<span class="focus-node-selected">ex:Alice</span> a ex:Person .
11701180
ex:NewYork a ex:Place .</pre>
1181+
<p>
1182+
In the following variation of the example above, <code>ex:Person</code> is declared as an instance of <code>sh:ShapeClass</code>,
1183+
with the same interpretation.
1184+
</p>
1185+
<pre class="example-shapes">
1186+
ex:Person
1187+
<b>a sh:ShapeClass</b> .</pre>
11711188
</section>
11721189

11731190
<section id="targetSubjectsOf">
@@ -4474,12 +4491,19 @@ <h2>Acknowledgements</h2>
44744491
<section class="appendix informative">
44754492
<h2>Revision History</h2>
44764493
<p>
4477-
The detailed list of changes and their diffs can be found in the Git repository.
4494+
The detailed list of changes and their diffs can be found in the <a href="https://github.com/w3c/data-shapes">Git repository</a>.
44784495
</p>
44794496
<ul>
44804497
<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>
44814498
</ul>
44824499
</section>
4500+
4501+
<section class="appendix informative" id="changes-12">
4502+
<h2>Changes between SHACL 1.0 Core and SHACL 1.2 Core</h2>
4503+
<ul>
4504+
<li>Added the new metaclass <a href="#ShapeClass"><code>sh:ShapeClass</code></a> as syntactic sugar for implicit class targets, see <a href="https://github.com/w3c/data-shapes/issues/212">Issue 212</a></li>
4505+
</ul>
4506+
</section>
44834507

44844508
</body>
44854509

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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ sh:PropertyShape
5454
rdfs:subClassOf sh:Shape ;
5555
rdfs:isDefinedBy sh: .
5656

57+
sh:ShapeClass
58+
a sh:ShapeClass ;
59+
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 ;
60+
rdfs:label "Shape class"@en ;
61+
rdfs:subClassOf rdfs:Class ;
62+
rdfs:subClassOf sh:NodeShape .
63+
5764
sh:deactivated
5865
a rdf:Property ;
5966
rdfs:label "deactivated"@en ;

0 commit comments

Comments
 (0)