-
Notifications
You must be signed in to change notification settings - Fork 8
/
standalone-constraint-constraint.ttl
275 lines (257 loc) · 7.69 KB
/
standalone-constraint-constraint.ttl
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
@prefix : <https://cube.link/shape/standalone-constraint-constraint#> .
@prefix dash: <http://datashapes.org/dash#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix cube: <https://cube.link/> .
@prefix meta: <https://cube.link/meta/> .
@prefix qudt: <http://qudt.org/schema/qudt/> .
#
# This is the bare minimal SHACL shape for validating a Cube Constraint.
# All Cube Constraints should pass this validation.
#
:ObservationConstraintShape
a sh:NodeShape ;
sh:targetClass cube:Constraint ;
sh:property [
# we assume at least 3 dimensions, otherwise we would have an empty list of dimensions
# one for cube:observedBy, one for rdf:type and at least one cube dimension
sh:path sh:property ;
sh:minCount 3 ;
sh:message "cube:Constraint needs at least a certain amount of sh:properties"
] ;
sh:property
[
sh:path sh:property ;
sh:node :PropertyPath ;
sh:message "a sh:path is needed on a property" ;
] ,
[
sh:path sh:property ;
sh:node :PropertyWithName ;
sh:message "needs a schema:name" ;
] ,
[
sh:path sh:property ;
sh:node :PropertyNameType ;
sh:message "schema:name needs to be a xsd:string or a rdf:langString" ;
] ,
[
sh:path sh:property ;
sh:node :PropertyWithType ;
sh:message "needs a sh:datatype, sh:nodeKind or sh:datatype within sh:or (...)" ;
] ,
[
sh:path sh:property ;
sh:node :PropertyScaleType ;
sh:message "If qudt:scaleType is used it needs to be within ( qudt:IntervalScale qudt:NominalScale qudt:EnumerationScale qudt:RatioScale qudt:OrdinalScale )" ;
] ,
[
sh:path sh:property ;
sh:node :PropertyRange ;
] ,
[
sh:path sh:property ;
sh:node :PropertyInList ;
sh:message "sh:in needs to be a list" ;
] ,
[
sh:path sh:property ;
sh:node :DimensionRelation ;
] ,
[
sh:path sh:property ;
sh:or (
[
sh:path qudt:unit ;
sh:equals qudt:hasUnit ;
]
[
sh:path qudt:unit ;
sh:maxCount 0 ;
]
) ;
sh:severity sh:Warning ;
sh:message "The use of qudt:unit is deprecated, please use qudt:hasUnit instead" ;
] ;
sh:property [
sh:path sh:closed;
sh:hasValue true;
] ;
sh:property [
sh:path meta:inHierarchy;
sh:node :Hierarchy;
sh:message "meta:inHierarchy does not validate"
] ;
.
:PropertyPath a sh:NodeShape ;
sh:property [
sh:path sh:path;
sh:minCount 1;
sh:maxCount 1;
] ;
.
:PropertyWithName a sh:NodeShape ;
sh:or(
[
sh:path schema:name;
sh:minCount 1;
]
[
sh:path sh:path;
sh:in (rdf:type cube:observedBy);
]
);
.
:PropertyNameType a sh:NodeShape ;
sh:property [
sh:path schema:name;
sh:xone ( [ sh:datatype xsd:string ] [ sh:datatype rdf:langString ] ) ;
];
.
:PropertyWithType a sh:NodeShape ;
sh:or(
[
sh:path sh:datatype;
sh:minCount 1;
]
[
sh:path sh:nodeKind;
sh:minCount 1;
]
[
sh:path sh:or;
sh:minCount 1;
sh:node :listnode ;
sh:property [
sh:path ( [ sh:zeroOrMorePath rdf:rest ] rdf:first ) ; # all list elements
sh:property [ sh:path sh:datatype ; sh:minCount 1 ] ; # have at least one datatype
]
]
);
.
:PropertyInList a sh:NodeShape ;
sh:property [
sh:path sh:in;
sh:node :listnode ;
];
.
:PropertyScaleType a sh:NodeShape ;
sh:property [
sh:path qudt:scaleType;
sh:in (qudt:IntervalScale qudt:NominalScale qudt:EnumerationScale qudt:RatioScale qudt:OrdinalScale) ;
sh:maxCount 1;
];
.
:PropertyRange a sh:NodeShape ;
sh:property [
sh:path sh:minInclusive;
sh:nodeType sh:Literal;
sh:message "sh:minInclusive needs to be a literal"
];
sh:property [
sh:path sh:maxInclusive;
sh:nodeType sh:Literal;
sh:message "sh:maxInclusive needs to be a literal"
];
sh:property [
sh:path sh:minCount;
sh:hasValue 1 ;
sh:maxCount 1 ;
sh:message "sh:minCount needs to be 1" ;
] , [
sh:path sh:maxCount;
sh:hasValue 1 ;
sh:maxCount 1 ;
sh:message "sh:maxCount needs to be 1" ;
] ;
.
:DimensionRelation a sh:NodeShape ;
sh:property [
sh:path meta:dimensionRelation;
sh:property [
sh:path meta:relatesTo;
sh:nodeKind sh:IRI ;
sh:minCount 1;
sh:message "meta:dimensionRelation requires at least one meta:relatesTo";
] ;
] ;
.
# Testing proper rdf:list construction
:restvalue sh:targetObjectsOf rdf:rest ;
sh:message "rdf:rest value must be a list node or rdf:nil";
sh:xone ([ sh:node :listnode ] [ sh:hasValue rdf:nil ])
.
:listnode sh:targetSubjectsOf rdf:first, rdf:rest ;
sh:property [ sh:path rdf:first ; sh:minCount 1 ; sh:maxCount 1 ;
sh:message "list node needs exactly one rdf:first" ] ;
sh:property [ sh:path rdf:rest ; sh:minCount 1 ; sh:maxCount 1 ;
sh:message "list node needs exactly one rdf:rest" ] ;
sh:closed true ;
sh:ignoredProperties (rdf:type) .
:inversepathnode a sh:NodeShape ;
sh:property [
sh:path sh:inversePath;
sh:nodeKind sh:IRI;
sh:minCount 1;
sh:maxCount 1;
sh:message "nextInHierarchy requires sh:path to be IRI or [ sh:inversePath ... ]"
] .
:NextInHierarchy a sh:NodeShape ;
sh:property [
sh:path sh:path;
sh:minCount 1;
sh:maxCount 1;
sh:message "nextInHierarchy requires exactly one sh:path"
],
[
sh:path schema:name;
sh:minCount 1;
sh:message "nextInHierarchy requires schema:name"
],
[
sh:path sh:targetClass;
sh:nodeKind sh:IRI;
sh:message "meta:nextInHierarchy/sh:targetClass must be an IRI"
],
[
sh:path meta:nextInHierarchy;
sh:node :NextInHierarchy ;
sh:severity sh:Info;
sh:message "nextInHierarchy can have nested nodes"
] ;
sh:xone (
[
sh:path sh:path;
sh:nodeKind sh:IRI;
sh:message "nextInHierarchy requires sh:path to be IRI or [ sh:inversePath ... ]"
]
[
sh:path sh:path;
sh:nodeKind sh:BlankNode;
sh:node :inversepathnode;
sh:message "nextInHierarchy requires sh:path to be IRI or [ sh:inversePath ... ]"
]
)
.
:Hierarchy a sh:NodeShape ;
sh:targetClass meta:Hierarchy ;
sh:property [
sh:path meta:hierarchyRoot;
sh:minCount 1;
sh:nodeKind sh:IRI;
sh:message "inHierarchy requires hierarchyRoot";
],
[
sh:path schema:name;
sh:minCount 1;
sh:message "inHierarchy requires schema:name"
],
[
sh:path meta:nextInHierarchy;
sh:node :NextInHierarchy;
sh:minCount 1;
sh:message "inHierarchy requires a conform nextInHierarchy"
] .