forked from zazuko/cube-link
-
Notifications
You must be signed in to change notification settings - Fork 0
/
standalone-constraint-constraint.ttl
444 lines (422 loc) · 13 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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
@prefix time: <http://www.w3.org/2006/time#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@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/> .
@prefix relation: <https://cube.link/relation/> .
#
# 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" ;
],
[
sh:path
(
meta:relatesTo
[ sh:inversePath sh:path ]
[ sh:inversePath sh:property ]
) ;
sh:minCount 1 ;
sh:class cube:Constraint ;
sh:message "value of meta:relatesTo must be a cube dimension" ;
],
[
sh:path
(
meta:relatesTo
[ sh:inversePath sh:path ]
) ;
sh:class cube:MeasureDimension ;
sh:message "value of meta:relatesTo must point to measure dimension " ;
] ;
] ;
.
:Annotation
a sh:NodeShape ;
sh:targetObjectsOf meta:annotation ;
sh:property
[
sh:path rdf:type ;
sh:minCount 1 ;
sh:message "annotation needs an rdf:type" ;
],
[
sh:path meta:annotationContext ;
sh:nodeKind sh:BlankNode ;
],
[
sh:path
(
[ sh:inversePath meta:annotation ]
) ;
sh:class cube:MeasureDimension ;
sh:message "annotated dimension must be a cube:MeasureDimension" ;
] ;
.
:AnnotationValue
a sh:NodeShape ;
sh:targetObjectsOf meta:annotation ;
sh:message "annotation must have exactly one schema:value or a combination of schema:minValue and schema:maxValue" ;
sh:xone
(
[
sh:property
[
sh:path schema:value ;
sh:minCount 1 ;
sh:maxCount 1 ;
] ;
]
[
sh:property
[
sh:path [ sh:alternativePath ( schema:minValue schema:maxValue ) ] ;
sh:minCount 1 ;
sh:maxCount 2 ;
] ;
]
) ;
.
:AnnotationContextDimensionType
a sh:NodeShape ;
sh:targetObjectsOf meta:annotationContext ;
sh:message "annotation context must have exactly one sh:path which is cube's key dimension" ;
sh:not
[
sh:property
[
sh:path
(
[ sh:inversePath meta:annotationContext ]
[ sh:inversePath meta:annotation ]
[ sh:inversePath sh:property ]
sh:property
sh:path
) ;
sh:disjoint sh:path ;
] ;
] ;
sh:property
[
sh:path sh:path ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:nodeKind sh:IRI ;
] ;
sh:property
[
sh:path ( sh:path [ sh:inversePath sh:path ] ) ;
sh:xone
(
[ sh:class cube:KeyDimension ]
[
sh:property
[
sh:path [ sh:inversePath meta:annotationContext ] ;
sh:minCount 1
]
]
)
] ;
.
:AnnotationContext
a sh:NodeShape ;
sh:targetObjectsOf meta:annotationContext ;
sh:message
"annotation context only allows constraints sh:hasValue, sh:in, sh:minInclusive, sh:maxInclusive, sh:minExclusive, sh:maxExclusive and they cannot be mixed" ;
sh:xone
(
[
sh:property
[
sh:path sh:hasValue ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:nodeKind sh:IRIOrLiteral ;
] ;
]
[
sh:property
[
sh:path sh:in ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:node :listnode ;
sh:nodeKind sh:BlankNode ;
] ;
]
[
sh:property
[
sh:path [ sh:alternativePath ( sh:maxInclusive sh:maxExclusive sh:minInclusive sh:minExclusive ) ] ;
sh:minCount 1 ;
sh:maxCount 2 ;
],
[
sh:path [ sh:alternativePath ( sh:maxInclusive sh:maxExclusive ) ] ;
sh:maxCount 1 ;
],
[
sh:path [ sh:alternativePath ( sh:minInclusive sh:minExclusive ) ] ;
sh:maxCount 1 ;
] ;
]
)
.
:Confidence a sh:NodeShape ;
sh:targetClass relation:ConfidenceLowerBound, relation:ConfidenceUpperBound ;
sh:property
[
sh:path dcterms:type ;
sh:maxCount 1 ;
] ;
.
# 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"
] .