-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmetamodel.ttl
619 lines (503 loc) · 28 KB
/
metamodel.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
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
## SHACL metamodel for my proposed syntax
## Includes
## - introduction of the core SHACL vocabulary, including types, domains, and ranges
## - shapes to validate the shape graphs, provided that all RDFS consequences are
## included in the shape graph (An alternative is to change the scopes to property
## object scopes, but that doesn't produce useful validation results)
## - introduction of the extension vocabulary, including types, domains, and ranges
## - implementation of SHACL constructs using templates
## - introduction and implementation of a few compatability constructs
@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 shmm: <http://www.w3.org/ns/shaclmm#> .
## PART 1: Core
sh:Shape a rdfs:Class .
sh:severity a rdf:Property .
sh:name a rdf:Property ; rdfs:domain sh:Shape ; rdfs:range rdf:langString .
sh:description a rdf:Property ; rdfs:domain sh:Shape ; rdfs:range rdf:langString .
sh:order a rdf:Property ; rdfs:range xsd:decimal .
sh:group a rdf:Property ; rdfs:domain sh:Shape ; rdfs:range sh:PropertyGroup .
sh:defaultValue a rdf:Property ; rdfs:domain sh:Shape .
shmm:shapeOtherShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:severity [ a sh:Shape ; sh:in ( sh:Info sh:Warning sh:Violation ) ] ) ;
sh:propValues ( sh:name [ a sh:Shape ; sh:uniqueLang true ] );
sh:propValues ( sh:description [ a sh:Shape ; sh:uniqueLang true ] );
sh:propValues ( sh:order [ a sh:Shape ; sh:datatype xsd:decimal ; sh:maxCount 1 ] ) ;
sh:propValues ( sh:group [ a sh:Shape ; sh:class sh:PropertyGroup ] ) ;
sh:propValues ( sh:defaultValue [ a sh:Shape ; sh:maxCount 1 ] ) .
sh:PropertyGroup a rdfs:Class .
shmm:shapePropertyGroup a sh:Shape ; sh:scopeClass sh:PropertyGroup ;
sh:propValues ( sh:order [ a sh:Shape ; sh:datatype xsd:decimal ; sh:maxCount 1 ] ) .
sh:inverse a rdf:Property ; rdfs:range rdf:Property .
# Validation results
sh:ValidationResult a rdfs:Class .
sh:focusNode a rdf:Property ; rdfs:domain sh:ValidationResult .
sh:subject a rdf:Property ; rdfs:domain sh:ValidationResult .
sh:predicate a rdf:Property ; rdfs:domain sh:ValidationResult ; rdfs:range rdf:Property .
sh:object a rdf:Property ; rdfs:domain sh:ValidationResult .
sh:sourceComponent a rdf:Property ; rdfs:domain sh:ValidationResult .
sh:sourceShape a rdf:Property ; rdfs:domain sh:ValidationResult ; rdfs:range sh:Shape .
sh:sourceTemplate a rdf:Property ; rdfs:domain sh:ValidationResult ; rdfs:range sh:ComponentTemplate .
sh:detail a rdf:Property ; rdfs:domain sh:ValidationResult .
sh:message a rdf:Property ; rdfs:range rdf:LangString .
shmm:ValidationResultSyntax a sh:Shape ; sh:scopeClass sh:ValidationResult ;
sh:propValues ( sh:focusNode [ a sh:Shape ; sh:maxCount 1 ] ) ;
sh:propValues ( sh:subject [ a sh:Shape ; sh:maxCount 1 ] ) ;
sh:propValues ( sh:predicate [ a sh:Shape ; sh:maxCount 1 ] ) ;
sh:propValues ( sh:object [ a sh:Shape ; sh:maxCount 1 ] ) ;
sh:propValues ( sh:sourceConstraint [ a sh:Shape ; sh:maxCount 1 ] ) ;
sh:propValues ( sh:sourceShape [ a sh:Shape ; sh:maxCount 1 ] ) ;
sh:propValues ( sh:sourceTemplate [ a sh:Shape ; sh:maxCount 1 ] ) ;
sh:propValues ( sh:message [ a sh:Shape ; sh:datatype rdf:LangString ] ) ;
sh:propValues ( sh:severity [ a sh:Shape ; sh:in ( sh:Info sh:Warning sh:Violation ) ] ) .
## PART 2: Description of built-ins, including validation shapes
# Auxiliary shapes
shmm:notBlank a sh:Shape ;
sh:or ( [ a sh:Shape ; sh:nodeKind sh:IRI ] [ a sh:Shape ; sh:nodeKind sh:Literal ] ) .
shmm:pathShape a sh:Shape ;
sh:or ( shmm:pathPartShape
[ a sh:Shape ; sh:list shmm:pathPartShape ] ) .
shmm:pathPartShape a sh:Shape ;
sh:or ( shmm:inverseShape # inverse of a property
[ a sh:Shape ; sh:nodeKind sh:IRI ] ) . # property
shmm:inverseShape a sh:Shape ;
sh:propValues ( sh:inverse [ a sh:Shape ; sh:nodeKind sh:IRI ;
sh:minCount 1 ; sh:maxCount 1 ] ) .
# Scopes
sh:scopeClass a rdf:Property; a sh:Shape; rdfs:domain sh:Shape; rdfs:range rdfs:Class ;
sh:nodeKind sh:IRI .
shmm:scopeClassShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:minExclusive sh:minExclusive ) .
sh:scopeNode a rdf:Property; a sh:Shape; rdfs:domain sh:Shape ;
sh:shape shmm:notBlank .
shmm:scopeNodeShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:scopeNode sh:scopeNode ) .
sh:scopePropertyObject a rdf:Property; a sh:Shape; rdfs:domain sh:Shape; rdfs:range rdf:Property;
sh:shape shmm:notBlank .
shmm:scopePropertyObjectShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:scopePropertyObject sh:scopePropertyObject ) .
sh:scopePropertySubject a rdf:Property; a sh:Shape; rdfs:domain sh:Shape; rdfs:range rdf:Property;
sh:shape shmm:notBlank .
shmm:scopePropertySubjectShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:scopePropertySubject sh:scopePropertySubject ) .
sh:scopeAllObjects a rdf:Property; a sh:Shape; rdfs:domain sh:Shape; rdfs:range xsd:boolean ;
sh:in ( true ) .
shmm:scopeAllObjectsShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:scopeAllObjects sh:scopeAllObjects ) .
sh:scopeAllSubjects a rdf:Property; a sh:Shape; rdfs:domain sh:Shape; rdfs:range xsd:boolean ;
sh:in ( true ) .
shmm:scopeAllSubjectsShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:scopeAllSubjects sh:scopeAllSubjects ) .
# Filter
sh:filter a rdf:Property; a sh:Shape; rdfs:domain sh:Shape; rdfs:range sh:Shape ;
sh:class sh:Shape .
shmm:filterShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:filter sh:filter ) .
# Components
sh:in a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdf:List ;
sh:list shmm:notBlank .
shmm:inShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:in sh:in ) .
sh:class a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdfs:Class ;
sh:nodeKind sh:IRI .
shmm:classShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:class sh:class ) .
sh:classIn a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdf:List ;
sh:list [ a sh:Shape ; sh:nodeKind sh:IRI ] .
shmm:classInShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:classIn sh:classIn ) .
sh:datatype a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdfs:Datatype ;
sh:nodeKind sh:IRI .
shmm:datatypeShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:datatype sh:datatype ) .
sh:datatypeIn a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdf:List ;
sh:list [ a sh:Shape ; sh:nodeKind sh:IRI ] .
shmm:datatypeInShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:datatypeIn sh:datatypeIn ) .
sh:directType a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdfs:Class ;
sh:nodeKind sh:IRI .
shmm:directTypeShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:directType sh:directType ) .
sh:minLength a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range xsd:integer ;
sh:datatype xsd:integer ;
sh:minInclusive 0 .
shmm:minLengthShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:minLength sh:minLength ) .
sh:maxLength a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range xsd:integer ;
sh:datatype xsd:integer ;
sh:minInclusive 0 .
shmm:maxLengthShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:maxLength sh:maxLength ) .
sh:minInclusive a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdfs:Literal ;
sh:nodeKind sh:Literal .
shmm:minInclusiveShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:minInclusive sh:minInclusive ) .
sh:minExclusive a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdfs:Literal ;
sh:nodeKind sh:Literal .
shmm:minExclusiveShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:minExclusive sh:minExclusive ) .
sh:maxInclusive a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdfs:Literal ;
sh:nodeKind sh:Literal .
shmm:maxInclusiveShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:maxInclusive sh:maxInclusive ) .
sh:maxExclusive a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdfs:Literal ;
sh:nodeKind sh:Literal .
shmm:maxExclusiveShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:maxExclusive sh:maxExclusive ) .
sh:nodeKind a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ;
sh:in ( sh:BlankNode sh:IRI sh:Literal sh:BlankNodeOrIRI
sh:BlankNodeOrLiteral sh:IRIOrLiteral ) .
shmm:nodeKindShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:nodeKind sh:nodeKind ) .
sh:pattern a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ;
sh:or ( [ a sh:Shape ; sh:list [ a sh:Shape ; sh:datatype xsd:string ] ;
sh:propValues ( ( rdf:rest rdf:rest ) [ a sh:Shape ; sh:hasValue rdf:nil ] ) ]
[ a sh:Shape ; sh:datatype xsd:string ] ) .
shmm:patternShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:pattern sh:pattern ) .
sh:equals a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdf:List ;
sh:list shmm:pathShape ;
sh:propValues ((rdf:rest rdf:rest) [ a sh:Shape ; sh:hasValue rdf:nil ] ) .
shmm:equalsShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:equals sh:equals ) .
sh:disjoint a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdf:List ;
sh:list shmm:pathShape ;
sh:propValues ((rdf:rest rdf:rest) [ a sh:Shape ; sh:hasValue rdf:nil ] ) .
shmm:disjointShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:disjoint sh:disjoint ) .
sh:lessThan a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdf:List ;
sh:propValues ((rdf:rest rdf:rest) [ a sh:Shape ; sh:hasValue rdf:nil ] ) ;
sh:list shmm:pathShape .
shmm:lessThanShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:lessThan sh:lessThan ) .
sh:lessThanOrEquals a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdf:List ;
sh:list shmm:pathShape ;
sh:propValues ((rdf:rest rdf:rest) [ a sh:Shape ; sh:hasValue rdf:nil ] ) .
shmm:lessThanOrEqualsShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:lessThanOrEquals sh:lessThanOrEquals ) .
sh:hasValue a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ;
sh:shape shmm:notBlank .
shmm:hasValueShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:hasValue sh:hasValue ) .
sh:uniqueLang a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ;
sh:in ( true ) .
shmm:uniqueLangShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:uniqueLang sh:uniqueLang ) .
sh:minCount a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range xsd:integer ;
sh:datatype xsd:integer ;
sh:minInclusive 0 .
shmm:minCountShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:minCount sh:minCount ) .
sh:maxCount a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range xsd:integer ;
sh:datatype xsd:integer ;
sh:minInclusive 0 .
shmm:maxCountShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:maxCount sh:maxCount ) .
sh:closed a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdf:List ;
sh:list [ a sh:Shape ; sh:or ( [ a sh:Shape ; sh:nodeKind sh:IRI ] shmm:inverseShape ) ] .
shmm:closedShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:closed sh:closed ) .
sh:list a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range sh:Shape ;
sh:class sh:Shape .
shmm:listShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:list sh:list ) .
sh:shape a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range sh:Shape ;
sh:class sh:Shape .
shmm:shapeShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:shape sh:shape ) .
sh:not a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range sh:Shape ;
sh:class sh:Shape .
shmm:notShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:not sh:not ) .
sh:and a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdf:List ;
sh:list [ a sh:Shape ; sh:class sh:Shape ] .
shmm:andShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:and sh:and ) .
sh:or a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdf:List ;
sh:list [ a sh:Shape ; sh:class sh:Shape ] .
shmm:orShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:or sh:or ) .
sh:partition a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdf:List ;
sh:list [ a sh:Shape ; sh:class sh:Shape ] .
shmm:partitionShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:partition sh:partition ) .
sh:propValues a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdf:List ;
sh:list [ a sh:Shape ] ;
sh:propValues ( ( rdf:rest rdf:rest ) [ a sh:Shape ; sh:hasValue rdf:nil ] ) ;
sh:propValues ( rdf:first shmm:pathShape ) ;
sh:propValues ( ( rdf:rest rdf:first ) [ a sh:Shape ; sh:class sh:Shape ] ) .
shmm:propValuesShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:propValues sh:propValues ) .
## PART 3: Extension Language
sh:scopeQuery a rdf:Property; rdfs:domain sh:Shape; rdfs:range xsd:string ;
sh:datatype xsd:string .
shmm:scopeQueryShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:scopeQuery sh:scopeQuery ) .
sh:query a rdf:Property; a sh:Shape ; rdfs:domain sh:Shape; rdfs:range xsd:string ;
sh:datatype xsd:string .
shmm:queryShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:query sh:query ) .
sh:ScopeTemplate a rdfs:Class; rdfs:subClassOf rdf:Property; rdfs:subClassOf sh:Shape.
shmm:queryScopeTemplateUniques a sh:Shape ; sh:scopeClass sh:scopeTemplate ;
sh:propValues ( sh:templateQuery [ a sh:Shape ; sh:maxCount 1 ] ) .
sh:ComponentTemplate a rdfs:Class; rdfs:subClassOf rdf:Property; rdfs:subClassOf sh:Shape.
sh:templateFilter a rdf:Property ; rdfs:range xsd:string .
sh:templatePattern a rdf:Property ; rdfs:range xsd:string .
sh:templateHaving a rdf:Property ; rdfs:range xsd:string .
sh:templateQuery a rdf:Property ; rdfs:range xsd:string .
sh:templateMessage a rdf:Property ; rdfs:range rdf:langString .
shmm:queryTemplateUniques a sh:Shape ; sh:scopeClass sh:ComponentTemplate ;
sh:propValues ( sh:templateFilter [ a sh:Shape ; sh:maxCount 1 ] ) ;
sh:propValues ( sh:templatePattern [ a sh:Shape ; sh:maxCount 1 ] ) ;
sh:propValues ( sh:templateHaving [ a sh:Shape ; sh:maxCount 1 ] ) ;
sh:propValues ( sh:templateQuery [ a sh:Shape ; sh:maxCount 1 ] ) ;
sh:propValues ( sh:templateMessage [ a sh:Shape ; sh:uniqueLang true ] ) .
sh:argumentName a rdf:Property ; rdfs:domain sh:Shape ; rdfs:range xsd:string .
sh:defaultValue a rdf:Property ; rdfs:domain sh:Shape .
shmm:argumentShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:argumentName [ a sh:Shape ; sh:datatype xsd:string ;
sh:minCount 1 ; sh:maxCount 1 ] ) ;
sh:propValues ( sh:defaultValue [ a sh:Shape ; sh:datatype xsd:string ;
sh:maxCount 1 ] ) .
## PART 4: Implementing SHACL Constructs Using Templates (not part of SHACL definition)
# Scopes
sh:scopeClass a sh:ScopeTemplate ;
sh:templateQuery "SELECT DISTINCT ?scope WHERE { ?scope rdf:type/rdfs:subClassOf* [argument] }" .
sh:scopeNode a sh:ScopeTemplate ;
sh:templateQuery "SELECT ( [argument] as ?scope ) WHERE { }" .
sh:scopePropertyObject a sh:ScopeTemplate ;
sh:templateQuery "SELECT DISTINCT ?scope WHERE { ?that [argument] ?scope . }" .
sh:scopePropertySubject a sh:ScopeTemplate ;
sh:templateQuery "SELECT DISTINCT ?scope WHERE { ?scope [argument] ?that . }" .
sh:scopeAllObjects a sh:ScopeTemplate ;
sh:templateQuery "SELECT DISTINCT ?scope WHERE { ?that ?property ?scope . }" .
sh:scopeAllSubjects a sh:ScopeTemplate ;
sh:templateQuery "SELECT DISTINCT ?scope WHERE { ?scope ?property ?that . }" .
sh:scopeQuery a sh:ScopeTemplate ;
sh:templateQuery "[argument]" .
# Components
sh:in a sh:ComponentTemplate;
sh:templateMessage "Does not have any required value"@en ;
sh:message "Values cannot be blank nodes"@en ;
sh:templateFilter "EXISTS { VALUES ?this { [l(argument)] } }" .
sh:class a sh:ComponentTemplate;
sh:templateMessage "Does not have required class [argument]"@en ;
sh:message "Classes need to be IRIs"@en ;
sh:templateFilter "EXISTS { ?this rdf:type/rdfs:subClassOf* [argument] }" .
sh:classIn a sh:ComponentTemplate ;
sh:templateMessage "Does not have any required class [l(argument)]"@en ;
sh:message "Classes need to be IRIs"@en ;
sh:templateFilter """EXISTS { VALUES ?class { [l(argument)] }
?this rdf:type/rdfs:subClassOf* ?class . }""" .
sh:datatype a sh:ComponentTemplate ;
sh:templateMessage "Does not have required datatype [argument]"@en ;
sh:message "Datatypes need to be IRIs"@en ;
sh:templateFilter """( isLiteral(?this) && datatype(?this) = [argument] )""" .
sh:datatypeIn a sh:ComponentTemplate ;
sh:templateMessage "Does not have any required datatype [l(argument)]"@en ;
sh:message "Datatypes need to be IRIs"@en ;
sh:templatePattern """BIND ( datatype(?this) AS ?dt )
FILTER NOT EXISTS { VALUES ?dt { [l(argument)] } }""" .
sh:directType a sh:ComponentTemplate ;
sh:templateMessage "Does not have required direct type [argument]"@en ;
sh:message "Classes need to be IRIs"@en ;
sh:templateFilter """EXISTS { ?this rdf:type [argument] }""" .
sh:minLength a sh:ComponentTemplate ;
sh:templateMessage "Length too short, must be at least [argument]"@en ;
sh:message "Length argument must be integer"@en ;
sh:templateFilter """( !isBlank(?this) && STRLEN(STR(?this)) >= [argument] )""" .
sh:maxLength a sh:ComponentTemplate ;
sh:templateMessage "Length too long, must be at most [argument]"@en ;
sh:message "Length argument must be integer"@en ;
sh:templateFilter "( !isBlank(?this) && STRLEN(STR(?this)) <= [argument] )" .
sh:minInclusive a sh:ComponentTemplate ;
sh:templateMessage "Too small, must be at least [argument]"@en ;
sh:message "Minimum must be a literal"@en ;
sh:templateFilter "( COALESCE(?this >= [argument],false) )" .
sh:minExclusive a sh:ComponentTemplate ;
sh:templateMessage "Too small, must be greater than [argument]"@en ;
sh:message "Minimum must be a literal"@en ;
sh:templateFilter "( COALESCE(?this > [argument],false) )" .
sh:maxInclusive a sh:ComponentTemplate ;
sh:templateMessage "Too big, must be at most [argument]"@en ;
sh:message "Minimum must be a literal"@en ;
sh:templateFilter "( COALESCE(?this <= [argument],false) )" .
sh:maxExclusive a sh:ComponentTemplate ;
sh:templateMessage "Too big, must be less than [argument]"@en ;
sh:message "Minimum must be a literal"@en ;
sh:templateFilter "( COALESCE(?this < [argument],false) )" .
sh:nodeKind a sh:ComponentTemplate ;
sh:templateMessage "Not of correct kind [argument]"@en ;
sh:message "Has to be sh:BlankNode, sh:IRI, or sh:Literal"@en ;
sh:templateFilter
"""((isIRI(?this) && [argument] IN (sh:IRI, sh:BlankNodeOrIRI, sh:IRIOrLiteral) ) ||
(isLiteral(?this) && [argument] IN ( sh:Literal, sh:BlankNodeOrLiteral, sh:IRIOrLiteral)) ||
(isBlank(?this) && [argument] IN ( sh:BlankNode, sh:BlankNodeOrLiteral, sh:BlankNodeOrLiteral)))""" .
sh:pattern a sh:ComponentTemplate ;
sh:propValues ( rdf:first [ a sh:Shape ; sh:argumentName "pattern" ] ) ;
sh:propValues ( ( rdf:rest rdf:first ) [ a sh:Shape ; sh:argumentName "flags" ;
sh:defaultValue "" ] ) ;
sh:templateMessage "Does not match pattern"@en ;
sh:message "Has to be a string or a list of two strings"@en ;
sh:templateFilter """( !isBlank(?this) &&
( ( ([pattern] = "") && REGEX(STR(?this),[argument],"") ) ||
( ([pattern] != "") && REGEX(STR(?this),[pattern],[flags]) ) ) )""" .
sh:equals a sh:ComponentTemplate ;
sh:propValues (rdf:first [ a sh:Shape ; sh:argumentName "path1" ] ) ;
sh:propValues ((rdf:rest rdf:first) [ a sh:Shape ; sh:argumentName "path2"]);
sh:templateMessage "Path values not equal"@en ;
sh:message "Not list of two paths"@en ;
sh:templatePattern
"""{ { { ?this [p(path1)] ?value } MINUS { ?this [p(path2)] ?value }
} UNION {
{ ?this [p(path2)] ?value } MINUS { ?this [p(path1)] ?value } } }""" .
sh:disjoint a sh:ComponentTemplate ;
sh:propValues (rdf:first [ a sh:Shape ; sh:argumentName "path1" ] ) ;
sh:propValues ((rdf:rest rdf:first) [ a sh:Shape ; sh:argumentName "path2"]);
sh:templateMessage "Path values not disjoint"@en ;
sh:message "Not list of two paths"@en ;
sh:templatePattern """?this [p(path1)] ?value1 . ?this [p(path2)] ?value1 .""" .
sh:lessThan a sh:ComponentTemplate ;
sh:propValues (rdf:first [ a sh:Shape ; sh:argumentName "path1" ] ) ;
sh:propValues ((rdf:rest rdf:first) [ a sh:Shape ; sh:argumentName "path2"]);
sh:templateMessage "First path value too big"@en ;
sh:message "Not list of two paths"@en ;
sh:templatePattern """?this [p(path1)] ?value1 . ?this [p(path2)] ?value2 .
FILTER ( ! (?value1 < ?value2) )""" .
sh:lessThanOrEquals a sh:ComponentTemplate ;
sh:propValues (rdf:first [ a sh:Shape ; sh:argumentName "path1" ] ) ;
sh:propValues ((rdf:rest rdf:first) [ a sh:Shape ; sh:argumentName "path2"]);
sh:templateMessage "First path value too big"@en ;
sh:message "Not list of two paths"@en ;
sh:templatePattern """?this [p(path1)] ?value1 . ?this [p(path2)] ?value2 .
FILTER ( ! (?value1 <= ?value2) )""" .
sh:hasValue a sh:ComponentTemplate ;
sh:templateMessage "Missing required value "@en ;
sh:message "Value can be anything"@en ;
sh:templateQuery """SELECT [projection] ([component] AS ?component) ([PS] AS ?PS)
( CONCAT([message],STR([argument])) AS ?message) ( [severity] AS ?severity )
WHERE { [outer]
FILTER NOT EXISTS { [inner] FILTER sameTerm(?this,[argument]) } }""".
sh:uniqueLang a sh:ComponentTemplate ;
sh:templateMessage "Values share a language tag"@en ;
sh:message "Argument can only be true"@en ;
sh:templateQuery """SELECT [projection] ([PS] AS ?PS) ?severity ([component] AS ?component) ?message
WHERE { [outer] [inner]
{ FILTER ( sameTerm(true,[argument]) ) } # in case validation was not done
BIND (lang(?this) AS ?lang)
FILTER (isLiteral(?this) && bound(?lang) && ?lang != "") }
GROUP BY [projection] ?lang HAVING ( COUNT(?this) > 1 )
VALUES (?message ?severity) { ( [message] [severity] ) }""" .
sh:minCount a sh:ComponentTemplate ;
sh:templateMessage "Too few values, need at least [argument]"@en ;
sh:message "Minimum count must be non-negative integer"@en ;
sh:templateQuery """SELECT [projection] ([PS] AS ?PS) ([severity] AS ?severity) ([component] AS ?component) ([message] AS ?message)
WHERE { [outer] OPTIONAL { [inner] } }
[group] HAVING ( COUNT (DISTINCT ?this) < [argument] )
VALUES (?message ?severity) { ( [message] [severity] ) }""" .
sh:maxCount a sh:ComponentTemplate ;
sh:templateMessage "Too many values, want at most [argument]"@en ;
sh:message "Maximum count must be non-negative integer"@en ;
sh:templateQuery """SELECT [projection] ([PS] AS ?PS) ([severity] AS ?severity) ([component] AS ?component) ([message] AS ?message)
WHERE { [outer] OPTIONAL { [inner] } }
[group] HAVING ( COUNT (DISTINCT ?this) > [argument] )
VALUES (?message ?severity) { ( [message] [severity] ) }""" .
sh:closed a sh:ComponentTemplate ;
sh:templateMessage "Value found for disallowed property"@en ;
sh:message "Closed properties need to be IRIs"@en ;
sh:templateFilter """( ! EXISTS { ?this !([l(p(argument) "|")]) ?value } )""" .
sh:list a sh:ComponentTemplate ;
sh:templateMessage "For list element"@en ;
sh:message "Argument must be a shape"@en ;
sh:templateQuery """# LIST
SELECT [projection] ?this ?subject ?predicate ?object
?PS ?CS ([severity] AS ?severity) ([component] AS ?component) ?message
WHERE { [outer] [inner]
{ FILTER NOT EXISTS { ?this rdf:rest* rdf:nil .}
BIND ( "List does not terminate at rdf:nil" AS ?message )
BIND ( ?this AS ?subject )
BIND ([PS] AS ?PS)
} UNION {
?this rdf:rest* ?tail .
FILTER ( ( EXISTS { ?tail rdf:rest ?tail1 . ?tail rdf:rest ?tail2 .
FILTER ( ! sameTerm(?tail1,?tail2) ) } ) ||
( EXISTS { ?tail rdf:first ?elem1 . ?tail rdf:first ?elem2 .
FILTER ( ! sameTerm(?elem1,?elem2) ) } ) )
BIND ( "List has multiple firsts or rests" AS ?message )
BIND ( ?this AS ?subject )
BIND ( ?tail AS ?object )
BIND ([PS] AS ?PS)
} UNION {
FILTER EXISTS { rdf:nil rdf:rest|rdf:first ?x }
BIND ( "rdf:nil has rdf:first or rdf:rest" AS ?message )
BIND ( ?this AS ?subject )
BIND ([PS] AS ?PS)
} UNION { [c("rdf:rest*/rdf:first" argument)]
} } # END LIST
""" .
sh:shape a sh:ComponentTemplate ;
sh:templateMessage "Shape violation"@en ;
sh:message "Shapes must not be literals"@en ;
sh:templateQuery """ SELECT [projection] ?this ?subject ?property ?object #SHAPE
?PS ?CS ?severity ([component] AS ?component) ?message
WHERE { [s(argument)] }""" .
sh:not a sh:ComponentTemplate ;
sh:templateMessage "Fails to validate against negated shape"@en ;
sh:message "Shapes must not be literals"@en ;
sh:templateQuery """SELECT [projection] ?this ?subject ?property ?object #NOT
([PS] AS ?PS) ?CS ?severity ([component] as ?component) ?message
WHERE { { [outer] [inner]
} MINUS {
{ SELECT [projection] ?this ?PS
WHERE { { [s(argument)] } FILTER ( ?severity = sh:Violation ) } } } }
VALUES (?message ?severity) { ( [message] [severity] ) }""" .
sh:and a sh:ComponentTemplate ;
sh:templateMessage "AND"@en ;
sh:message "Shapes must not be literals"@en ;
sh:templateQuery """SELECT [projection] ?this ?subject ?property ?object #AND
?PS ?CS ?severity ([component] AS ?component) ?message
WHERE { { [l(s(argument) " } UNION { ")] } }""" .
sh:or a sh:ComponentTemplate ;
sh:templateMessage "OR Failure"@en ;
sh:message "Shapes must not be literals"@en ;
sh:templateQuery """SELECT [projection] ?this ?subject ?property ?object
?PS ?CS ([severity] AS ?severity) ([component] AS ?component) ([message] AS ?message)
WHERE {
{ SELECT [projection] ?this WHERE { VALUES ( ?this ) { ( UNDEF ) } } }
{ SELECT [projection] ?this WHERE {
[l(s(argument) "} } { SELECT [projection] ?this WHERE {")]
} } }""" .
sh:propValues a sh:ComponentTemplate ;
sh:propValues ( rdf:first [ a sh:Shape ; sh:argumentName "path" ] ) ;
sh:propValues ( ( rdf:rest rdf:first ) [ a sh:Shape ; sh:argumentName "shape" ] ) ;
sh:templateMessage "In path [p(path)]"@en ;
sh:message "Argument is path, shape list"@en ;
sh:templateQuery """[c(p(path) shape)]""" .
# sh:partition not possible because partition tears shapes apart
sh:query a sh:ComponentTemplate ;
sh:templateMessage "Query component failure"@en ;
sh:message "Queries need to be strings"@en ;
sh:templateQuery """[argument]""" .
# PART 5: Compatability Constructs and Their Implementation (incomplete)
sh:property a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdf:List ;
sh:list [ a sh:Shape ; sh:nodeKind sh:IRI ] .
shmm:propertyShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:property sh:property ) .
sh:property a sh:ComponentTemplate ;
sh:propValues ( sh:predicate [ a sh:Shape ; sh:nodeKind sh:IRI ;
sh:argumentName "path" ] ) ;
sh:templateMessage "In path [p(path)]"@en ;
sh:message "Argument is shape containing sh:predicate as property"@en ;
sh:templateQuery """[c(p(path) shape)]""" .
sh:inverseProperty a rdf:Property ; a sh:Shape ; rdfs:domain sh:Shape ; rdfs:range rdf:List ;
sh:list [ a sh:Shape ; sh:nodeKind sh:IRI ] .
shmm:inversePropertyShape a sh:Shape ; sh:scopeClass sh:Shape ;
sh:propValues ( sh:inverseProperty sh:inverseProperty ) .
sh:inverseProperty a sh:ComponentTemplate ;
sh:propValues ( sh:predicate [ a sh:Shape ; sh:nodeKind sh:IRI ;
sh:argumentName "path" ] ) ;
sh:templateMessage "In path [p(path)]"@en ;
sh:message "Argument is shape containing sh:predicate as property"@en ;
sh:templateQuery """[c(^p(path) shape)]""" . ## DOES THIS WORK??