- From: Peter F. Patel-Schneider <pfpschneider@gmail.com>
- Date: Mon, 28 Dec 2015 08:56:48 -0800
- To: RDF Data Shapes Working Group <public-data-shapes-wg@w3.org>
Here are some test cases for SHACL validation, concentrating on datatypes and classes. I believe that all these match what is currently in the SHACL spec and what the majority of the members of the working group present desired when these aspects of SHACL were discussed. I can put these into approved test format if someone reminds me where the description of the test case format is. peter Note: add the following prefix directives to all @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix sh: <http://www.w3.org/ns/shacl#> . @prefix pp: <http://peoplepetsontology.example.com/> . @prefix ex: <http://data.example.com/> . Control Graph A/ [ rdf:type sh:Shape; sh:scopeClass pp:Person ; sh:property [ rdf:type sh:Constraint; sh:predicate pp:pet; sh:class pp:Pet; sh:minCount 1 ] ; sh:property [ rdf:type sh:Constraint; sh:predicate pp:name; sh:datatype xsd:string ] ; sh:property [ rdf:type sh:Constraint; sh:predicate pp:age; sh:datatype xsd:integer ] ; sh:property [ rdf:type sh:Constraint; sh:predicate pp:income; sh:datatype xsd:decimal ] ; sh:property [ rdf:type sh:Constraint; sh:predicate pp:p5; sh:datatype xsd:double ] ; sh:property [ rdf:type sh:Constraint; sh:predicate pp:p6; sh:datatype xsd:int ] ; sh:property [ rdf:type sh:Constraint; sh:predicate pp:p7; sh:datatype xsd:float ] ] . Valid Data Graphs in Turtle for A AP0/ nothing with type pp:Person so nothing to validate ex:mikey rdf:type pp:Dog . AP1/ all values explicitly correctly typed for ex:mikey ex:mikey rdf:type pp:Person ; pp:pet [ rdf:type pp:Pet ] ; pp:name "Mike"^^xsd:string ; pp:age "4"^^^xsd:integer ; pp:income "4.0"^^xsd:decimal ; pp:p5 "4.0E0"^^xsd:double ; pp:p6 "4"^^xsd:int ; pp:p7 "4.0E0"^^xsd:float . AP2/ correct implicit datatypes for ex:mikey ex:mikey rdf:type pp:Person ; pp:pet [ rdf:type pp:Pet ] ; pp:name "Mike" ; pp:age "4" ; pp:income "4.0" ; pp:p5 "4.0E0" ; pp:p6 "4"^^xsd:int ; pp:p7 "4.0E0"^^xsd:float . AP3/ value of pp:pet SHACL-inferred to be of type pp:Pet pp:PetDog rdfs:subClassOf pp:Pet . ex:mikey rdf:type pp:Person ; pp:pet [ rdf:type pp:PetDog ] ; pp:name "Mike"^^xsd:string ; pp:age "4"^^^xsd:integer ; pp:income "4.0"^^xsd:decimal ; pp:p5 "4.0E0"^^xsd:double ; pp:p6 "4"^^xsd:int ; pp:p7 "4.0E0"^^xsd:float . AP4/ nothing SHACL-inferred to be of type pp:Person pp:subClassOf rdfs:subPropertyOf rdfs:subClassOf . pp:Student pp:subClassOf pp:Person . ex:mikey rdf:type pp:Student . AP5/ nothing SHACL-inferred to be of type pp:Person pp:pet rdfs:domain pp:Person . ex:mikey rdf:type rdf:Resource ; pp:pet [ ] . Non-valid Data Graphs AN1/ rdf:langString is not xsd:string ex:mikey rdf:type pp:Person ; pp:pet [ rdf:type pp:Pet ] ; pp:name "Mike"@en ; pp:age "4" ; pp:income "4.0" ; pp:p5 "4.0E0" ; pp:p6 "4"^^xsd:int ; pp:p7 "4.0E0"^^xsd:float . AN2/ xsd:int is not xsd:integer ex:mikey rdf:type pp:Person ; pp:pet [ rdf:type pp:Pet ] ; pp:name "Mike" ; pp:age "4"^^xsd:int ; pp:income "4.0" ; pp:p5 "4.0E0" ; pp:p6 "4"^^xsd:int ; pp:p7 "4.0E0"^^xsd:float . AN3/ xsd:integer is not xsd:int ex:mikey rdf:type pp:Person ; pp:pet [ rdf:type pp:Pet ] ; pp:name "Mike" ; pp:age "4" ; pp:income "4.0" ; pp:p5 "4.0E0" ; pp:p6 "4" ; pp:p7 "4.0E0"^^xsd:float . AN4/ xsd:float is not xsd:double ex:mikey rdf:type pp:Person ; pp:pet [ rdf:type pp:Pet ] ; pp:name "Mike" ; pp:age "4" ; pp:income "4.0"^^xsd:float ; pp:p5 "4.0E0" ; pp:p6 "4"^^xsd:int ; AN5/ xsd:double is not xsd:float ex:mikey rdf:type pp:Person ; pp:pet [ rdf:type pp:Pet ] ; pp:name "Mike" ; pp:age "4" ; pp:income "4.0" ; pp:p5 "4.0E0" ; pp:p6 "4"^^xsd:int ; pp:p7 "4.0E0" . AN6/ xsd:decimal is not xsd:float ex:mikey rdf:type pp:Person ; pp:pet [ rdf:type pp:Pet ] ; pp:name "Mike" ; pp:age "4" ; pp:income "4.0" ; pp:p5 "4.0E0" ; pp:p6 "4"^^xsd:int ; pp:p7 "4.0" . AN7/ pp:pet value not SHACL-inferred to be of type c1 pp:subClassOf rdfs:subPropertyOf rdfs:subClassOf . pp:PetDog pp:subClassOf pp:Dog . ex:mikey rdf:type pp:Person ; pp:pet [ rdf:type pp:Student ] ; pp:name "Mike" ; pp:age "4" ; pp:income "4.0" ; pp:p5 "4.0E0" ; pp:p6 "4"^^xsd:int ; pp:p7 "4.0E0"^^xsd:float . AN8/ pp:pet value not SHACL-inferred to be of type pp:Pet rdfs:range pp:pet pp:Pet . ex:mikey rdf:type pp:Person ; pp:pet [ ] ; pp:name "Mike" ; pp:age "4" ; pp:income "4.0" ; pp:p5 "4.0E0" ; pp:p6 "4"^^xsd:int ; pp:p7 "4.0E0"^^xsd:float . AN9/ no SHACL-inferred value for pp:pet pp:petDog rdfs:subPropertyOf pp:pet . ex:mikey rdf:type pp:Person ; pp:petDog [ rdf:type pp:Pet ] ; pp:name "Mike"^^xsd:string ; pp:age "4"^^^xsd:integer ; pp:income "4.0"^^xsd:decimal ; pp:p5 "4.0E0"^^xsd:double ; pp:p6 "4"^^xsd:int ; pp:p7 "4.0E0"^^xsd:float . Combined control and data graph BP1/ all pp:pet values are acceptable for all pp:Person pp:Person rdf:type rdfs:Class . [ rdf:type sh:Shape; sh:scopeClass pp:Person ; sh:property [ rdf:type sh:Constaint; sh:predicate pp:pet; sh:class pp:Pet ] ] pp:Student rdfs:subClassOf pp:Person . pp:pet rdfs:domain pp:Person . pp:PetDog rdfs:subClassOf pp:Pet ; rdfs:subClassOf pp:Dog . pp:favouritePet rdfs:subPropertyOf pp:pet ; rdfs:domain pp:Person ; rdfs:range pp:Pet . ex:mikey rdf:type pp:Student ; pp:pet [ rdf:type pp:Pet ] ; pp:pet [ rdf:type pp:PetDog ] ; pp:favouritePet [ rdf:type pp:Pet ] . BP2/ all pp:pet values are acceptable for all pp:Person pp:Person rdf:type rdfs:Class . [ rdf:type sh:Shape; sh:scopeClass pp:Person ; sh:property [ rdf:type sh:Constraint; sh:predicate pp:pet; sh:class pp:Pet ] ] pp:Student rdfs:subClassOf pp:Person . pp:pet rdfs:domain pp:Person . pp:PetDog rdfs:subClassOf pp:Pet ; rdfs:subClassOf pp:Dog . pp:favouritePet rdfs:subPropertyOf pp:pet ; rdfs:domain pp:Person ; rdfs:range pp:Pet . ex:mikey rdf:type pp:Student ; pp:pet [ rdf:type pp:Pet ] ; pp:pet [ rdf:type pp:PetDog ] ; pp:favouritePet [ ] . BN1/ one pp:pet value for ex:mikey is not acceptable pp:Person rdf:type rdfs:Class . [ rdf:type sh:Shape; sh:scopeClass pp:Person ; sh:property [ rdf:type sh:Constraint; sh:predicate pp:pet; sh:class pp:Pet ] ] pp:Student rdfs:subClassOf pp:Person . pp:pet rdfs:domain pp:Person ; rdfs:range pp:Pet . pp:PetDog rdfs:subClassOf pp:Pet ; rdfs:subClassOf pp:Dog . pp:favouritePet rdfs:subPropertyOf pp:pet ; rdfs:domain pp:Person ; rdfs:range pp:PetDog . ex:mikey rdf:type pp:Student ; pp:pet [ rdf:type pp:Pet ] ; pp:pet [ ] ; pp:favouritePet [ rdf:type pp:Pet ] . BN2/ not enough values of pp:pet for ex:mikey pp:Person rdf:type rdfs:Class . [ rdf:type sh:Shape; sh:scopeClass pp:Person ; sh:property [ rdf:type sh:Constraint; sh:predicate pp:pet; sh:class pp:Pet; sh:minCount 3 ] ] pp:Student rdfs:subClassOf pp:Person . pp:pet rdfs:domain pp:Person . pp:PetDog rdfs:subClassOf pp:Pet ; rdfs:subClassOf pp:Dog . pp:favouritePet rdfs:subPropertyOf pp:pet ; rdfs:domain pp:Person ; rdfs:range pp:Pet . ex:mikey rdf:type pp:Student ; pp:pet [ rdf:type pp:Pet ] ; pp:pet [ rdf:type pp:PetDog ] ; pp:favouritePet [ rdf:type pp:Pet ] .
Received on Monday, 28 December 2015 16:57:19 UTC