-
Notifications
You must be signed in to change notification settings - Fork 2
/
bookHtml011.html
3635 lines (3577 loc) · 751 KB
/
bookHtml011.html
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
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="hevea 2.23">
<link rel="stylesheet" type="text/css" href="book.css"><link rel="stylesheet" type="text/css" href="bookHtml.css">
<title>SHACL</title>
</head>
<body>
<a href="bookHtml010.html"><img src="previous_motif.gif" alt="Previous"></a>
<a href="index.html"><img src="contents_motif.gif" alt="Up"></a>
<a href="bookHtml012.html"><img src="next_motif.gif" alt="Next"></a>
<hr>
<header>
<a href="http://book.validatingrdf.com">Validating RDF data</a>
<img src="cover.jpg"></img>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-112019120-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-112019120-1');
</script>
</header>
<h1 class="chapter" id="sec122">Chapter 5 SHACL</h1>
<p>
<a id="hevea_default463"></a>
<a id="ch5"></a>
<a id="ch050SHACL"></a>
</p><p><a id="hevea_default464"></a>
Shapes Constraint Language (SHACL) has been developed by the W3C RDF Data Shapes Working Group,
which was chartered in 2014 with the goal to
“produce a language for defining structural constraints on RDF graphs [<a href="bookHtml018.html#SHACLCharter">6</a>].” </p><p><a id="hevea_default465"></a>
The first public working draft was published in October 2015 and it was proposed as a W3C Recommendation in June 2017.<sup><a id="text14" href="#note14">1</a></sup></p><p><a id="hevea_default466"></a> <a id="hevea_default467"></a> <a id="hevea_default468"></a>
SHACL was influenced by SPIN, and some parts from OSLC resource shapes and ShEx.
At the beginning of the Working Group activity it was considered that SHACL was going to be
an integration of all the validation approaches into a unified language.
However, due to core differences, SHACL and ShEx did not converge.
Chapter <a href="bookHtml013.html#ch070Comparing">7</a> contains a comparison of both languages and
describes the main differences. </p><p><a id="hevea_default469"></a> <a id="hevea_default470"></a>
SHACL is divided in two parts.
The first part, called SHACL Core, describes a core RDF vocabulary to define common shapes and constraints while
the second part describes an extension mechanism in terms of SPARQL and has been called: SHACL-SPARQL. </p><p>Two working group notes have been published to extend SHACL with
(a) advanced features such as rules and complex expressions<sup><a id="text15" href="#note15">2</a></sup> and
(b) to enable the definition of constraint components in Javascript (called SHACL-Javascript).<sup><a id="text16" href="#note16">3</a></sup></p><p><a id="hevea_default471"></a>
A W3C SHACL community group<sup><a id="text17" href="#note17">4</a></sup> has been created to continue working on SHACL preparing educational contents and
supporting SHACL adoption.
A working group note was also suggested for a SHACL Compact
Syntax<sup><a id="text18" href="#note18">5</a></sup>
but it was decided to postpone it for the W3C community group.</p>
<h2 class="section" id="sec123">5.1 Simple Example</h2>
<p>
<a id="ch5.sec1"></a></p><p><a id="hevea_default472"></a>
SHACL groups the information and constraints that apply to data nodes into some constructs called shapes.
<a id="hevea_default473"></a>
SHACL shapes differ from ShEx shapes in the sense that they also contain information about the target nodes or set of nodes to which they can be applied.</p><p><a id="hevea_default474"></a>
<a id="hevea_default475"></a>
<a id="hevea_default476"></a>
The syntax of SHACL is defined in terms of RDF so we will use Turtle in this book although it is possible to employ other RDF serialization formats such as JSON-LD or
RDF/XML. </p><div class="example"><div class="theorem"><span class="c013">Example 94</span> <em>UserShape example in SHACL</em><em> </em><a id="ch050SHACLExample"></a><p><em>The following example is similar to the ShEx definition in
Example </em><a href="bookHtml010.html#ch040%3AShExSimpleExample"><em>26</em></a><em>.</em><sup><a id="text19" href="#note19"><em>6</em></a></sup><em>
</em><a id="hevea_default477"></a><em>
It defines a shape </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> of type </em><em>
</em><code><em><span class="c004">sh</span></em></code><code><em>:</em></code><code><em><span class="c006">NodeShape</span></em></code><em>.
</em><a id="hevea_default478"></a><em>
It has target class declaration pointing to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">User</span></em></code><em> which means that it applies to all nodes that are instances of </em><em>
</em><code><em>:</em></code><code><em><span class="c006">User</span></em></code><em> (see Section </em><a href="#ch050targetClass"><em>5.7.2</em></a><em>).
The next lines declare that nodes conforming to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> must satisfy the following constraints.</em></p><ul class="itemize"></em><li class="li-itemize"><em> <em><em>They must have exactly one property </em></em><em><em>
</em></em><code><em><em><span class="c004">schema</span></em></em></code><code><em><em>:</em></em></code><code><em><em><span class="c006">name</span></em></em></code><em><em> with values of type </em></em><em><em>
</em></em><code><em><em><span class="c004">xsd</span></em></em></code><code><em><em>:</em></em></code><code><em><em><span class="c006">string</span></em></em></code><em><em> (lines 3–8).</em></em></li><li class="li-itemize"><em><em>They must have exaclty one property </em></em><em><em>
</em></em><code><em><em><span class="c004">schema</span></em></em></code><code><em><em>:</em></em></code><code><em><em><span class="c006">gender</span></em></em></code><em><em> whose value must be either
</em></em><em><em>
</em></em><code><em><em><span class="c004">schema</span></em></em></code><code><em><em>:</em></em></code><code><em><em><span class="c006">Male</span></em></em></code><em><em> or </em></em><em><em>
</em></em><code><em><em><span class="c004">schema</span></em></em></code><code><em><em>:</em></em></code><code><em><em><span class="c006">Female</span></em></em></code><em><em> or any </em></em><em><em>
</em></em><code><em><em><span class="c004">xsd</span></em></em></code><code><em><em>:</em></em></code><code><em><em><span class="c006">string</span></em></em></code><em><em> literal (lines 9–17).</em></em></li><li class="li-itemize"><em><em>They have zero or one </em></em><em><em>
</em></em><code><em><em><span class="c004">schema</span></em></em></code><code><em><em>:</em></em></code><code><em><em><span class="c006">birthDate</span></em></em></code><em><em> property whose datatype must be </em></em><em><em>
</em></em><code><em><em><span class="c004">xsd</span></em></em></code><code><em><em>:</em></em></code><code><em><em><span class="c006">date</span></em></em></code><em><em> (lines 18–22).</em></em></li><li class="li-itemize"><em><em>They have zero or more </em></em><em><em>
</em></em><code><em><em><span class="c004">schema</span></em></em></code><code><em><em>:</em></em></code><code><em><em><span class="c006">knows</span></em></em></code><em><em> properties whose nodes must be IRIs and have type </em></em><em><em>
</em></em><code><em><em>:</em></em></code><code><em><em><span class="c006">User</span></em></em></code><em><em> (lines 23–27).</em></em></li></ul><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">UserShape</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">NodeShape</span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">targetClass</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c008"><em><span class="c011"># Blank node 1</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">minCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">maxCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">datatype</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">xsd</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">string</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> ] ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c008"><em><span class="c011"># Blank node 2</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">gender</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">minCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">maxCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">or</span></span></em><em><span class="c011"> (</span></em><em><span class="c011">
</span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">in</span></span></em><em><span class="c011"> (</span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Male</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Female</span></span></em><em><span class="c011">) ]</span></em><em><span class="c011">
</span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">datatype</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">xsd</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">string</span></span></em><em><span class="c011">]</span></em><em><span class="c011">
</span></em><em><span class="c011"> )</span></em><em><span class="c011">
</span></em><em><span class="c011"> ] ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c008"><em><span class="c011"># Blank node 3 </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">birthDate</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">maxCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">datatype</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">xsd</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">date</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> ] ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c008"><em><span class="c011"># Blank node 4 </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">knows</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">nodeKind</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">IRI</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">class</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> ] .</span></em></td></tr>
</table></div></div><p>SHACL defines shapes as a conjunction of constraints that nodes must satisfy.
A SHACL processor checks each of the constraints and returns validation errors for every constraint that is not satisfied.</p><p>When no error is reported, it is assumed that the RDF graph has been validated. </p><div class="example"><div class="theorem"><span class="c013">Example 95</span> <em>RDF graph conforming to Example </em><a href="#ch050SHACLExample"><em>94</em></a><em>
</em><a id="ch050GoodRDFGraph"></a><p><em>The following RDF data graph conforms to the previous example: </em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">alice</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011">; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Alice"</span></em></span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">gender</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Female</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">knows</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">bob</span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">bob</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011">; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">gender</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Male</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Robert"</span></em></span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">birthDate</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"1980-03-10"</span></em></span></span></em><em><span class="c011">^^</span></em><em><span class="c011"><span class="c004">xsd</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">date</span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">carol</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011">; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Carol"</span></em></span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">gender</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Female</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">foaf</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Carol"</span></em></span></span></em><em><span class="c011"> .</span></em></td></tr>
</table><p><em>When an RDF graph conforms to a shapes graph, SHACL processors return a validation report with no errors.
The validation report contains the declaration:</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">[ </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">ValidationReport</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">conforms</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">true</span></span></em><em><span class="c011">
</span></em><em><span class="c011">].</span></em></td></tr>
</table></div></div><div class="example"><div class="theorem"><span class="c013">Example 96</span> <em>Example of non conforming RDF graph</em><em>
</em><a id="ch050SHACLBadDataGraph"></a><p><a id="hevea_default479"></a><em>
The following RDF graph does not conform to the shapes graph declared in
Example </em><a href="#ch050SHACLExample"><em>94</em></a><em>.</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">dave</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Dave"</span></em></span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">gender</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">Unknown</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">birthDate</span></span></em><em><span class="c011"> 1980 ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">knows</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">grace</span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">emily</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Emily"</span></em></span></span></em><em><span class="c011">, </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Emilee"</span></em></span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">gender</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Female</span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">frank</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">foaf</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Frank"</span></em></span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">gender</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Male</span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011"><span class="c006">_</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">x</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011">; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Unknown"</span></em></span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">gender</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Male</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">knows</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c006">_</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">x</span></span></em><em><span class="c011"> .</span></em></td></tr>
</table><p><em>A SHACL processor reports the following errors.</em></p><ul class="itemize"><li class="li-itemize"><em>
</em><code><em>:</em></code><code><em><span class="c006">dave</span></em></code><em> has value different from </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">Male</span></em></code><em>, </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">Female</span></em></code><em> or string for property </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">gender</span></em></code><em> (the allowed values).</em></li><li class="li-itemize"><em>
</em><code><em>:</em></code><code><em><span class="c006">dave</span></em></code><em> has value </em><em>
</em><code><em>1980</em></code><em> for property </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">birthDate</span></em></code><em> which is of datatype integer when it should be of datatype </em><em>
</em><code><em><span class="c004">xsd</span></em></code><code><em>:</em></code><code><em><span class="c006">date</span></em></code><em>.</em></li><li class="li-itemize"><em>
</em><code><em>:</em></code><code><em><span class="c006">dave</span></em></code><em> has value </em><em>
</em><code><em>:</em></code><code><em><span class="c006">grace</span></em></code><em> for property </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">knows</span></em></code><em> which is not an instance of </em><em>
</em><code><em>:</em></code><code><em><span class="c006">User</span></em></code><em>.</em></li><li class="li-itemize"><em>
</em><code><em>:</em></code><code><em><span class="c006">emily</span></em></code><em> has 2 values for property </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">name</span></em></code><em> when the maximum count is 1.</em></li><li class="li-itemize"><em>
</em><code><em>:</em></code><code><em><span class="c006">frank</span></em></code><em> does not have value for property </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">name</span></em></code><em>.</em></li><li class="li-itemize"><em>
</em><code><em><span class="c006">_</span></em></code><code><em>:</em></code><code><em><span class="c006">x</span></em></code><em> fails because the value of </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">knows</span></em></code><em> is a blank node and must be an IRI.
</em></li></ul></div></div><p>When an RDF graph does not conform to a shapes graph, SHACL processors return a validation report that contains several errors.
Section <a href="#ch050ValidationReport">5.5</a> describes the validation report structure.</p>
<h2 class="section" id="sec124">5.2 SHACL Implementations</h2>
<p> <a id="ch05SHACLImplementations"></a>
<a id="ch5.sec2"></a></p><p>At the time of this writing, there are several implementations of SHACL.</p><ul class="itemize"><li class="li-itemize"><p><a id="hevea_default480"></a>
<a id="hevea_default481"></a>
<a id="hevea_default482"></a>
<a id="hevea_default483"></a>
<a id="hevea_default484"></a>
<a id="hevea_default485"></a>
</p>TopQuadrant has an open source implementation in Java
(using the Apache Jena Library) called TopBraid SHACL API<sup><a id="text20" href="#note20">7</a></sup>.
<a id="hevea_default486"></a> <a id="hevea_default487"></a>
It implements SHACL Core, SHACL-SPARQL, and SHACL rules (see <a href="#ch5.sec19">5.19</a>) and
also offers a command line tool.
TopQuadrant is the company behind TopBraid Composer, which is a commercial interactive development environment for semantic web and linked data applications.
TopBraid Composer (including the free edition) includes a version of the API for RDF validation. <p><a id="hevea_default488"></a> <a id="hevea_default489"></a>
</p></li><li class="li-itemize">SHACL Playground,<sup><a id="text21" href="#note21">8</a></sup> an online SHACL demo implemented in Javascript by TopQuadrant.<p><a id="hevea_default490"></a>
</p></li><li class="li-itemize">SHACLex<sup><a id="text22" href="#note22">9</a></sup> implements SHACL Core (it also implements ShEx).
It has been written in Scala based on a simple and generic RDF Library
(currently it works on top of Apache Jena library but there are plans to use other libraries).
SHACLex can be used to deploy an online validator service and an online demo is deployed in Heroku.<sup><a id="text23" href="#note23">10</a></sup>
<p><a id="hevea_default491"></a> <a id="hevea_default492"></a> <a id="hevea_default493"></a>
</p></li><li class="li-itemize">Corese STTL SHACL validator. Implemented by Olivier Corby.
It is an implementation of SHACL Core using STTL (SPARQL Template Transformation language), which is a generic transformation language for
RDF.<sup><a id="text24" href="#note24">11</a></sup>
STTL is itself implemented in Java.
An online demo of the validator is also available.<sup><a id="text25" href="#note25">12</a></sup> <p><a id="hevea_default494"></a> <a id="hevea_default495"></a>
</p></li><li class="li-itemize">Netage SHACL Engine<sup><a id="text26" href="#note26">13</a></sup> implemented in Java (using the Jena Library) by Nicky van Oorschot.
It has support for SHACL-SPARQL.<p><a id="hevea_default496"></a>
</p></li><li class="li-itemize">SHACL-Check a prototype implemented by Tim Berners-Lee to check the
specification.<sup><a id="text27" href="#note27">14</a></sup><p><a id="hevea_default497"></a>
</p></li><li class="li-itemize">RDFUnit.<sup><a id="text28" href="#note28">15</a></sup>
A test driven data-debugging framework that runs test cases against RDF data and records any violations in structured form.
Besides its SPARQL-based constraint definition language, RDFUnit supports rule translation from multiple formats i.e. OWL under closed world semantics, OSLC and DSP.
At the time of this writing, RDFUnit supports a very big part of SHACL-Core and SHACL-SPARQL<sup><a id="text29" href="#note29">16</a></sup>.
One of the future plans for RDFUnit is to support ShEx through the SHACLex implementation.<p><a id="hevea_default498"></a>
</p></li><li class="li-itemize">Alternative SHACL implementation, by Peter F. Patel-Schneider in
Python.<sup><a id="text30" href="#note30">17</a></sup> <p><a id="hevea_default499"></a>
</p></li><li class="li-itemize">ELI Validator, by the ELI (European Legislation Identifier) Initiative<sup><a id="text31" href="#note31">18</a></sup> which is
based on the TopBraid SHACL API.</li><li class="li-itemize">SHACL for rdf4j<sup><a id="text32" href="#note32">19</a></sup> (formerly Sesame) developed as a Google Summer of Code
2017 project.</li></ul>
<h2 class="section" id="sec125">5.3 Basic Definitions: Shapes Graphs, Node, and Property Shapes</h2>
<p>
<a id="ch5.sec3"></a></p><p><a id="hevea_default500"></a> <a id="hevea_default501"></a>
A SHACL processor has two inputs: a data graph that contains the RDF data to validate and a shapes graph that contains the shapes.
Example <a href="#ch050SHACLExample">94</a> contains a shapes graph and
Examples <a href="#ch050GoodRDFGraph">95</a> and <a href="#ch050SHACLBadDataGraph">96</a> contain two possible RDF data graphs.
It is possible to use a single graph that contains both the data and shapes graph merged.</p><p><a id="hevea_default502"></a> <a id="hevea_default503"></a>
There are two main types of shapes: node shapes and property shapes.
Node shapes declare constraints directly on a node.
Property shapes declare constraints on the values associated with a node through a path. </p><p><a id="hevea_default504"></a>
Property shapes have a property
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">path</span></code> that declares the path that goes from the focus node to the value that they describe.
The most frequent paths are predicate paths which are formed by a single IRI. </p><p>A node shape usually contains several property shapes which are declared through the
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">property</span></code> predicate. </p><p>Example <a href="#ch050SHACLExample">94</a> contained four such property shape declarations.
The first one was defined as:</p><table class="lstframe c014"><tr><td class="lstlisting"><span class="c011">:</span><span class="c011"><span class="c006">UserShape</span></span><span class="c011"> ...</span><span class="c011">
</span><span class="c011"> </span><span class="c011"><span class="c004">sh</span></span><span class="c011">:</span><span class="c011"><span class="c006">property</span></span><span class="c011"> [ </span><span class="c011"><span class="c008"><span class="c011"># Blank node 1</span></span></span><span class="c011">
</span><span class="c011"> </span><span class="c011"><span class="c004">sh</span></span><span class="c011">:</span><span class="c011"><span class="c006">path</span></span><span class="c011"> </span><span class="c011"><span class="c004">schema</span></span><span class="c011">:</span><span class="c011"><span class="c006">name</span></span><span class="c011"> ;</span><span class="c011">
</span><span class="c011"> </span><span class="c011"><span class="c004">sh</span></span><span class="c011">:</span><span class="c011"><span class="c006">minCount</span></span><span class="c011"> 1;</span><span class="c011">
</span><span class="c011"> </span><span class="c011"><span class="c004">sh</span></span><span class="c011">:</span><span class="c011"><span class="c006">maxCount</span></span><span class="c011"> 1;</span><span class="c011">
</span><span class="c011"> </span><span class="c011"><span class="c004">sh</span></span><span class="c011">:</span><span class="c011"><span class="c006">datatype</span></span><span class="c011"> </span><span class="c011"><span class="c004">xsd</span></span><span class="c011">:</span><span class="c011"><span class="c006">string</span></span><span class="c011"> ;</span><span class="c011">
</span><span class="c011"> ] ;</span><span class="c011">
</span><span class="c011"> ...</span></td></tr>
</table><p>Which means that nodes that conform to
<code>:</code><code><span class="c006">UserShape</span></code> must also conform to the property shape identified by blank node 1.
The path of that property shape (line 3) is the predicate
<code><span class="c004">schema</span></code><code>:</code><code><span class="c006">name</span></code> which is, in this case, a single IRI.
The property shape contains several components that declare that there can be a minimum and a maximum of one values that can be accessed through that path (lines 4 and 5)
and that they must belong to the
<code><span class="c004">xsd</span></code><code>:</code><code><span class="c006">string</span></code> datatype (line 6).</p><p>Notice that in Example <a href="#ch050SHACLExample">94</a> we used blank nodes for property shapes and enumerated them from 1–4 because we will refer to them when we describe the validation report in next section.
<a id="hevea_default505"></a>
Although using blank nodes may be more readable, sometimes, it may be better to declare an IRI for the property shapes so they can be referenced from other shapes graphs when they are imported (see the next section).</p><div class="example"><div class="theorem"><span class="c013">Example 97</span> <em>Declaring IRIs for property shapes</em><p><em>Example </em><a href="#ch050SHACLExample"><em>94</em></a><em> could be rewritten as:</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">UserShape</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">NodeShape</span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">targetClass</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">nodeKind</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">IRI</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">HasEmail</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">HasGender</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">MaybeBirthDate</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">KnowsUsers</span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">HasEmail</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">minCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">maxCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">datatype</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">xsd</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">string</span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">HasGender</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">gender</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">minCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">maxCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">or</span></span></em><em><span class="c011"> (</span></em><em><span class="c011">
</span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">in</span></span></em><em><span class="c011"> (</span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Male</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Female</span></span></em><em><span class="c011">) ]</span></em><em><span class="c011">
</span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">datatype</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">xsd</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">string</span></span></em><em><span class="c011">]</span></em><em><span class="c011">
</span></em><em><span class="c011"> ) .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">MaybeBirthDate</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">birthDate</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">maxCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">datatype</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">xsd</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">date</span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">KnowsUsers</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">knows</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">class</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> .</span></em></td></tr>
</table></div></div>
<h2 class="section" id="sec126">5.4 Importing other Shapes Graphs</h2>
<p>
<a id="ch050ImportingShapes"></a>
<a id="ch5.sec4"></a></p><p><a id="hevea_default506"></a>
<a id="hevea_default507"></a>
A shapes graph contains shapes definitions that will be passed to the SHACL validation process.
Shapes graphs can be reusable modules that can be referenced by other shapes graphs with the predicate
<code><span class="c004">owl</span></code><code>:</code><code><span class="c006">imports</span></code>.
As a pre-validation step, SHACL processors should extend the original shapes graph by following and importing all referenced shapes graphs through
<code><span class="c004">owl</span></code><code>:</code><code><span class="c006">imports</span></code> declarations.
The resulting graph will be the input shapes graph that will be used for validation. </p><div class="example"><div class="theorem"><span class="c013">Example 98</span> <em>Importing shapes graphs</em><em>
</em><a id="ch050ImportingShapesGraphs"></a><p><em>If we assume that Example </em><a href="#ch050SHACLExample"><em>94</em></a><em> is available at
IRI </em><code><em>http://example.org/UserShapes</em></code><em>, then, the following shapes graph imports its shapes and uses them to declare that nodes that conform to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">TeacherShape</span></em></code><em> must also conform to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> (line 5) and have the predicate </em><em>
</em><code><em>:</em></code><code><em><span class="c006">teaches</span></em></code><em> with a value of datatype </em><em>
</em><code><em><span class="c004">xsd</span></em></code><code><em>:</em></code><code><em><span class="c006">string</span></em></code><em>.</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011"><span class="c008"><em><span class="c011"><></span></em></span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">owl</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">imports</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c008"><em><span class="c011"><http://example.org/UserShapes></span></em></span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">TeacherShape</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">NodeShape</span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">targetClass</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">Teacher</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">node</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">UserShape</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> [</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">teaches</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">minCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">datatype</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">xsd</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">string</span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> ]</span></em><em><span class="c011">
</span></em><em><span class="c011">.</span></em></td></tr>
</table><p><em>Given the following data:</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">alice</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">Teacher</span></span></em><em><span class="c011">; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :TeacherShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Alice"</span></em></span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">gender</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Female</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">knows</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">bob</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">teaches</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Algebra"</span></em></span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">bob</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">gender</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Male</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Robert"</span></em></span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">carol</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">Teacher</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :TeacherShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">gender</span></span></em><em><span class="c011"> 23 ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">teaches</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Logic"</span></em></span></span></em><em><span class="c011"> .</span></em></td></tr>
</table><p><em>A SHACL processor validates that </em><em>
</em><code><em>:</em></code><code><em><span class="c006">alice</span></em></code><em> conforms to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">TeacherShape</span></em></code><em>, and </em><em>
</em><code><em>:</em></code><code><em><span class="c006">bob</span></em></code><em> to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> but reports that </em><em>
</em><code><em>:</em></code><code><em><span class="c006">carol</span></em></code><em> does not conform to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">TeacherShape</span></em></code><em>.</em></p></div></div><p><a id="hevea_default508"></a>
</p>
<h2 class="section" id="sec127">5.5 Validation Report</h2>
<p>
<a id="ch050ValidationReport"></a>
<a id="ch5.sec5"></a></p><p>As we said, SHACL processors take as input a data graph and a shapes graph and return a validation report. </p><p>The validation report is defined as an RDF graph with the following structure.
If the data graph conforms to the shapes graph, the report contains a
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">conforms</span></code> declaration with the value
<code><span class="c003">true</span></code>:</p><p><a id="hevea_default509"></a>
</p><table class="lstframe c014"><tr><td class="lstlisting"><span class="c011">:</span><span class="c011"><span class="c006">report</span></span><span class="c011"> </span><span class="c011"><span class="c003">a</span></span><span class="c011"> </span><span class="c011"><span class="c004">sh</span></span><span class="c011">:</span><span class="c011"><span class="c006">ValidationReport</span></span><span class="c011"> ;</span><span class="c011">
</span><span class="c011"> </span><span class="c011"><span class="c004">sh</span></span><span class="c011">:</span><span class="c011"><span class="c006">conforms</span></span><span class="c011"> </span><span class="c011"><span class="c003">true</span></span><span class="c011"> .</span></td></tr>
</table><p><a id="hevea_default510"></a>
<a id="hevea_default511"></a>
<a id="hevea_default512"></a>
If the data graph does not conform to the shapes graph, the validation report will have a value
<code><span class="c003">false</span></code> for the property
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">conforms</span></code> and a set of validation errors of type
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">ValidationResult</span></code> linked by the property
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">result</span></code>. </p><p><a id="hevea_default513"></a>
Each validation result contains metadata about the cause of the error such as
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">focusNode</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">value</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">resultPath</span></code>, etc.
Table <a href="#ch050.ValidationReportProperties">5.1</a> describes the properties of validation results.</p><p><a id="hevea_default514"></a>
<a id="hevea_default515"></a>
<a id="hevea_default516"></a>
<a id="hevea_default517"></a>
<a id="hevea_default518"></a>
<a id="hevea_default519"></a>
<a id="hevea_default520"></a>
<a id="hevea_default521"></a></p><blockquote class="table"><div class="center"><hr class="c021"></div>
<div class="caption"><table class="c002 cellpading0"><tr><td class="c018">Table 5.1: SHACL validation result properties</td></tr>
</table></div>
<a id="ch050.ValidationReportProperties"></a>
<div class="center">
<table class="c000 cellpadding1" border=1><tr><td class="c017"> <span class="c013">Property</span></td><td class="c019"><span class="c013">Description
</span></td></tr>
<tr><td class="c017">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">focusNode</span></code></td><td class="c019">The focus node that was being validated when the error happened
</td></tr>
<tr><td class="c017">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">resultPath</span></code></td><td class="c019">The path from the focus node. This property is optional usually corresponds to the
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">path</span></code> declaration of property shapes
</td></tr>
<tr><td class="c017">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">value</span></code></td><td class="c019">The value that violated the constraint, when available
</td></tr>
<tr><td class="c017">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">sourceShape</span></code></td><td class="c019">The shape that the focus node was validated against when the constraint was violated.
</td></tr>
<tr><td class="c017">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">sourceConstraintComponent</span></code></td><td class="c019">The IRI that identifies the component that caused the violation.
</td></tr>
<tr><td class="c017">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">detail</span></code></td><td class="c019">May point to further details about the cause of the error.
This property can be used for reporting errors in nested nested shapes.
</td></tr>
<tr><td class="c017">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">resultMessage</span></code></td><td class="c019">Textual details about the error. This message can be affected by the
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">message</span></code> property (see section <a href="#ch050shMessage">5.6.4</a>)
</td></tr>
<tr><td class="c017">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">resultSeverity</span></code></td><td class="c019">A value which is equal to the
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">severity</span></code> value of the shape that caused the violation error. If the shape doesn’t have
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">severity</span></code> declaration then the default value will be
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">Violation</span></code>.</td></tr>
</table>
</div>
<div class="center"><hr class="c021"></div></blockquote><div class="example"><div class="theorem"><span class="c013">Example 99</span> <p><em>The validation report generated by a SHACL processor when trying to validate the shapes graph in Example </em><a href="#ch050SHACLExample"><em>94</em></a><em> with
the data graph from Example </em><a href="#ch050SHACLBadDataGraph"><em>96</em></a><em> could be:</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">report</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">ValidationReport</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">conforms</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">false</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">result</span></span></em><em><span class="c011">
</span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">ValidationResult</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultSeverity</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Violation</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceConstraintComponent</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">InConstraintComponent</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceShape</span></span></em><em><span class="c011"> ... ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011"># blank node 2</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">focusNode</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">dave</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">value</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">Unknown</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultPath</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">gender</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultMessage</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Value has none of the shapes from the or list"</span></em></span></span></em><em><span class="c011">],</span></em><em><span class="c011">
</span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">ValidationResult</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultSeverity</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Violation</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceConstraintComponent</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">DatatypeConstraintComponent</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceShape</span></span></em><em><span class="c011"> ... ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011"># blank node 3</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">focusNode</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">dave</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">value</span></span></em><em><span class="c011"> 1980 ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultPath</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">birthDate</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultMessage</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Value does not have datatype xsd:date"</span></em></span></span></em><em><span class="c011"> ],</span></em><em><span class="c011">
</span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">ValidationResult</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultSeverity</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Violation</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceConstraintComponent</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">ClassConstraintComponent</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceShape</span></span></em><em><span class="c011"> ... ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011"># blank node 4</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">focusNode</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">dave</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">value</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">grace</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultPath</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">knows</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultMessage</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Value is not an instance of User"</span></em></span></span></em><em><span class="c011"> ],</span></em><em><span class="c011">
</span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">ValidationResult</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultSeverity</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Violation</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceConstraintComponent</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">MaxCountConstraintComponent</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceShape</span></span></em><em><span class="c011"> ... ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011"># blank node 1</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">focusNode</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">emily</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultPath</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultMessage</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"More than 1 values"</span></em></span></span></em><em><span class="c011"> ],</span></em><em><span class="c011">
</span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">ValidationResult</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultSeverity</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Violation</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceConstraintComponent</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">MinCountConstraintComponent</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceShape</span></span></em><em><span class="c011"> ...; </span></em><em><span class="c011"><span class="c008"><em><span class="c011"># blank node 1</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">focusNode</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">frank</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultPath</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultMessage</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Less than 1 values"</span></em></span></span></em><em><span class="c011"> ],</span></em><em><span class="c011">
</span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">ValidationResult</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultSeverity</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Violation</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceConstraintComponent</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">NodeKindConstraintComponent</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceShape</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">UserShape</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">focusNode</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c006">_</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">x</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">value</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c006">_</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">x</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultMessage</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Value does not have node kind sh:IRI"</span></em></span></span></em><em><span class="c011">]</span></em><em><span class="c011">
</span></em><em><span class="c011"> .</span></em></td></tr>
</table></div></div><p>Although in the rest of this chapter we will describe the different errors in natural language for simplicity,
the validation results returned by SHACL processors will have the structure above.</p>
<h2 class="section" id="sec128">5.6 Shapes</h2>
<p>
<a id="ch5.sec6"></a></p><p>There are two types of shapes in SHACL: node shapes and property shapes.
Node shapes specify constraints about a node while
property shapes specify constraints about the values that can be reached from a node by a path.</p><blockquote class="figure"><div class="center"><hr class="c021"></div>
<div class="center">
<img src="SHACL_Shapes.png">
</div>
<a id="ch050.SHACLShapes"></a>
<div class="caption"><table class="c002 cellpading0"><tr><td class="c018">Figure 5.1: Shapes in SHACL.</td></tr>
</table></div>
<div class="center"><hr class="c021"></div></blockquote><p><a id="hevea_default522"></a>
</p>
<h3 class="subsection" id="sec129">5.6.1 Node shapes</h3>
<p>
<a id="ch5.sec6.1"></a></p><p>Node shapes directly specify constraints about a focus node. </p><div class="example"><div class="theorem"><span class="c013">Example 100</span> <em>Node shape example</em><p><em>The following shapes graph declares a node shape </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em>
which applies to all nodes that are instances of </em><em>
</em><code><em>:</em></code><code><em><span class="c006">User</span></em></code><em>
and the constraint that nodes conforming to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> must be IRIs. </em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">UserShape</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">NodeShape</span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">targetClass</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">nodeKind</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">IRI</span></span></em><em><span class="c011"> .</span></em></td></tr>
</table><p><em>Given the following RDF graph: </em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">alice</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> . </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011"><span class="c008"><em><span class="c011"><http://other.uri.com/bob></span></em></span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> . </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011"><span class="c006">_</span></span></em><em><span class="c011">:1 </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> . </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape </span></em></span></span></em></td></tr>
</table><p><em>A SHACL processor checks that </em><em>
</em><code><em>:</em></code><code><em><span class="c006">alice</span></em></code><em> and </em><em>
</em><code><em><</em></code><code><em><span class="c006">http</span></em></code><code><em>://</em></code><code><em><span class="c006">other</span></em></code><code><em>.</em></code><code><em><span class="c006">uri</span></em></code><code><em>.</em></code><code><em><span class="c006">com</span></em></code><code><em>/</em></code><code><em><span class="c006">bob</span></em></code><code><em>></em></code><em> conform to shape </em><em>
</em><code><em>:</em></code><code><em><span class="c006">User</span></em></code><em> and returns the error:</em></p><ul class="itemize"><li class="li-itemize"><em>
</em><em>
</em><code><em><span class="c006">_</span></em></code><code><em>:1</em></code><em> is not an IRI
</em></li></ul></div></div><p><a id="hevea_default523"></a>
</p>
<h3 class="subsection" id="sec130">5.6.2 Property Shapes</h3>
<p>
<a id="ch5.sec6.2"></a></p><p><a id="hevea_default524"></a>
Property shapes specify constraints about the values that can be reached from a focus node by some path.
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">property</span></code> associates a shape with a property shape.</p><p>The nodes that are affected by a property shape are specified using
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">path</span></code> property
that can take as value IRIs or SHACL paths.</p><p><a id="hevea_default525"></a>
<a id="hevea_default526"></a>
SHACL paths are semantically equivalent to a subset of the SPARQL 1.1 property paths but they use an RDF encoding based on the following rules.</p><ul class="itemize"><li class="li-itemize">Direct predicates use a single IRI.<p><a id="hevea_default527"></a>
</p></li><li class="li-itemize">Inverse paths are declared by a blank node with the property
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">inversePath</span></code>.<p><a id="hevea_default528"></a>
</p></li><li class="li-itemize">Sequence paths are encoded by RDF lists whose values are SHACL paths themselves.<p><a id="hevea_default529"></a>
</p></li><li class="li-itemize">Alternative paths are declared by a blank node with the property
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">alternativePath</span></code> whose value is an RDF list with the different alternatives.<p><a id="hevea_default530"></a>
<a id="hevea_default531"></a>
<a id="hevea_default532"></a>
</p></li><li class="li-itemize">The path modifiers
<code>?</code>,
<code>*</code>, and
<code>+</code> are encoded by a blank node with the corresponding
properties
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">zeroOrOnePath</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">zeroOrMorePath</span></code> or
<code><span class="c006">oneOrMorePath</span></code>.
</li></ul><p>Table <a href="#ch050.SHACLPaths">5.2</a> presents some examples of SHACL paths and their corresponding SPARQL paths.</p><blockquote class="table"><div class="center"><hr class="c021"></div>
<div class="caption"><table class="c002 cellpading0"><tr><td class="c018">Table 5.2: SHACL and SPARQL paths</td></tr>
</table></div>
<a id="ch050.SHACLPaths"></a>
<div class="center">
<table class="c000 cellpadding1" border=1><tr><td class="c020"> <span class="c013">SHACL path</span></td><td class="c020"><span class="c013">SPARQL path
</span></td></tr>
<tr><td class="c020">
<code><span class="c004">schema</span></code><code>:</code><code><span class="c006">name</span></code></td><td class="c020">
<code><span class="c004">schema</span></code><code>:</code><code><span class="c006">name</span></code>
</td></tr>
<tr><td class="c020">
<code>[</code><code><span class="c004">sh</span></code><code>:</code><code><span class="c006">inversePath</span></code><code> </code><code><span class="c004">schema</span></code><code>:</code><code><span class="c006">knows</span></code><code>]</code></td><td class="c020">
<code>^</code><code><span class="c004">schema</span></code><code>:</code><code><span class="c006">knows</span></code>
</td></tr>
<tr><td class="c020">
<code>(</code><code><span class="c004">schema</span></code><code>:</code><code><span class="c006">knows</span></code><code> </code><code><span class="c004">schema</span></code><code>:</code><code><span class="c006">name</span></code><code>)</code></td><td class="c020">
<code><span class="c004">schema</span></code><code>:</code><code><span class="c006">knows</span></code><code>/</code><code><span class="c004">schema</span></code><code>:</code><code><span class="c006">name</span></code>
</td></tr>
<tr><td class="c020">
<code>[</code><code><span class="c004">sh</span></code><code>:</code><code><span class="c006">alternativePath</span></code><code> (</code><code><span class="c004">schema</span></code><code>:</code><code><span class="c006">knows</span></code><code> </code><code><span class="c004">schema</span></code><code>:</code><code><span class="c006">follows</span></code><code>)]</code></td><td class="c020">
<code><span class="c004">schema</span></code><code>:</code><code><span class="c006">knows</span></code>|
<code><span class="c004">schema</span></code><code>:</code><code><span class="c006">follows</span></code>
</td></tr>
<tr><td class="c020">
<code>[</code><code><span class="c004">sh</span></code><code>:</code><code><span class="c006">zeroOrOnePath</span></code><code> </code><code><span class="c004">schema</span></code><code>:</code><code><span class="c006">knows</span></code><code>]</code></td><td class="c020">
<code><span class="c004">schema</span></code><code>:</code><code><span class="c006">knows</span></code><code>?</code>
</td></tr>
<tr><td class="c020">
<code>[</code><code><span class="c004">sh</span></code><code>:</code><code><span class="c006">oneOrMorePath</span></code><code> </code><code><span class="c004">schema</span></code><code>:</code><code><span class="c006">knows</span></code><code>]</code></td><td class="c020">
<code><span class="c004">schema</span></code><code>:</code><code><span class="c006">knows</span></code><code>+</code>
</td></tr>
<tr><td class="c020">
<code>([</code><code><span class="c004">sh</span></code><code>:</code><code><span class="c006">zeroOrMorePath</span></code><code> </code><code><span class="c004">schema</span></code><code>:</code><code><span class="c006">knows</span></code><code>] </code><code><span class="c004">schema</span></code><code>:</code><code><span class="c006">name</span></code><code>)</code></td><td class="c020">
<code><span class="c004">schema</span></code><code>:</code><code><span class="c006">knows</span></code><code>*/</code><code><span class="c004">schema</span></code><code>:</code><code><span class="c006">name</span></code>
</td></tr>
</table>
</div>
<div class="center"><hr class="c021"></div></blockquote><div class="example"><div class="theorem"><span class="c013">Example 101</span> <em>SHACL paths example</em><p><em>The following shape declares that nodes that are instances of </em><em>
</em><code><em>:</em></code><code><em><span class="c006">User</span></em></code><em>
must satisfy that they must have a value for property </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">knows</span></em></code><em> or </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">follows</span></em></code><em>,
which must be an IRI and
that any node linked to users by the transitive closure of the </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">knows</span></em></code><em> property
must have a </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">email</span></em></code><em> whose value must also be an IRI.</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">UserShape</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">NodeShape</span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">targetClass</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> [</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> [</span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">alternativePath</span></span></em><em><span class="c011"> (</span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">knows</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">follows</span></span></em><em><span class="c011">)] ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">nodeKind</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">IRI</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">minCount</span></span></em><em><span class="c011"> 1</span></em><em><span class="c011">
</span></em><em><span class="c011"> ] ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> [</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> ([</span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">oneOrMorePath</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">knows</span></span></em><em><span class="c011">] </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">email</span></span></em><em><span class="c011">) ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">nodeKind</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">IRI</span></span></em><em><span class="c011">
</span></em><em><span class="c011"> ].</span></em></td></tr>
</table><p><em>Given the following RDF data:</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">alice</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :UserShape</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">follows</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c008"><em><span class="c011"><mailto:alice@mail.org></span></em></span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">knows</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">bob</span></span></em><em><span class="c011">, :</span></em><em><span class="c011"><span class="c006">carol</span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">bob</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">email</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c008"><em><span class="c011"><mailto:bob@mail.org></span></em></span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">knows</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">carol</span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">carol</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">email</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c008"><em><span class="c011"><mailto:carol@mail.org></span></em></span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">dave</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">knows</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c008"><em><span class="c011"><mailto:dave@mail.org></span></em></span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">knows</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">carol</span></span></em><em><span class="c011">, :</span></em><em><span class="c011"><span class="c006">emily</span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">emily</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">email</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Unknown"</span></em></span></span></em><em><span class="c011"> .</span></em></td></tr>
</table><p><em>A SHACL processor verifies that </em><em>
</em><code><em>:</em></code><code><em><span class="c006">alice</span></em></code><em> conforms to shape </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> because it has </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">email</span></em></code><em> with an IRI value and
all the nodes that can be reached by the property </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">knows</span></em></code><em> one or more times followed by the property </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">email</span></em></code><em>
(which is equivalent to </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">knows</span></em></code><code><em>+/</em></code><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">email</span></em></code><em> using SPARQL notation) are also IRIs. </em></p><p><em>The SHACL processor would return error for </em><em>
</em><code><em>:</em></code><code><em><span class="c006">dave</span></em></code><em> because one of the values of </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">knows</span></em></code><em> has an </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">email</span></em></code><em> that is not an IRI (</em><em>
</em><code><em>:</em></code><code><em><span class="c006">emily</span></em></code><em>).</em></p></div></div>
<h3 class="subsection" id="sec131">5.6.3 Constraint Components</h3>
<p>
<a id="ch5.sec6.3"></a></p><p><a id="hevea_default533"></a>
SHACL defines the concept of constraint components which are associated with shapes to declare constraints.
Each node or property shape can be associated with several constraint components. </p><p>Constraint components are identified by an IRI and have two types of parameters: mandatory and optional.
The association between a shape and a constraint component is made by declaring values for the parameters.
The parameters are also identified by IRIs and have values.
Most of the constraint components in SHACL Core have a single parameter and follow the convention that
if the parameter is named
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">p</span></code>, the corresponding constraint component is named
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">pConstraintComponent</span></code>.</p><div class="example"><div class="theorem"><span class="c013">Example 102</span> <em>Shape with two constraints</em><p><em>The following code:</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">UserShape</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">NodeShape</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">nodeKind</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">IRI</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">class</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Person</span></span></em><em><span class="c011"> .</span></em></td></tr>
</table><p><em>declares a node shape </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> with two constraints which are associated with the following constraint components:</em></p><ul class="itemize"><li class="li-itemize"><p><a id="hevea_default534"></a><em>
</em></p><em>
</em><code><em><span class="c004">sh</span></em></code><code><em>:</em></code><code><em><span class="c006">NodeKindConstraintComponent</span></em></code><em> with the value </em><em>
</em><code><em><span class="c004">sh</span></em></code><code><em>:</em></code><code><em><span class="c003">IRI</span></em></code><em> for the parameter </em><em>
</em><code><em><span class="c004">sh</span></em></code><code><em>:</em></code><code><em><span class="c006">nodeKind</span></em></code><em>.
The constraint means that nodes that conform to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> must be IRIs; and</em><p><a id="hevea_default535"></a><em>
</em></p></li><li class="li-itemize"><em>
</em><code><em><span class="c004">sh</span></em></code><code><em>:</em></code><code><em><span class="c006">ClassConstraintComponent</span></em></code><em> with the value </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">Person</span></em></code><em> for the parameter </em><em>
</em><code><em><span class="c004">sh</span></em></code><code><em>:</em></code><code><em><span class="c006">class</span></em></code><em>.
The constraint means that nodes conforming to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> must be instances of </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">Person</span></em></code><em>.
</em></li></ul><p><em>Given the following data:</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">alice</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Person</span></span></em><em><span class="c011"> . </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :UserShape</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">bob</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Product</span></span></em><em><span class="c011"> . </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011"><span class="c006">_</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">x</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Person</span></span></em><em><span class="c011"> . </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape</span></em></span></span></em></td></tr>
</table></div></div><p>When a constraint component declares a single parameter,
the parameter may be used several times in the same shape.
Each value of the parameter declares a different constraint.
The interpretations of such declarations is conjunctive, i.e., all constraints apply. </p><div class="example"><div class="theorem"><span class="c013">Example 103</span> <em>Shape with two constraints with the same parameter</em><p><em>The following code:</em></p><p><a id="hevea_default536"></a><em>
</em><em>
</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">UserShape</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">NodeShape</span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">class</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">foaf</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Person</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">class</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Person</span></span></em><em><span class="c011"> .</span></em></td></tr>
</table><p><em>Declares two constraints with the parameter </em><em>
</em><code><em><span class="c004">sh</span></em></code><code><em>:</em></code><code><em><span class="c006">class</span></em></code><em> that means that nodes conforming to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> must be instances of both </em><em>
</em><code><em><span class="c004">foaf</span></em></code><code><em>:</em></code><code><em><span class="c006">Person</span></em></code><em> and </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">Person</span></em></code><em>.</em></p></div></div><p>Constraint components are associated with validators which define the behavior of the constraint. </p><p>SHACL Core contains a list of built-in constraint components that are classified in
Table <a href="#ch050CoreConstraintComponents">5.3</a>.
In the table, we included the parameter names because they are shorter than the component IRIs.
Those components will be described in more detail in their corresponding sections later in this chapter. </p><p><a id="hevea_default537"></a> <a id="hevea_default538"></a>
<a id="hevea_default539"></a> <a id="hevea_default540"></a> <a id="hevea_default541"></a>
<a id="hevea_default542"></a> <a id="hevea_default543"></a>
<a id="hevea_default544"></a>
<a id="hevea_default545"></a>
<a id="hevea_default546"></a>
<a id="hevea_default547"></a>
<a id="hevea_default548"></a>
<a id="hevea_default549"></a>
<a id="hevea_default550"></a>
<a id="hevea_default551"></a>
<a id="hevea_default552"></a>
<a id="hevea_default553"></a>
<a id="hevea_default554"></a> <a id="hevea_default555"></a> <a id="hevea_default556"></a> <a id="hevea_default557"></a>
<a id="hevea_default558"></a>
<a id="hevea_default559"></a>
<a id="hevea_default560"></a>
<a id="hevea_default561"></a>
<a id="hevea_default562"></a>
<a id="hevea_default563"></a>
<a id="hevea_default564"></a> <a id="hevea_default565"></a> <a id="hevea_default566"></a> <a id="hevea_default567"></a>
<a id="hevea_default568"></a> <a id="hevea_default569"></a> <a id="hevea_default570"></a> <a id="hevea_default571"></a>
</p><blockquote class="table"><div class="center"><hr class="c021"></div>
<div class="caption"><table class="c002 cellpading0"><tr><td class="c018">Table 5.3: SHACL core constraint components</td></tr>
</table></div>
<a id="ch050CoreConstraintComponents"></a>
<div class="center">
<table class="c000 cellpadding1" border=1><tr><td class="c020"> <span class="c013">Operation</span></td><td class="c019"><span class="c013">Parameters</span></td><td class="c017"><span class="c013">Section
</span></td></tr>
<tr><td class="c020"> Cardinality constraints</td><td class="c019">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">minCount</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">maxCount</span></code></td><td class="c017"><a href="#ch050Cardinalities">5.8</a>
</td></tr>
<tr><td class="c020"> Value types</td><td class="c019">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">class</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">datatype</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">nodeKind</span></code> <br>
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">in</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">hasValue</span></code></td><td class="c017"><a href="#ch050ValueTypes">5.9</a>
</td></tr>
<tr><td class="c020"> Value range constraints</td><td class="c019">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c003">minInclusive</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c003">maxInclusive</span></code> <br>
<code><span class="c004">sh</span></code><code>:</code><code><span class="c003">minExclusive</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c003">maxExclusive</span></code></td><td class="c017"><a href="#ch050ValueRanges">5.10.1</a>
</td></tr>
<tr><td class="c020"> String based constraints</td><td class="c019">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c003">minLength</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c003">maxLength</span></code> <br>
<code><span class="c004">sh</span></code><code>:</code><code><span class="c003">length</span></code>
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">pattern</span></code></td><td class="c017"><a href="#ch040Stringbased">5.10.2</a>
</td></tr>
<tr><td class="c020"> Language based</td><td class="c019">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">uniqueLang</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">languageIn</span></code></td><td class="c017"><a href="#ch050LanguageBased">5.10.3</a>
</td></tr>
<tr><td class="c020"> Logical constraints</td><td class="c019">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">and</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c003">or</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">xone</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c003">not</span></code></td><td class="c017"><a href="#ch050logicalConstraints">5.11</a>
</td></tr>
<tr><td class="c020"> Shape-based constraints</td><td class="c019">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">node</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">property</span></code> <br>
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">qualifiedValueShape</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">qualifiedValueShapesDisjoint</span></code> <br>
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">qualifiedMinCount</span></code>
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">qualifiedMaxCount</span></code></td><td class="c017"><a href="#ch050shapeBasedConstraints">5.12</a>
</td></tr>
<tr><td class="c020"> Closed shapes</td><td class="c019">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c003">closed</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">ignoredProperties</span></code></td><td class="c017"><a href="#ch050Closed">5.13</a>
</td></tr>
<tr><td class="c020"> Property pair constraints</td><td class="c019">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">equals</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">disjoint</span></code> <br>
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">lesThan</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">lessThanOrEquals</span></code></td><td class="c017"><a href="#ch050propertyPairConstraints">5.14</a>
</td></tr>
<tr><td class="c020"> Non-validating constraints</td><td class="c019">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">name</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">description</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">order</span></code>,
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">group</span></code></td><td class="c017"><a href="#ch050NonValidating">5.15</a>
</td></tr>
</table>
</div>
<div class="center"><hr class="c021"></div></blockquote><p><a id="hevea_default572"></a>
As we will show in Section <a href="#ch050SHACLSPARQL">5.16</a>, SHACL-SPARQL can be used to declare other constraint components.</p>
<h3 class="subsection" id="sec132">5.6.4 Human Friendly Messages</h3>
<p>
<a id="ch050shMessage"></a>
<a id="ch5.sec6.4"></a></p><p><a id="hevea_default573"></a>
<a id="hevea_default574"></a>
The property <span class="c007"><span class="c011"><span class="c010">sh:message</span></span></span> can be used to associate a human-friendly message
with a shape.
If there is a violation that affects that shape, a SHACL processor can include
the value of <span class="c007"><span class="c011"><span class="c010">sh:message</span></span></span> as the value of
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">resultMessage</span></code>
in the validation report. </p><div class="example"><div class="theorem"><span class="c013">Example 104</span> <em>
</em><code><em><span class="c004">sh</span></em></code><code><em>:</em></code><code><em><span class="c006">message</span></em></code><em> example</em><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">UserShape</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">NodeShape</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">targetClass</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c008"><em><span class="c011"># Blank node 1</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">minCount</span></span></em><em><span class="c011"> 1 ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">message</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Where is the name?"</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> ] .</span></em></td></tr>
</table><p><em>Given the following RDF graph: </em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">alice</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Alice"</span></em></span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">bob</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">foaf</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Bob"</span></em></span></span></em><em><span class="c011"> .</span></em></td></tr>
</table><p><em>A SHACL processor would return the following validation report:</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">report</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">ValidationReport</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">conforms</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">false</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">result</span></span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">ValidationResult</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultSeverity</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Violation</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceConstraintComponent</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">MinCountConstraintComponent</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceShape</span></span></em><em><span class="c011"> ... ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011"># Blank node 1</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">focusNode</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">bob</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultPath</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultMessage</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Where is the name?"</span></em></span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011">] .</span></em></td></tr>
</table></div></div>
<h3 class="subsection" id="sec133">5.6.5 Declaring Shape Severities</h3>
<p>
<a id="ch050severity"></a>
<a id="ch5.sec6.5"></a></p><p><a id="hevea_default575"></a>
The property <span class="c007"><span class="c011"><span class="c010">sh:severity</span></span></span> can be used to declare a severity value for a shape.
If there is a violation that affects that shape, a SHACL processor can include the value of <span class="c007"><span class="c011"><span class="c010">sh:severity</span></span></span> as the value of
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">resultSeverity</span></code> in the validation report.
<a id="hevea_default576"></a>
<a id="hevea_default577"></a>
<a id="hevea_default578"></a>
SHACL describes three kinds of severity levels:
<span class="c007"><span class="c011"><span class="c010">sh:Info</span></span></span>, <span class="c007"><span class="c011"><span class="c010">sh:Warning</span></span></span>, and <span class="c007"><span class="c011"><span class="c010">sh:Violation</span></span></span>.
If the shape does not declare a severity value, the default one is
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">Violation</span></code>.</p><div class="example"><div class="theorem"><span class="c013">Example 105</span> <em>
</em><code><em><span class="c004">sh</span></em></code><code><em>:</em></code><code><em><span class="c006">severity</span></em></code><em> example</em><p><em>Given the following shapes graph: </em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">UserShape</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">NodeShape</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">targetClass</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c008"><em><span class="c011"># Blank node 1</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">datatype</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">xsd</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">string</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">severity</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Warning</span></span></em><em><span class="c011">
</span></em><em><span class="c011"> ] .</span></em></td></tr>
</table><p><em>and the RDF graph: </em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">alice</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Alice"</span></em></span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">bob</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> 23 .</span></em></td></tr>
</table><p><em>A SHACL processor returns the following validation report:</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">report</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">ValidationReport</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">conforms</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">false</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">result</span></span></em><em><span class="c011"> [ </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">ValidationResult</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultSeverity</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Warning</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceConstraintComponent</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">DatatypeConstraintComponent</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">sourceShape</span></span></em><em><span class="c011"> ... ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011"># Blank node 1</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">focusNode</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">bob</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultPath</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">resultMessage</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Datatype should be xsd:string"</span></em></span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">value</span></span></em><em><span class="c011"> 23</span></em><em><span class="c011">
</span></em><em><span class="c011">] .</span></em></td></tr>
</table></div></div>
<h3 class="subsection" id="sec134">5.6.6 Deactivating Shapes</h3>
<p>
<a id="ch050deactivate"></a>
<a id="ch5.sec6.6"></a></p><p><a id="hevea_default579"></a>
If a shape has the property
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">deactivated</span></code> with the value
<code><span class="c003">true</span></code> then it is deactivated and all RDF terms will conform to it.</p><p>A typical use case for deactivated shapes is when one
imports shapes from another graph by a third party and wants to deactivate some of the shapes in the local shapes graph that do not apply in the current context. </p><p>Notice that if the author of a shapes library anticipates that a shape may need to be disabled or modified by others,
it may be better to use IRIs instead of blank nodes, so they can be referenced later.</p><div class="example"><div class="theorem"><span class="c013">Example 106</span> <em>Deactivating shapes</em><em>
</em><a id="ch050DeactivatingShapes"></a><p><em>Let’s assume that there is a shapes library available at IRI
</em><a href="http://example.org/UserShapes"><em><span class="c010">http://example.org/UserShapes</span></em></a><em> with the following shapes graph:</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">UserShape</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">NodeShape</span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">targetClass</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">HasName</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">HasEmail</span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">HasName</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">minCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">maxCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">datatype</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">xsd</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">string</span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">HasEmail</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">email</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">minCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">nodeKind</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">IRI</span></span></em><em><span class="c011"> .</span></em></td></tr>
</table><p><em>And we define a shapes graph importing the previous shapes and adding a declaration for </em><em>
</em><code><em>:</em></code><code><em><span class="c006">TeacherShape</span></em></code><em> that deactivates the property </em><em>
</em><code><em>:</em></code><code><em><span class="c006">HasEmail</span></em></code><em>:</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011"><span class="c008"><em><span class="c011"><></span></em></span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">owl</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">imports</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c008"><em><span class="c011"><http://example.org/UserShapes></span></em></span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">TeacherShape</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">NodeShape</span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">targetClass</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">Teacher</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">node</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">UserShape</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> [</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">teaches</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">minCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">datatype</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">xsd</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">string</span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> ] ;</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">HasEmail</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">deactivated</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">true</span></span></em><em><span class="c011"> .</span></em></td></tr>
</table><p><em>The merged shapes graph deactivates the property shape </em><em>
</em><code><em>:</em></code><code><em><span class="c006">HasEmail</span></em></code><em> so nodes that conform to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">TeacherShape</span></em></code><em> need to conform to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> but do not need to have </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">email</span></em></code><em> property.</em></p><p><em>Given the following RDF data:</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">alice</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">Teacher</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :TeacherShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Alice"</span></em></span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">email</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c008"><em><span class="c011"><mailto:alice@example.org></span></em></span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">teaches</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Logic"</span></em></span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">bod</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">Teacher</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :TeacherShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Robert"</span></em></span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">email</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"This email is not an IRI"</span></em></span></span></em><em><span class="c011">;</span></em><em><span class="c011">
</span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">teaches</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Algebra"</span></em></span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">carol</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">Teacher</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :TeacherShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> 23 ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">teaches</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Logic"</span></em></span></span></em><em><span class="c011"> .</span></em></td></tr>
</table><p><em>A SHACL processor checks that </em><em>
</em><code><em>:</em></code><code><em><span class="c006">alice</span></em></code><em> and </em><em>
</em><code><em>:</em></code><code><em><span class="c006">bob</span></em></code><em> conform to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">TeacherShape</span></em></code><em> even if </em><em>
</em><code><em>:</em></code><code><em><span class="c006">bob</span></em></code><em> does not conform to the </em><em>
</em><code><em>:</em></code><code><em><span class="c006">HasEmail</span></em></code><em> shape.
It returns the following error:</em></p><ul class="itemize"><li class="li-itemize"><em>
</em><code><em>:</em></code><code><em><span class="c006">carol</span></em></code><em> does not conform to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">TeacherShape</span></em></code><em> because it does not conform to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> as the value of property </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">name</span></em></code><em> does not have datatype </em><em>
</em><code><em><span class="c004">xsd</span></em></code><code><em>:</em></code><code><em><span class="c006">string</span></em></code><em>.
</em></li></ul></div></div><p><a id="hevea_default580"></a>
</p>
<h2 class="section" id="sec135">5.7 Target Declarations</h2>
<p>
<a id="ch050TargetNodes"></a>
<a id="ch5.sec7"></a></p><p>SHACL shapes may define several target declarations.
Target declarations specify the set of nodes that will be validated against a shape.
Table <a href="#ch050.TargetDeclarations">5.4</a> contains the different target declarations defined in SHACL core.</p><p>SHACL targets provide the same functionality as the ShEx Shape maps (see <a href="bookHtml010.html#ch040ShapeMaps">4.9</a>).
We discuss the core differences in section <a href="bookHtml013.html#ch7.sec4">7.4</a>.</p><p><a id="hevea_default581"></a>
<a id="hevea_default582"></a>
<a id="hevea_default583"></a>
<a id="hevea_default584"></a>
</p><blockquote class="table"><div class="center"><hr class="c021"></div>
<div class="caption"><table class="c002 cellpading0"><tr><td class="c018">Table 5.4: SHACL target declarations</td></tr>
</table></div>
<a id="ch050.TargetDeclarations"></a>
<div class="center">
<table class="c000 cellpadding1" border=1><tr><td class="c020"> <span class="c013">Value</span></td><td class="c019"><span class="c013">Description
</span></td></tr>
<tr><td class="c020">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">targetNode</span></code></td><td class="c019">Directly point to a node
</td></tr>
<tr><td class="c020">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">targetClass</span></code></td><td class="c019">All nodes that are instances of some class
</td></tr>
<tr><td class="c020">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">targetSubjectsOf</span></code></td><td class="c019">All nodes that are subjects of some predicate
</td></tr>
<tr><td class="c020">
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">targetObjectsOf</span></code></td><td class="c019">All nodes that are objects of some predicate
</td></tr>
</table>
</div>
<div class="center"><hr class="c021"></div></blockquote><p><a id="hevea_default585"></a>
</p>
<h3 class="subsection" id="sec136">5.7.1 Target Node</h3>
<p>
<a id="ch050TargetNode"></a>
<a id="ch5.sec7.1"></a></p><p>The predicate
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">targetNode</span></code> declares a node that must conform to some shape. </p><div class="example"><div class="theorem"><span class="c013">Example 107</span> <em>
</em><code><em><span class="c004">sh</span></em></code><code><em>:</em></code><code><em><span class="c006">targetNode</span></em></code><em> example</em><p><em>In the following example, </em><em>
</em><code><em>:</em></code><code><em><span class="c006">alice</span></em></code><em>, </em><em>
</em><code><em>:</em></code><code><em><span class="c006">bob</span></em></code><em>, and </em><em>
</em><code><em>:</em></code><code><em><span class="c006">carol</span></em></code><em> are declared as the target nodes of </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> so a SHACL processor will validate those nodes.</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">UserShape</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">NodeShape</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">targetNode</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">alice</span></span></em><em><span class="c011">, :</span></em><em><span class="c011"><span class="c006">bob</span></span></em><em><span class="c011">, :</span></em><em><span class="c011"><span class="c006">carol</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> [</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">minCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">maxCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">datatype</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">xsd</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">string</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> ] .</span></em></td></tr>
</table><p><em>Given the RDF graph:</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">alice</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Alice Cooper"</span></em></span></span></em><em><span class="c011"> . </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :UserShape</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">bob</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">foaf</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Bob"</span></em></span></span></em><em><span class="c011"> . </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">carol</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> 23 . </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">dave</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> 45 . </span></em><em><span class="c011"><span class="c008"><em><span class="c011"># Ignored</span></em></span></span></em></td></tr>
</table><p><em>A SHACL processor checks that </em><em>
</em><code><em>:</em></code><code><em><span class="c006">alice</span></em></code><em> conforms to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> and returns the errors:</em></p><ul class="itemize"><li class="li-itemize"><em>
</em><code><em>:</em></code><code><em><span class="c006">bob</span></em></code><em> does not have have value for property </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">name</span></em></code><em>
</em></li><li class="li-itemize"><em>
</em><code><em>:</em></code><code><em><span class="c006">carol</span></em></code><em> has a value which is not a </em><em>
</em><code><em><span class="c004">xsd</span></em></code><code><em>:</em></code><code><em><span class="c006">string</span></em></code><em> for property </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">name</span></em></code><em>.
</em></li></ul><p><em>Notice that it ignores </em><em>
</em><code><em>:</em></code><code><em><span class="c006">dave</span></em></code><em> as it was not affected by the </em><em>
</em><code><em><span class="c004">sh</span></em></code><code><em>:</em></code><code><em><span class="c006">targetNode</span></em></code><em> declaration.</em></p></div></div><p>
<code><span class="c004">sh</span></code><code>:</code><code><span class="c006">targetNode</span></code> provides a similar functionality to the ShEx Fixed shape map (see <a href="bookHtml010.html#ch040fixedShapeMaps">4.9.1</a>).
However, the difference is that SHACL target nodes silently ignore missing target nodes from the data graph, while in ShEx, we get back a failure.
Depending on the data and constraint modeling approach, silent ignore may lead to false-positives and thus, target nodes should be used with caution.</p><p><a id="hevea_default586"></a>
</p>
<h3 class="subsection" id="sec137">5.7.2 Target Class</h3>
<p>
<a id="ch050targetClass"></a>
<a id="ch5.sec7.2"></a></p><p>Target class declarations specify that all instances of some class must be validated with some shape. </p><p><a id="hevea_default587"></a> <a id="ch050SHACLInstance"></a>
<a id="hevea_default588"></a>
<a id="hevea_default589"></a>
SHACL employs a specific notion of instance, which is called <em>SHACL instance</em>, which can be defined using SPARQL property paths as:
A node
<code><span class="c006">X</span></code> is a SHACL instance of a class
<code><span class="c006">C</span></code> if
<code><span class="c006">X</span></code><code> </code><code><span class="c004">rdf</span></code><code>:</code><code><span class="c006">type</span></code><code>/</code><code><span class="c004">rdfs</span></code><code>:</code><code><span class="c006">subClassOf</span></code><code>* </code><code><span class="c006">C</span></code>.</p><p>It means that nodes with an explicit
<code><span class="c004">rdf</span></code><code>:</code><code><span class="c006">type</span></code> arc declaration are considered
but also values that have an
<code><span class="c004">rdf</span></code><code>:</code><code><span class="c006">type</span></code> declaration pointing to some class that is transitively linked to another class by the
<code><span class="c004">rdfs</span></code><code>:</code><code><span class="c006">subClassOf</span></code> predicate.
Note that the definition uses only the predicate
<code><span class="c004">rdfs</span></code><code>:</code><code><span class="c006">subClassOf</span></code> but does not take into account other predicates from RDFS like
<code><span class="c004">rdfs</span></code><code>:</code><code><span class="c006">domain</span></code>,
<code><span class="c004">rdfs</span></code><code>:</code><code><span class="c006">target</span></code>, etc.
The definition is does not require RDFS inference.</p><div class="example"><div class="theorem"><span class="c013">Example 108</span> <em>
</em><code><em><span class="c004">sh</span></em></code><code><em>:</em></code><code><em><span class="c006">targetClass</span></em></code><em> example</em><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">UserShape</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">NodeShape</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">targetClass</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">property</span></span></em><em><span class="c011"> [</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">path</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">minCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">maxCount</span></span></em><em><span class="c011"> 1;</span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">sh</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">datatype</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">xsd</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">string</span></span></em><em><span class="c011"> ;</span></em><em><span class="c011">
</span></em><em><span class="c011"> ] .</span></em></td></tr>
</table><p><em>Given the following RDF graph:</em></p><table class="lstframe c014"><tr><td class="lstlisting"><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">alice</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011">; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :UserShape</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Alice Cooper"</span></em></span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">bob</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011">; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">foaf</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Bob"</span></em></span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">carol</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011">; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> 23 .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">dave</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">Student</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Fails as a :UserShape</span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> 45 .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">emily</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c003">a</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">Student</span></span></em><em><span class="c011"> ; </span></em><em><span class="c011"><span class="c008"><em><span class="c011">#Passes as a :UserShape </span></em></span></span></em><em><span class="c011">
</span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">schema</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">name</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c005"><em><span class="c011">"Emily"</span></em></span></span></em><em><span class="c011"> .</span></em><em><span class="c011">
</span></em><em><span class="c011">
</span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">Student</span></span></em><em><span class="c011"> </span></em><em><span class="c011"><span class="c004">rdfs</span></span></em><em><span class="c011">:</span></em><em><span class="c011"><span class="c006">subClassOf</span></span></em><em><span class="c011"> :</span></em><em><span class="c011"><span class="c006">User</span></span></em><em><span class="c011"> .</span></em></td></tr>
</table><p><em>A SHACL validator checks that both </em><em>
</em><code><em>:</em></code><code><em><span class="c006">alice</span></em></code><em> and </em><em>
</em><code><em>:</em></code><code><em><span class="c006">emily</span></em></code><em> conform to </em><em>
</em><code><em>:</em></code><code><em><span class="c006">UserShape</span></em></code><em> and returns the following errors:</em></p><ul class="itemize"><li class="li-itemize"><em>
</em><code><em>:</em></code><code><em><span class="c006">bob</span></em></code><em> does not have property </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">name</span></em></code><em>.
</em></li><li class="li-itemize"><em>
</em><code><em>:</em></code><code><em><span class="c006">carol</span></em></code><em> has a value for </em><em>
</em><code><em><span class="c004">schema</span></em></code><code><em>:</em></code><code><em><span class="c006">name</span></em></code><em> that is not an </em><em>
</em><code><em><span class="c004">xsd</span></em></code><code><em>:</em></code><code><em><span class="c006">string</span></em></code><em>.
</em></li><li class="li-itemize"><em>