Skip to content

#429: Have SHACL-SHACL warn about unsatisfiable usage of sh:in and sh:xone #451

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

Open
wants to merge 1 commit 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
2 changes: 2 additions & 0 deletions shacl12-core/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5899,6 +5899,7 @@ <h4>sh:xone</h4>
A <a>SHACL list</a> of shapes to validate the value nodes against.
<span data-syntax-rule="xone-node">Each value of <code>sh:xone</code> in a shape is a <a>SHACL list</a>.</span>
<span data-syntax-rule="xone-members-node">Each <a>member</a> of such list must be a <a>well-formed</a> <a>shape</a>.</span>
<span data-syntax-rule="xone-minListLength">There should be at least one <a>member</a> of such list.</span>
</td>
</tr>
</tbody></table>
Expand Down Expand Up @@ -7299,6 +7300,7 @@ <h4>sh:in</h4>
A <a>SHACL list</a> that has the allowed values as <a>members</a>.
<span data-syntax-rule="in-node">Each value of <code>sh:in</code> in a shape is a <a>SHACL list</a>.</span>
<span data-syntax-rule="in-maxCount">A shape has at most one value for <code>sh:in</code>.</span>
<span data-syntax-rule="in-minListLength">There should be at least one <a>member</a> of such list.</span>
</td>
</tr>
</tbody></table>
Expand Down
46 changes: 46 additions & 0 deletions shacl12-test-suite/tests/core/node/in-002.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@prefix ex: <http://example.com/ns#> .
@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:Instance
rdf:type ex:TestShape ;
.
ex:TestInUnsatisfiableShape
rdf:type rdfs:Class ;
rdf:type sh:NodeShape ;
rdfs:comment "Unsatisfiable due to empty sh:in list. SHACL-SHACL would raise a warning about the empty list."@en ;
rdfs:label "Test shape" ;
sh:in () ;
.
<>
rdf:type mf:Manifest ;
mf:entries (
<in-002>
) ;
.
<in-002>
rdf:type sht:Validate ;
rdfs:label "Test of sh:in at node shape 002" ;
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:Instance ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:InConstraintComponent ;
sh:sourceShape ex:TestShape ;
sh:value ex:Instance ;
] ;
] ;
mf:status sht:approved ;
.
55 changes: 55 additions & 0 deletions shacl12-test-suite/tests/core/node/in-003.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@prefix ex: <http://example.com/ns#> .
@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:TestInUnsatisfiableShape
rdf:type rdfs:Class ;
rdf:type sh:NodeShape ;
rdfs:label "Test shape" ;
sh:in rdf:nil ;
.
shsh:inSubjectsShape
a sh:NodeShape ;
rdfs:isDefinedBy shsh: ;
sh:property shsh:inSubjectsShapeXonePropertyShape ;
sh:targetSubjectsOf sh:in ;
.
shsh:inSubjectsShapeInPropertyShape
a sh:PropertyShape ;
rdfs:isDefinedBy shsh: ;
sh:path sh:in ;
sh:minListLength 1 ;
sh:severity sh:Warning ;
.
<>
rdf:type mf:Manifest ;
mf:entries (
<in-003>
) ;
.
<in-003>
rdf:type sht:Validate ;
rdfs:label "Test of sh:in at node shape 003" ;
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:TestInUnsatisfiableShape ;
sh:resultSeverity sh:Warning ;
sh:sourceConstraintComponent sh:MinListLengthConstraintComponent ;
sh:sourceShape shsh:inSubjectsShapeInPropertyShape ;
sh:value rdf:nil ;
] ;
] ;
mf:status sht:approved ;
.
45 changes: 45 additions & 0 deletions shacl12-test-suite/tests/core/node/xone-002.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@prefix ex: <http://example.com/ns#> .
@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:Bob
rdf:type ex:Person ;
.
ex:TestXoneUnsatisfiableShape
rdf:type sh:NodeShape ;
rdfs:comment "Unsatisfiable due to empty sh:xone list. SHACL-SHACL would raise a warning about the empty list."@en ;
sh:targetClass ex:Person ;
sh:xone () ;
.
<>
rdf:type mf:Manifest ;
mf:entries (
<xone-002>
) ;
.
<xone-002>
rdf:type sht:Validate ;
rdfs:label "Test of sh:xone at node shape 002" ;
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:Bob ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:XoneConstraintComponent ;
sh:sourceShape ex:TestXoneUnsatisfiableShape ;
sh:value ex:Bob ;
] ;
] ;
mf:status sht:approved ;
.
55 changes: 55 additions & 0 deletions shacl12-test-suite/tests/core/node/xone-003.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@prefix ex: <http://example.com/ns#> .
@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 shsh: <http://www.w3.org/ns/shacl-shacl#> .
@prefix sht: <http://www.w3.org/ns/shacl-test#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:TestXoneUnsatisfiableShape
rdf:type sh:NodeShape ;
sh:targetClass ex:Person ;
sh:xone rdf:nil ;
.
shsh:xoneSubjectsShape
a sh:NodeShape ;
rdfs:isDefinedBy shsh: ;
sh:property shsh:xoneSubjectsShapeXonePropertyShape ;
sh:targetSubjectsOf sh:xone ;
.
shsh:xoneSubjectsShapeXonePropertyShape
a sh:PropertyShape ;
rdfs:isDefinedBy shsh: ;
sh:path sh:xone ;
sh:minListLength 1 ;
sh:severity sh:Warning ;
.
<>
rdf:type mf:Manifest ;
mf:entries (
<xone-003>
) ;
.
<xone-003>
rdf:type sht:Validate ;
rdfs:label "Test of sh:xone at node shape 003" ;
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:TestXoneUnsatisfiableShape ;
sh:resultSeverity sh:Warning ;
sh:sourceConstraintComponent sh:MinListLengthConstraintComponent ;
sh:sourceShape shsh:xoneSubjectsShapeXonePropertyShape ;
sh:value rdf:nil ;
] ;
] ;
mf:status sht:approved ;
.
32 changes: 30 additions & 2 deletions shacl12-vocabularies/shacl-shacl.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ shsh:ShapeShape
sh:property [
sh:path sh:in ;
sh:maxCount 1 ; # in-maxCount
sh:minListLength 1 ; # in-minListLength
] ;
sh:property [
sh:path sh:languageIn ;
Expand Down Expand Up @@ -294,7 +293,7 @@ shsh:ShapeShape
] ;
sh:property [
sh:path sh:xone ;
sh:memberShape shsh:ShapeShape ; # xone-memberShape
sh:memberShape shsh:ShapeShape ; # xone-members-node
] .

