Skip to content

Commit

Permalink
New version of system vocab and ref document for recursion propagatio…
Browse files Browse the repository at this point in the history
…n based on "undefined". Added/updated tests for these changes.
  • Loading branch information
HolgerKnublauch committed Jun 17, 2015
1 parent d7dbe19 commit dbe442a
Show file tree
Hide file tree
Showing 7 changed files with 459 additions and 77 deletions.
59 changes: 59 additions & 0 deletions data-shapes-test-suite/tests/features/core/and-003.ttl
@@ -0,0 +1,59 @@
# baseURI: http://www.w3.org/ns/shacl/test/features/core/and-003

@prefix ex: <http://example.org/> .
@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 xsd: <http://www.w3.org/2001/XMLSchema#> .

<>
a sh:Graph ;
sh:shapesGraph <http://www.w3.org/ns/shacl> ;
.


# Shape Definitions -----------------------------------------------------------

ex:RecursiveShape
a sh:Shape ;
sh:property [
sh:predicate ex:property2 ;
sh:valueShape ex:RecursiveShape ;
] ;
.

ex:AndShape
a sh:Shape ;
sh:constraint [
a sh:AndConstraint ;
sh:shapes (
[
sh:property [
sh:predicate ex:property1 ;
sh:maxCount 1 ;
]
]
ex:RecursiveShape
)
] ;
.

# Instances -------------------------------------------------------------------

ex:ValidInstance1
sh:nodeShape ex:AndShape ;
ex:property1 "One" ;
.

# Invalid: Infinite loop
ex:InvalidInstance1
sh:nodeShape ex:AndShape ;
ex:property2 ex:InvalidInstance1 ;
.

# Invalid: more than one property1
ex:InvalidInstance2
sh:nodeShape ex:AndShape ;
ex:property1 "One" ;
ex:property1 "Two" ;
.
61 changes: 61 additions & 0 deletions data-shapes-test-suite/tests/features/core/manifest.ttl
Expand Up @@ -22,6 +22,8 @@
<or-001>
<property-001>
<recursive-001>
<recursive-002>
<recursive-003>
<scopeShape-001>
<valueShape-001>
<xor-001>
Expand Down Expand Up @@ -81,6 +83,24 @@
mf:status sht:proposed ;
.

<and-003>
a sht:Validate ;
mf:name "Test of a sh:AndConstraint" ;
mf:action [
sht:schema <and-003.ttl> ;
sht:data <and-003.ttl> ;
] ;
mf:result [
a sh:FatalError ;
sh:root ex:InvalidInstance1 ;
] ;
mf:result [
a sh:Error ;
sh:root ex:InvalidInstance2 ;
] ;
mf:status sht:proposed ;
.

