-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathvalidation.ttl
More file actions
150 lines (143 loc) · 5.75 KB
/
Copy pathvalidation.ttl
File metadata and controls
150 lines (143 loc) · 5.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
@prefix bacnet: <http://data.ashrae.org/bacnet/2020#> .
@prefix brick: <https://brickschema.org/schema/Brick#> .
@prefix bsh: <https://brickschema.org/schema/BrickShape#> .
@prefix dcterms: <http://purl.org/dc/terms#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix qudt: <http://qudt.org/schema/qudt/> .
@prefix qudtqk: <http://qudt.org/vocab/quantitykind/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sdo: <http://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix sosa: <http://www.w3.org/ns/sosa/> .
@prefix tag: <https://brickschema.org/schema/BrickTag#> .
@prefix unit: <http://qudt.org/vocab/unit/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
# SHACL rule which tests that every single URI that starts with the Brick namespace
# has a corresponding class or property in the Brick ontology
bsh:NamespaceDefinitionRule
a sh:NodeShape ;
# Target every node that appears in the graph
sh:target [
a sh:SPARQLTarget ;
sh:select """
SELECT DISTINCT ?this WHERE {
{ ?this ?p ?o } UNION { ?s ?p ?this }
}
"""
] ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:message "URIs in the Brick namespace must have a class or be an instance of Substance, Quantity, or Tag." ;
sh:prefixes <https://brickschema.org/schema/Brick> ;
sh:select """
PREFIX brick: <https://brickschema.org/schema/Brick#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT $this WHERE {
FILTER NOT EXISTS { $this owl:deprecated true }
FILTER(isIRI($this))
FILTER(STRSTARTS(STR($this), "https://brickschema.org/schema/Brick#"))
FILTER NOT EXISTS {
{ $this a owl:Class, sh:NodeShape ; rdfs:subClassOf* brick:Entity }
UNION
{ $this a brick:Substance }
UNION
{ $this a brick:Quantity }
UNION
{ $this a brick:Tag }
UNION
{ $this a brick:EntityProperty }
UNION
{ $this a owl:ObjectProperty }
UNION
{ $this a owl:DatatypeProperty }
UNION
{ $this a rdf:Property }
UNION
{ $this a sh:NodeShape }
UNION
{ $this rdf:type/rdfs:subClassOf* brick:Relationship }
}
}
"""
] .
bsh:NamespaceDefinitionRuleProperty
a sh:NodeShape ;
# Target every node that appears in the graph
sh:target [
a sh:SPARQLTarget ;
sh:select """
SELECT DISTINCT ?this WHERE {
?s ?this ?o
}
"""
] ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:message "Properties in the Brick namespace must be an instance of EntityProperty/Relationship and ObjectProperty/DatatypeProperty." ;
sh:prefixes <https://brickschema.org/schema/Brick> ;
sh:select """
PREFIX brick: <https://brickschema.org/schema/Brick#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT $this WHERE {
FILTER NOT EXISTS { $this owl:deprecated true }
FILTER(isIRI($this))
FILTER(STRSTARTS(STR($this), "https://brickschema.org/schema/Brick#"))
FILTER NOT EXISTS {
{ $this a brick:Relationship }
UNION
{ $this a brick:EntityProperty }
{ $this a owl:ObjectProperty }
UNION
{ $this a owl:DatatypeProperty }
}
}
"""
] .
bsh:ObjectDatatypePropertyDisjoint a sh:NodeShape ;
sh:targetClass owl:ObjectProperty, owl:DatatypeProperty ;
sh:message "Object and Datatype properties must be disjoint." ;
sh:xone (
[ sh:class owl:ObjectProperty ]
[ sh:class owl:DatatypeProperty ]
) .
bsh:NonCanonicalWithDefinitionShape
a sh:NodeShape ;
sh:target [
a sh:SPARQLTarget ;
sh:select """
PREFIX brick: <https://brickschema.org/schema/Brick#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT DISTINCT ?this WHERE {
?this a owl:Class ;
brick:aliasOf ?canonical ;
skos:definition ?def ;
rdfs:subClassOf* brick:Entity .
}
"""
] ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:message "This class has a skos:definition but is marked as non-canonical via brick:aliasOf. Only canonical classes may have definitions." ;
sh:prefixes <https://brickschema.org/schema/Brick> ;
sh:select """
PREFIX brick: <https://brickschema.org/schema/Brick#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT $this WHERE {
FILTER(isIRI($this))
FILTER(STRSTARTS(STR($this), "https://brickschema.org/schema/Brick#"))
FILTER EXISTS { $this skos:definition ?def }
FILTER EXISTS { $this brick:aliasOf ?canonical}
}
"""
] .