shsh:NodeShapeShape
Expand Down Expand Up @@ -347,6 +346,35 @@ shsh:ShapesListShape
sh:targetObjectsOf sh:xone ; # xone-members-node
sh:memberShape shsh:ShapeShape .

# Values of sh:in and sh:xone should have length >= 1.
shsh:inSubjectsShape
a sh:NodeShape ;
rdfs:comment "A shape that raises warnings on unsatisfiable lists. If some use case requires a length-0 list on 'sh:in', this graph should be supplemented with 'shsh:inSubjectsShape sh:deactivated true .'."@en ;
sh:property shsh:inSubjectsShapeInPropertyShape ;
sh:targetSubjectsOf sh:in ;
.

shsh:inSubjectsShapeInPropertyShape
a sh:PropertyShape ;
sh:path sh:in ;
sh:minListLength 1 ; # in-minListLength
sh:severity sh:Warning ;
.

shsh:xoneSubjectsShape
a sh:NodeShape ;
rdfs:comment "A shape that raises warnings on unsatisfiable lists. If some use case requires a length-0 list on 'sh:xone', this graph should be supplemented with 'shsh:xoneSubjectsShape sh:deactivated true .'."@en ;
sh:property shsh:xoneSubjectsShapeXonePropertyShape ;
sh:targetSubjectsOf sh:xone ;
.

shsh:xoneSubjectsShapeXonePropertyShape
a sh:PropertyShape ;
sh:path sh:xone ;
sh:minListLength 1 ; # xone-minListLength
sh:severity sh:Warning ;
.

# A path of blank node path syntax, used to simulate recursion
_:PathPath
sh:alternativePath (
Expand Down