<class-001>
a sht:Validate ;
mf:name "Test of a sh:ShapeClass definition" ;
Expand Down Expand Up @@ -210,6 +230,13 @@
sht:schema <recursive-001.ttl> ;
sht:data <recursive-001.ttl> ;
] ;
mf:result [
a sh:FatalError ;
sh:root ex:Diego ;
sh:subject ex:Diego ;
sh:predicate ex:knows ;
sh:object ex:Alessandro ;
] ;
mf:result [
a sh:Error ;
sh:root ex:Enrico ;
Expand All @@ -220,6 +247,40 @@
mf:status sht:proposed ;
.

<recursive-002>
a sht:Validate ;
mf:name "Test of a sh:valueShape with recursion" ;
mf:action [
sht:schema <recursive-002.ttl> ;
sht:data <recursive-002.ttl> ;
] ;
mf:result [
a sh:FatalError ;
sh:root ex:Instance ;
sh:subject ex:Instance ;
sh:predicate ex:property ;
sh:object ex:Instance ;
] ;
mf:status sht:proposed ;
.

<recursive-003>
a sht:Validate ;
mf:name "Test of a sh:valueShape with recursion" ;
mf:action [
sht:schema <recursive-003.ttl> ;
sht:data <recursive-003.ttl> ;
] ;
mf:result [
a sh:FatalError ;
sh:root ex:Instance1 ;
sh:subject ex:Instance1 ;
sh:predicate ex:someProperty ;
sh:object ex:Instance2 ;
] ;
mf:status sht:proposed ;
.

<scopeShape-001>
a sht:Validate ;
mf:name "Test of a sh:scopeShape" ;
Expand Down
Expand Up @@ -65,5 +65,5 @@ ex:Diego ex:knows ex:Alessandro .
ex:Enrico ex:knows ex:John .
ex:John ex:knows ex:Maurizio .

ex:Diego sh:nodeShape ex:Polentoni . # Correct
ex:Diego sh:nodeShape ex:Polentoni . # Undefined due to infinite loop (Diego -> Alessandro -> Diego)
ex:Enrico sh:nodeShape ex:Polentoni . # Incorrect (Enrico -> John -> Maurizio)
28 changes: 28 additions & 0 deletions data-shapes-test-suite/tests/features/core/recursive-002.ttl
@@ -0,0 +1,28 @@
# baseURI: http://www.w3.org/ns/shacl/test/features/core/recursive-002

@prefix ex: <http://example.org/> .
@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 xsd: <http://www.w3.org/2001/XMLSchema#> .

<>
a sh:Graph ;
sh:shapesGraph <http://www.w3.org/ns/shacl> ;
.

# Shapes ----------------------------------------------------------------------

ex:MyShape
a sh:Shape ;
sh:property [
sh:predicate ex:property ;
sh:valueShape ex:MyShape ;
] ;
.

# Instances -------------------------------------------------------------------

ex:Instance
sh:nodeShape ex:MyShape ;
ex:property ex:Instance .
84 changes: 84 additions & 0 deletions data-shapes-test-suite/tests/features/core/recursive-003.ttl
@@ -0,0 +1,84 @@
# baseURI: http://www.w3.org/ns/shacl/test/features/core/recursive-003

@prefix ex: <http://example.org/> .
@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 xsd: <http://www.w3.org/2001/XMLSchema#> .

<>
a sh:Graph ;
sh:shapesGraph <http://www.w3.org/ns/shacl> ;
rdfs:comment "Based on an example suggested by Simon in https://lists.w3.org/Archives/Public/public-data-shapes-wg/2015Jun/0083.html" ;
.

# Shapes ----------------------------------------------------------------------

ex:recursionShapeExample
a sh:Shape ;
sh:property [
sh:predicate ex:someProperty ;
sh:valueShape ex:hasAShape ;
] .

ex:hasAShape
a sh:Shape ;
sh:constraint [
a sh:AndConstraint ;
sh:shapes (ex:ValueTypeAShape ex:notBShape)
] .

ex:hasBShape
a sh:Shape ;
sh:constraint [
a sh:AndConstraint ;
sh:shapes (ex:ValueTypeBShape ex:notAShape)
] .

ex:notAShape
a sh:Shape ;
sh:constraint [
a sh:NotConstraint ;
sh:shape ex:hasAShape ;
] .

ex:notBShape
a sh:Shape ;
sh:constraint [
a sh:NotConstraint ;
sh:shape ex:hasBShape;
] .

ex:ValueTypeAShape
a sh:Shape ;
sh:property [
sh:predicate ex:property ;
sh:valueType ex:ClassA ;
] .

ex:ValueTypeBShape
a sh:Shape ;
sh:property [
sh:predicate ex:property ;
sh:valueType ex:ClassB ;
] .


# Instances -------------------------------------------------------------------

ex:InstanceOfA
a ex:ClassA ;
.

ex:InstanceOfB
a ex:ClassB ;
.

ex:Instance1
sh:nodeShape ex:recursionShapeExample ;
ex:someProperty ex:Instance2 ;
.

ex:Instance2
ex:property ex:InstanceOfA ;
.

0 comments on commit dbe442a

Please sign in to comment.