Skip to content

Issue 414: list constraints #416

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 19 commits into
base: feat/memberShape
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
649 changes: 459 additions & 190 deletions shacl12-core/index.html

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions shacl12-test-suite/tests/core/node/manifest.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
mf:include <maxExclusive-001.ttl> ;
mf:include <maxInclusive-001.ttl> ;
mf:include <maxLength-001.ttl> ;
mf:include <maxListLength-001.ttl> ;
mf:include <memberShape-001.ttl> ;
mf:include <minExclusive-001.ttl> ;
mf:include <minInclusive-001.ttl> ;
mf:include <minInclusive-002.ttl> ;
mf:include <minInclusive-003.ttl> ;
mf:include <minLength-001.ttl> ;
mf:include <minListLength-001.ttl> ;
mf:include <node-001.ttl> ;
mf:include <nodeKind-001.ttl> ;
mf:include <not-001.ttl> ;
Expand All @@ -41,6 +43,7 @@
mf:include <pattern-002.ttl> ;
mf:include <reifierShape-001.ttl> ;
mf:include <reifierShape-002.ttl> ;
mf:include <uniqueMembers-001.ttl> ;
mf:include <xone-001.ttl> ;
mf:include <xone-duplicate.ttl> ;
mf:include <qualified-001.ttl> ;
Expand Down
63 changes: 63 additions & 0 deletions shacl12-test-suite/tests/core/node/maxListLength-001.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://datashapes.org/sh/tests/core/node/maxListLength-001.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:ListShape
rdf:type sh:NodeShape ;
sh:maxListLength 2 ;
# Satisfies all constraints
sh:targetNode ex:list0, rdf:nil ;
# Violates maxListLength constraint
sh:targetNode ex:list1, ex:notAList ;
.

ex:list0
rdf:first 1 ;
rdf:rest ( 2 ) .

ex:list1
rdf:first 1 ;
rdf:rest ( 2 3 ) .

<>
rdf:type mf:Manifest ;
mf:entries (
<maxListLength-001>
) ;
.

<maxListLength-001>
rdf:type sht:Validate ;
rdfs:label "Test of sh:maxListLength on node shape 001" ;
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:list1 ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MaxListLengthConstraintComponent ;
sh:sourceShape ex:ListShape ;
sh:value ex:list1 ;
] ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode ex:notAList ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MaxListLengthConstraintComponent ;
sh:sourceShape ex:ListShape ;
sh:value ex:notAList ;
] ;
] ;
mf:status sht:approved ;
.
141 changes: 36 additions & 105 deletions shacl12-test-suite/tests/core/node/memberShape-001.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,64 @@ ex:IRIShape a sh:NodeShape ;
ex:IRIListShape
rdf:type sh:NodeShape ;
sh:memberShape ex:IRIShape ;
sh:targetNode ( ex:Alice ex:Bob ) ;
sh:targetNode ex:list0 ;
# Valid empty list
sh:targetNode () ;
# _:b1 is valid, the remainder trigger violations (including _:b3 which has no properties in this graph)
sh:targetNode _:b1, _:b2, _:b3, _:b4, _:b5, _:b6, _:b7, _:b9 ;
sh:targetNode rdf:nil ;
# ex:list1 is valid, the remainder trigger violations (including ex:list3 which has no properties in this graph)
sh:targetNode ex:list1, ex:list2, ex:list3, ex:list4, ex:list5, ex:list6, ex:list7, ex:list9 ;
.

_:b1
ex:list0
rdf:first ex:Alice ;
rdf:rest (
ex:Bob
) ;
.

ex:list1
rdf:first ex:Alice ;
rdf:rest rdf:nil ;
ex:extraProperty "extra" ;
.

_:b2
ex:list2
rdf:first ex:Alice ;
rdf:rest (
"Bob"
)
.

_:b4
ex:list4
rdf:first ex:Alice ;
.

_:b5
ex:list5
rdf:first "Charlie" ;
rdf:rest (
"Donna"
)
.

_:b6
ex:list6
rdf:first "Charlie" ;
.

_:b8 rdfs:label "Malformed SHACL List" .
ex:list8 rdfs:label "Malformed SHACL List" .

_:b7
ex:list7
rdf:first "Charlie" ;
rdf:rest _:b8 ;
rdf:rest ex:list8 ;
.

# using _:b9 and _:b10 to test recursive list error
_:b9
# using ex:list9 and ex:list10 to test recursive list error
ex:list9
rdf:first ex:Alice ;
rdf:rest _:b10 ;
rdf:rest ex:list10 ;
.

_:b10
ex:list10
rdf:first "Bob" ;
rdf:rest _:b9 .
rdf:rest ex:list9 .

