Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#212: Added sh:ShapeClass #254

Open
wants to merge 7 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions shacl12-core/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ <h4>Class-based Targets (sh:targetClass)</h4>
</section>

<section id="implicit-targetClass">
<h4>Implicit Class Targets</h4>
<h4>Implicit Class Targets and sh:ShapeClass</h4>
<p>
Informally, if a <a>shape</a> is also declared to be a <a>class</a> in the <a>shapes graph</a> then
all <a>SHACL instances</a> of this class are a target for the shape.
Expand All @@ -1241,6 +1241,15 @@ <h4>Implicit Class Targets</h4>
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>
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>.
</div>
<p id="ShapeClass">
The SHACL namespace includes a dedicated class <code>sh:ShapeClass</code> that can serve as a syntactic shortcut for the implicit class targets pattern.
</p>
<div class="def">
<div class="def-header">TEXTUAL DEFINITION</div>
The class <code>sh:ShapeClass</code> is an <code>rdfs:subClassOf</code> of both <code>sh:NodeShape</code> and <code>rdfs:Class</code>.
If <code>s</code> is a <a>SHACL instance</a> of <code>sh:ShapeClass</code> in a <a>shapes graph</a> <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>.
</div>
<p><em>The remainder of this section is informative.</em></p>
<p>
In the following example, <code>ex:Alice</code> is a focus node, because it is a <a>SHACL instance</a> of
Expand All @@ -1260,6 +1269,18 @@ <h4>Implicit Class Targets</h4>
</div>
</div>
</aside>
<p>
In the following variation of the example above, <code>ex:Person</code> is declared as an instance of <code>sh:ShapeClass</code>,
with the same interpretation.
</p>
<aside class="example">
<div class="shapes-graph">
<div class="turtle">
ex:Person
<b>a sh:ShapeClass</b> .</pre>
</div>
</div>
</aside>
</section>

<section id="targetSubjectsOf">
Expand Down Expand Up @@ -4788,7 +4809,7 @@ <h2>Acknowledgements</h2>
<section class="appendix informative">
<h2>Revision History</h2>
<p>
The detailed list of changes and their diffs can be found in the Git repository.
The detailed list of changes and their diffs can be found in the <a href="https://github.com/w3c/data-shapes">Git repository</a>.
</p>
<ul>
<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>
Expand All @@ -4799,8 +4820,9 @@ <h2>Revision History</h2>
<h2>Changes between SHACL 1.0 Core and SHACL 1.2 Core</h2>
<ul>
<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>
<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>
</ul>
</section>
</section>
</body>

<script type="text/javascript">
Expand Down
1 change: 1 addition & 0 deletions shacl12-test-suite/tests/core/targets/manifest.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
mf:include <multipleTargets-001.ttl> ;
mf:include <targetClass-001.ttl> ;
mf:include <targetClassImplicit-001.ttl> ;
mf:include <targetClassImplicit-002.ttl> ;
mf:include <targetNode-001.ttl> ;
mf:include <targetObjectsOf-001.ttl> ;
mf:include <targetSubjectsOf-001.ttl> ;
Expand Down
57 changes: 57 additions & 0 deletions shacl12-test-suite/tests/core/targets/targetClassImplicit-002.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://datashapes.org/sh/tests/core/targets/targetClassImplicit-002.test#> .
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix sht: <http://www.w3.org/ns/shacl-test#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:InvalidInstance
rdf:type ex:SubClass ;
rdfs:label "Invalid instance" ;
.
ex:SubClass
rdf:type rdfs:Class ;
rdfs:label "Sub class" ;
rdfs:subClassOf ex:SuperClass ;
.
ex:SuperClass
a sh:ShapeClass ;
rdfs:label "Super class" ;
sh:in (
ex:ValidInstance
) ;
.
ex:ValidInstance
rdf:type ex:SubClass ;
rdfs:label "Valid instance" ;
.
<>
rdf:type mf:Manifest ;
mf:entries (
<targetClassImplicit-002>
) ;
.
<targetClassImplicit-002>
rdf:type sht:Validate ;
rdfs:label "Verify that sh:ShapeClass is interpreted as implicit class target" ;
mf:action [
sht:dataGraph <> ;
sht:shapesGraph <> ;
] ;
mf:result [
rdf:type sh:ValidationReport ;
sh:conforms "false"^^xsd:boolean ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode ex:InvalidInstance ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:InConstraintComponent ;
sh:sourceShape ex:SuperClass ;
sh:value ex:InvalidInstance ;
] ;
] ;
mf:status sht:approved ;
.
8 changes: 8 additions & 0 deletions shacl12-vocabularies/shacl.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ sh:PropertyShape
rdfs:subClassOf sh:Shape ;
rdfs:isDefinedBy sh: .

sh:ShapeClass
a rdfs:Class ;
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 ;
rdfs:label "Shape class"@en ;
rdfs:subClassOf rdfs:Class ;
rdfs:subClassOf sh:NodeShape ;
rdfs:isDefinedBy sh: .

sh:deactivated
a rdf:Property ;
rdfs:label "deactivated"@en ;
Expand Down