Commit 5a25c444 authored by Susanne Arndt's avatar Susanne Arndt
Browse files

Resolve "Add Shacl shapes"

parent 85816bed
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://www.example.org/#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix listdb: <https://www.listdb.de/ontology#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix wikidata: <http://www.wikidata.org/entity/> .
@prefix qudt: <http://qudt.org/schema/qudt/> .
ex:Quantity_Shape
a sh:NodeShape ;
sh:targetClass qudt:Quantity ;
sh:property [
sh:path listdb:value ;
sh:minCount 1;
sh:maxCount 1;
sh:or ([sh:datatype xsd:string][sh:datatype xsd:nonNegativeInteger][sh:datatype xsd:float ;] [sh:datatype xsd:integer]) ;
sh:severity sh:Warning ;
];
sh:property [
sh:path qudt:unit ;
sh:minCount 1;
sh:maxCount 1;
sh:Class qudt:Unit ;
sh:severity sh:Warning ;
];
sh:property [
sh:path skos:prefLabel ;
sh:minCount 1;
sh:maxCount 1;
sh:or ([sh:datatype xsd:string ;] [sh:languageIn ("en" "de")]);
sh:severity sh:Warning ;
];
sh:closed true ;
sh:ignoredProperties ( rdf:type owl:topDataProperty owl:topObjectProperty ) .
\ No newline at end of file
# Data validation with the Shapes Constraints Language
With the [Shapes Constraints Language (SHACL)](https://www.w3.org/TR/shacl/) it is possible to define a set of conditions against which an RDF graph can be validated for well-formedness.
This set of conditions is itself modelled as an RDF graph. These so-called "shapes graphs" can re-use ontology terms and other RDF data.
This directory contains shapes graphs for the validation of elements in LisDB Ontology.
The basic principle is well demonstrated by the [SHACL documentation](https://www.w3.org/TR/shacl/#shacl-example), from which the following examples are taken.
A simple example for a shapes graphs is:
``` Turtle
ex:PersonShape
a sh:NodeShape ;
sh:targetClass ex:Person ; # Applies to all persons
sh:property [ # _:b1
sh:path ex:ssn ; # constrains the values of ex:ssn
sh:maxCount 1 ;
sh:datatype xsd:string ;
sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ;
] ;
sh:property [ # _:b2
sh:path ex:worksFor ;
sh:class ex:Company ;
sh:nodeKind sh:IRI ;
] ;
sh:closed true ;
sh:ignoredProperties ( rdf:type ) .
```
A simple example for a data graph whose well-formedness needs to be checked is:
``` Turtle
@prefix ex: <http://www.example.com#>
ex:Alice
a ex:Person ;
ex:ssn "987-65-432A" .
ex:Bob
a ex:Person ;
ex:ssn "123-45-6789" ;
ex:ssn "124-35-6789" .
ex:Calvin
a ex:Person ;
ex:birthDate "1971-07-07"^^xsd:date ;
ex:worksFor ex:UntypedCompany .
```
Evaluating these data against the shapes graph, would result in the following violations:
```Turtle
[ a sh:ValidationReport ;
sh:conforms false ;
sh:result
[ a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:focusNode ex:Alice ;
sh:resultPath ex:ssn ;
sh:value "987-65-432A" ;
sh:sourceConstraintComponent sh:RegexConstraintComponent ;
sh:sourceShape ... blank node _:b1 on ex:ssn above ... ;
] ,
[ a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:focusNode ex:Bob ;
sh:resultPath ex:ssn ;
sh:sourceConstraintComponent sh:MaxCountConstraintComponent ;
sh:sourceShape ... blank node _:b1 on ex:ssn above ... ;
] ,
[ a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:focusNode ex:Calvin ;
sh:resultPath ex:worksFor ;
sh:value ex:UntypedCompany ;
sh:sourceConstraintComponent sh:ClassConstraintComponent ;
sh:sourceShape ... blank node _:b2 on ex:worksFor above ... ;
] ,
[ a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:focusNode ex:Calvin ;
sh:resultPath ex:birthDate ;
sh:value "1971-07-07"^^xsd:date ;
sh:sourceConstraintComponent sh:ClosedConstraintComponent ;
sh:sourceShape sh:PersonShape ;
]
] .
```
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://www.example.org/#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix listdb: <https://www.listdb.de/ontology#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix wikidata: <http://www.wikidata.org/entity/> .
@prefix qudt: <http://qudt.org/schema/qudt/> .
ex:metadata_file_Shape
a sh:NodeShape ;
sh:targetClass listdb:C0000000062 ;
sh:property [
sh:path dcterms:spatial ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:severity sh:Warning ;
] ;
sh:property [
sh:path geo:location ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:severity sh:Warning ;
] ;
sh:property [
sh:path skos:prefLabel ;
sh:maxCount 1 ;
sh:languageIn ("en" "de") ;
sh:severity sh:Warning ;
];
sh:property [
sh:path wikidata:P281 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:datatype xsd:string] [sh:datatype xsd:integer]) ;
sh:pattern "\\d{5}" ;
sh:severity sh:Warning ;
];
sh:property [
sh:path wikidata:P669 ;
sh:maxCount 3 ;
sh:minCount 1 ;
sh:severity sh:Warning ;
];
sh:property [
sh:path skos:listdb:AP0000000064 ;
sh:minCount 0 ;
sh:languageIn ("en" "de") ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:AP0000000075 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:AP0000000151 ;
sh:minCount 0 ;
sh:maxCount 1 ;
sh:or ([sh:class listdb:E0000000253 ;] [sh:datatype xsd:string ; sh:languageIn ("en" "de") ;]) ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:AP0000000161 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:datatype xsd:integer ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:AP0000000162 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:datatype xsd:string ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:DP0000000027 ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:languageIn ("en" "de") ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:DP0000000028 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:dataType xsd:string ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:DP0000000029 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:dataType xsd:integer ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:DP0000000187;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:dataType xsd:string ;
sh:pattern "\\d{8}_\\d{4}" ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:E0000000213 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000204] [sh:class listdb:E0000000253 ;] [sh:datatype xsd:string ;]) ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:E0000000216 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:class qudt:Quantity ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:E0000000223 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:class qudt:Quantity ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:E0000000230 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:class qudt:Quantity ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:E0000000232 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:class qudt:Quantity ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:E0000000236 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:class qudt:Quantity ;
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000018 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000020 ;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000038 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000033;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000042 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000041;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000049 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000047;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000056 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000052;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000060 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000057;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000073 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000070;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000085 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000080;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000118 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000086;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000119 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000098;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000125 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000120;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000127 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000126;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000129 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000128;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000165 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000153;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000166 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000158;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000168 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000131;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000169 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000132;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000170 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000133;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000180 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000143;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000171 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000134;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000172 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000135;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000177 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000140;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000181 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000144;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000182 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000145;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000183 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000146;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000184 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000147;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000185 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000148;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000190 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class qudt:Quantity;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000194 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class qudt:Quantity;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000196 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class qudt:Quantity;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000197 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class qudt:Quantity;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000199 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class qudt:Quantity;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:E0000000222 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class qudt:Quantity;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000017 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000040;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:AP0000000064 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:languageIn ("en" "de");] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000201 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class qudt:Quantity;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000173 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000136;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000172 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000135;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000174 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000137;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000175 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000138;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000176 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000139;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000178 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000141;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000179 ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:or ([sh:class listdb:C0000000142;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;
];
sh:property [
sh:path listdb:OP0000000037 ;
sh:minCount 1 ;
sh:or ([sh:class qudt:Quantity ;][sh:class listdb:C0000000039;] [sh:class listdb:E0000000253 ;]);
sh:severity sh:Warning ;