<>
rdf:type mf:Manifest ;
Expand All @@ -85,15 +92,13 @@ _:b10
sh:conforms "false"^^xsd:boolean ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode _:b2 ;
sh:resultMessage "Value does not conform to Shape ex:IRIListShape. See details for more information." ;
sh:focusNode ex:list2 ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
sh:sourceShape ex:IRIListShape ;
sh:detail [
rdf:type sh:ValidationResult ;
sh:focusNode "Bob" ;
sh:resultMessage "Value is not of Node Kind sh:IRI" ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:NodeKindConstraintComponent ;
sh:sourceShape ex:IRIShape ;
Expand All @@ -102,59 +107,36 @@ _:b10
] ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode _:b3 ;
sh:resultMessage "Value is a malformed SHACL List." ;
sh:focusNode ex:list3 ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
sh:sourceShape ex:IRIListShape ;
sh:value _:b3 ;
sh:detail [
rdf:type sh:ValidationResult ;
sh:focusNode _:b3 ;
sh:resultMessage "Value is a malformed SHACL List. _:b3 is missing rdf:first and rdf:rest properties." ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
sh:sourceShape ex:IRIListShape ;
sh:value _:b3 ;
] ;
sh:value ex:list3 ;
] ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode _:b4 ;
sh:resultMessage "Value does not conform to Shape ex:IRIListShape. See details for more information." ;
sh:focusNode ex:list4 ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
sh:sourceShape ex:IRIListShape ;
sh:value _:b4 ;
sh:detail [
rdf:type sh:ValidationResult ;
sh:focusNode _:b4 ;
sh:resultMessage "Value is a malformed SHACL List. _:b4 is missing rdf:rest property." ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
sh:sourceShape ex:IRIListShape ;
sh:value _:b4 ;
] ;
sh:value ex:list4 ;
] ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode _:b5 ;
sh:resultMessage "Value does not conform to Shape ex:IRIListShape. See details for more information." ;
sh:focusNode ex:list5 ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
sh:sourceShape ex:IRIListShape ;
sh:detail [
rdf:type sh:ValidationResult ;
sh:focusNode "Charlie" ;
sh:resultMessage "Value is not of Node Kind sh:IRI" ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:NodeKindConstraintComponent ;
sh:sourceShape ex:IRIShape ;
sh:value "Charlie" ;
], [
rdf:type sh:ValidationResult ;
sh:focusNode "Donna" ;
sh:resultMessage "Value is not of Node Kind sh:IRI" ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:NodeKindConstraintComponent ;
sh:sourceShape ex:IRIShape ;
Expand All @@ -163,78 +145,27 @@ _:b10
] ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode _:b6 ;
sh:resultMessage "Value does not conform to Shape ex:IRIListShape. See details for more information." ;
sh:focusNode ex:list6 ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
sh:sourceShape ex:IRIListShape ;
sh:detail [
rdf:type sh:ValidationResult ;
sh:focusNode "Charlie" ;
sh:resultMessage "Value is not of Node Kind sh:IRI" ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:NodeKindConstraintComponent ;
sh:sourceShape ex:IRIShape ;
sh:value "Charlie" ;
], [
rdf:type sh:ValidationResult ;
sh:focusNode _:b6 ;
sh:resultMessage "Value is a malformed SHACL List. _:b6 is missing rdf:rest property." ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
sh:sourceShape ex:IRIListShape ;
sh:value _:b6 ;
] ;
sh:value ex:list6 ;
] ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode _:b7 ;
sh:resultMessage "Value does not conform to Shape ex:IRIListShape. See details for more information." ;
sh:focusNode ex:list7 ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
sh:sourceShape ex:IRIListShape ;
sh:detail [
rdf:type sh:ValidationResult ;
sh:focusNode "Charlie" ;
sh:resultMessage "Value is not of Node Kind sh:IRI" ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:NodeKindConstraintComponent ;
sh:sourceShape ex:IRIShape ;
sh:value "Charlie" ;
], [
rdf:type sh:ValidationResult ;
sh:focusNode _:b8 ;
sh:resultMessage "Value is a malformed SHACL List. _:b8 is missing rdf:first and rdf:rest property." ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
sh:sourceShape ex:IRIListShape ;
sh:value _:b8 ;
] ;
sh:value ex:list8 ;
] ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode _:b9 ;
sh:resultMessage "Value does not conform to Shape ex:IRIListShape. See details for more information." ;
sh:focusNode ex:list9 ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
sh:sourceShape ex:IRIListShape ;
sh:detail [
rdf:type sh:ValidationResult ;
sh:focusNode "Charlie" ;
sh:resultMessage "Value is not of Node Kind sh:IRI" ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:NodeKindConstraintComponent ;
sh:sourceShape ex:IRIShape ;
sh:value "Charlie" ;
], [
rdf:type sh:ValidationResult ;
sh:focusNode _:b10 ;
sh:resultMessage "Value is a malformed SHACL List. A list cannot have itself in the rdf:rest+ path. List _:b9 follows from _:b10." ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
sh:sourceShape ex:IRIListShape ;
sh:value _:b9 ;
] ;
sh:value ex:list10 ;
] ;
] ;
mf:status sht:approved ;
Expand Down
58 changes: 58 additions & 0 deletions shacl12-test-suite/tests/core/node/minListLength-001.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://datashapes.org/sh/tests/core/node/minListLength-001.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:ListShape
rdf:type sh:NodeShape ;
sh:minListLength 1 ;
# Satisfies all constraints
sh:targetNode ex:list0 ;
# Violates minListLength constraint
sh:targetNode rdf:nil, ex:notAList ;
.

ex:list0
rdf:first 1 ;
rdf:rest ( 2 ) .

<>
rdf:type mf:Manifest ;
mf:entries (
<minListLength-001>
) ;
.

<minListLength-001>
rdf:type sht:Validate ;
rdfs:label "Test of sh:minListLength on node shape 001" ;
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 rdf:nil ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MinListLengthConstraintComponent ;
sh:sourceShape ex:ListShape ;
] ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode ex:notAList ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MinListLengthConstraintComponent ;
sh:sourceShape ex:ListShape ;
sh:value ex:notAList ;
] ;
] ;
mf:status sht:approved ;
.
Loading