-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathindex.html
6552 lines (6337 loc) · 223 KB
/
index.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>
<title>SHACL 1.2 Core</title>
<meta charset="utf-8">
<script src="https://www.w3.org/Tools/respec/respec-w3c" class="remove" defer></script>
<script class="remove">
function prepareSyntaxRules() {
document.querySelectorAll("[data-syntax-rule]").forEach(element => {
let ruleId = element.getAttribute("data-syntax-rule");
let tr = document.createElement("tr");
tr.classList.add("syntax-rule-tr");
let td1 = document.createElement("td");
td1.classList.add("syntax-rule-id");
let a = document.createElement("a");
a.classList.add("syntax-rule-id-a");
a.href = "#syntax-rule-" + ruleId;
a.textContent = ruleId;
td1.appendChild(a);
let td2 = document.createElement("td");
td2.innerHTML = element.innerHTML;
tr.appendChild(td1);
tr.appendChild(td2);
// Replace <dfn> elements inside `tr` with <a> elements
tr.querySelectorAll("dfn").forEach(dfn => {
let a = document.createElement("a");
a.textContent = dfn.textContent;
dfn.replaceWith(a);
});
document.getElementById("syntax-rules-table").appendChild(tr);
element.setAttribute("id", "syntax-rule-" + ruleId);
});
}
function prepareValidators() {
document.querySelectorAll("[data-validator]").forEach(element => {
let validatorId = element.getAttribute("data-validator") + "ConstraintComponent";
let tr = document.createElement("tr");
tr.classList.add("validator-tr");
let td = document.createElement("td");
tr.appendChild(td);
let a = document.createElement("a");
a.classList.add("validator-id-a");
a.href = `#validator-${validatorId}`;
a.textContent = `sh:${validatorId}`;
td.appendChild(a);
td.innerHTML += ": " + element.innerHTML;
document.getElementById("validators-table").appendChild(tr);
element.id = "validator-" + validatorId;
});
}
document.addEventListener("DOMContentLoaded", () => {
// Replace code div blocks in shapes, data, and results graph with tabs
for (const graph of document.querySelectorAll(".shapes-graph, .data-graph, .results-graph")) {
const tabs = document.createElement("aside");
tabs.classList.add("ds-selector-tabs");
graph.firstElementChild.classList.add("selected");
for (const child of graph.children) {
child.classList.add("tab");
}
tabs.append(...graph.children);
graph.append(tabs)
}
// Generate buttons for the selection logic
for (const tabs of document.querySelectorAll(".ds-selector-tabs")) {
const selectors = document.createElement("div");
selectors.classList.add("selectors");
selectors.innerHTML = `
<button class="selected" data-selects="turtle">Turtle</button>
<button data-selects="jsonld">JSON-LD</button>
`
tabs.prepend(selectors);
}
// Add example button selection logic
for (const button of document.querySelectorAll(".ds-selector-tabs .selectors button")) {
button.onclick = () => {
const ex = button.closest(".ds-selector-tabs");
ex.querySelector("button.selected").classList.remove("selected");
ex.querySelector(".selected").classList.remove("selected");
button.classList.add('selected');
ex.querySelector("." + button.dataset.selects).classList.add("selected");
}
}
});
var respecConfig = {
group: "wg/data-shapes",
github: "w3c/data-shapes",
edDraftURI: "https://w3c.github.io/data-shapes/shacl12-core/",
specStatus: "ED",
latestVersion: null,
preProcess : [ prepareSyntaxRules, prepareValidators ],
shortName: "shacl12-core",
subjectPrefix: "[shacl-core]",
editors: [
{
name: "Holger Knublauch",
company: "TopQuadrant, Inc.",
companyURL: "https://topquadrant.com/",
w3cid: 46500
},
{
name: "Thomas Bergwinkl",
company: "TopQuadrant, Inc.",
companyURL: "https://www.topquadrant.com/",
w3cid: 47803
},
{
name: "Yousouf Taghzouti",
company: "Inria",
companyURL: "https://www.inria.fr/",
w3cid: 143054
},
{
name: "Simon Werner",
company: "Taxonic",
companyURL: "https://www.taxonic.com/",
w3cid: 164386
},
],
formerEditors: [
{
name: "Dimitris Kontokostas",
w3cid: 58399
}
],
testSuiteURI: "https://w3c.github.io/data-shapes/data-shapes-test-suite/",
lint: {
"no-unused-dfns": false, // This should be removed near the end of the process
},
previousPublishDate: "2017-07-20",
previousMaturity: "REC",
prevRecShortname: "shacl",
prevRecURI: "https://www.w3.org/TR/2017/REC-shacl-20170720/",
wgPublicList: "public-shacl"
};
</script>
<style>
pre {
tab-size: 3;
-moz-tab-size: 3; /* Code for Firefox */
-o-tab-size: 3; /* Code for Opera */
}
th {
text-align: left;
}
table.rule { background-color: #EBEBE0; }
table.rule td { text-align: center; }
td.up { border-bottom:1px solid black; }
td {
vertical-align: top;
}
.algorithm {
background: #fafafc;
border-left-style: solid;
border-left-width: .5em;
border-color: #c0c0c0;
margin-bottom: 16px;
padding: 8px;
}
.arg {
font-weight: bold;
color: #000080;
}
.def {
background: #fcfcfc;
border-left-style: solid;
border-left-width: .5em;
border-color: #c0c0c0;
margin-bottom: 16px;
}
.def-text {
}
.def-text-body {
}
.def-header {
color: #a0a0a0;
font-size: 16px;
padding-bottom: 8px;
}
.diagram-class {
border: 1px solid black;
border-radius: 4px;
width: 360px;
}
.diagram-class-name {
font-size: 16px;
font-weight: bold;
text-align: center;
}
.diagram-class-properties {
border-top: 1px solid black;
}
.diagram-class-properties-start {
padding: 8px;
}
.diagram-class-properties-section {
border-top: 1px dashed #808080;
padding: 8px;
}
.example {
overflow-y: hidden !important;
}
.focus-node-selected {
color: blue;
}
.focus-node-error {
color: red;
}
.triple-can-be-skipped {
color: grey;
}
.focus-node-error {
color: red;
}
.target-can-be-skipped {
color: darkslategray;
font-style: italic;
}
.component-class {
font-weight: bold;
font-size: 16px;
}
.parameter-context {
font-weight: bold;
font-size: 16px;
}
.parameters {
font-weight: bold;
font-size: 16px;
}
.part-header {
font-weight: bold;
}
.syntax {
border-left-style: solid;
border-left-width: .5em;
border-color: #d0d0d0;
margin-bottom: 16px;
padding: .5em 1em;
background-color: #f6f6f6;
}
.syntax-rule-id {
padding-right: 10px;
}
.syntax-rule-id-a {
white-space: nowrap;
}
.validator-id-a {
font-weight: bold;
white-space: nowrap;
}
.term {
font-style: italic;
}
.term-def-header {
font-style: italic;
font-weight: bold;
}
.term-table {
border-collapse: collapse;
border-color: #000000;
margin: 16px;
}
.term-table td, th {
border-width: 1px;
border-style: solid;
padding: 5px;
}
.todo {
color: red;
}
pre {
word-wrap: normal;
}
.turtle {
font-family: Menlo, Consolas, "DejaVu Sans Mono", Monaco, monospace;
font-size: 14.4px;
hyphens: none;
overflow-x: auto;
padding: .5em;
tab-size: 3;
-moz-tab-size: 3; /* Code for Firefox */
-o-tab-size: 3; /* Code for Opera */
text-align: start;
margin-bottom: -1.5em;
margin-top: -1.5em;
white-space: pre;
}
.data-graph {
background: #eeb;
border: 1px solid #cc9;
margin-top: 0.3em;
}
.data-graph:before {
color: #996;
content: "Data graph";
padding-left: 0.4em;
}
.results-graph {
background: #edb;
border: 1px solid #bbb;
margin-top: 0.3em;
}
.results-graph:before {
color: #997;
content: "Validation results";
padding-left: 0.4em;
}
.shapes-graph {
background: #deb;
border: 1px solid #bbb;
margin-top: 0.3em;
}
.shapes-graph:before {
color: #888;
content: "Shapes graph";
padding-left: 0.4em;
}
/* no dark mode, keep colors for shapes-graph, data-graph, and results graph background */
code.hljs {
--base: transparent;
--mono-1: #383a42;
}
/* our syntax menu for switching */
div.syntaxmenu {
border: 1px dotted black;
padding:0.5em;
margin: 1em;
}
@media print {
div.syntaxmenu { display:none; }
}
/* example tab selection */
.ds-selector-tabs .selectors {
padding: 0;
border-bottom: 1px solid #ccc;
height: 28px;
}
.ds-selector-tabs .selectors button {
display: inline-block;
min-width: 54px;
text-align: center;
font-size: 11px;
font-weight: bold;
height: 27px;
padding: 0 8px;
line-height: 27px;
transition: all,0.218s;
border-top-right-radius: 2px;
border-top-left-radius: 2px;
color: #666;
border: 1px solid transparent;
}
.ds-selector-tabs .selectors button:first-child {
margin-left: 2px;
}
.ds-selector-tabs .selectors button.selected {
color: #202020 !important;
border: 1px solid #ccc;
border-bottom: 1px solid #fff !important;
}
.ds-selector-tabs .selectors button:hover {
background-color: transparent;
color: #202020;
cursor: pointer;
}
.ds-selector-tabs .tab {
display: none;
}
.ds-selector-tabs .selected {
display: block;
}
</style>
</head>
<body>
<section id="abstract">
<p>
This document defines the Core of the SHACL Shapes Constraint Language.
SHACL is a language for validating RDF graphs against a set of conditions.
These conditions are provided as shapes and other constructs expressed in the form of an RDF graph.
RDF graphs that are used in this manner are called "shapes graphs" in SHACL and
the RDF graphs that are validated against a shapes graph are called "data graphs".
As SHACL shape graphs are used to validate that data graphs satisfy a set of conditions
they can also be viewed as a description of the data graphs that do satisfy these conditions.
Such descriptions may be used for a variety of purposes beside validation, including
user interface building, code generation and data integration.
</p>
</section>
<section id="sotd">
</section>
<section class="introductory">
<h2>Document Outline</h2>
<p>
The introduction includes a <a href="#terminology">Terminology</a> section.
</p>
<p>
The syntax of SHACL is RDF.
The examples in this document use Turtle [[rdf12-turtle]] and (in one instance) JSON-LD [[json-ld]].
Other RDF serializations such as RDF/XML may be used in practice.
The reader should be familiar with basic RDF concepts [[rdf12-concepts]] such as triples.
</p>
</section>
<section id="introduction">
<h2>Introduction</h2>
<p>
This document specifies the Core of SHACL (Shapes Constraint Language), a language for describing and validating RDF graphs.
This section introduces SHACL with an overview of the key terminology and an example to illustrate basic concepts.
</p>
<section id="terminology">
<h3>Terminology</h3>
<p>
Throughout this document, the following terminology is used.
</p>
<p>
Terminology that is linked to portions of RDF 1.2 Concepts and Abstract
Syntax is used in SHACL as defined there. Terminology that is linked to
portions of SPARQL 1.2 Query Language is used in SHACL as defined there. A
single linkage is sufficient to provide a definition for all occurences of a
particular term in this document.
</p>
<p>
Definitions are complete within this document, i.e., if there is no rule to
make some situation true in this document then the situation is false.
</p>
<div class="def" id="rdf-terminology">
<div class="term-def-header">Basic RDF Terminology</div>
<div>
This document uses the terms
<dfn data-cite="rdf12-concepts#dfn-rdf-graph" data-lt="graph|graphs|RDF graphs">RDF graph</dfn>,
<dfn data-cite="rdf12-concepts#dfn-rdf-triple" data-lt="triple|triples">RDF triple</dfn>,
<dfn data-cite="rdf12-concepts#dfn-iri" data-lt="IRI|IRIs">IRI</dfn>,
<dfn data-cite="rdf12-concepts#dfn-literal" data-lt="literal|literals">literal</dfn>,
<dfn data-cite="rdf12-concepts#dfn-datatype" data-lt="datatype">datatype</dfn>,
<dfn data-cite="rdf12-concepts#dfn-blank-node" data-lt="blank node|blank nodes">blank node</dfn>,
<dfn data-cite="rdf12-concepts#dfn-node" data-lt="node|nodes">node</dfn> of an RDF graph,
<dfn data-cite="rdf12-concepts#dfn-rdf-term" data-lt="term|terms">RDF term</dfn>,
<dfn data-cite="rdf12-concepts#dfn-subject" data-lt="subject|subjects">subject</dfn>,
<dfn data-cite="rdf12-concepts#dfn-predicate" data-lt="predicate|predicates">predicate</dfn>, and
<dfn data-cite="rdf12-concepts#dfn-object" data-lt="object|objects">object</dfn> of RDF triples
as defined in RDF 1.2 Concepts and Abstract Syntax [[!rdf12-concepts]].
<dfn data-lt="language tag">Language tags</dfn> are defined as in [[!BCP47]].
</div>
</div>
<div class="def">
<div class="term-def-header">Property Value and Path</div>
<div>
A <dfn data-lt="properties">property</dfn> is an <a>IRI</a>.
An <a>RDF term</a> <code>n</code> has a <dfn data-lt="values|property value|property values">value</dfn> <code>v</code>
for property <code>p</code> in an <a>RDF graph</a> if there is an <a>RDF triple</a> in the graph
with <a>subject</a> <code>n</code>, <a>predicate</a> <code>p</code>, and <a>object</a> <code>v</code>.
The phrase "Every value of P in graph G ..." means "Every object of a triple in G with predicate P ...".
(In this document, the verbs <em>specify</em> or <em>declare</em> are sometimes used to express the fact that an RDF term has values for a given predicate in a graph.)
<br />
<dfn data-lt="SPARQL property path">SPARQL property paths</dfn> are defined as in <a href="https://www.w3.org/TR/sparql12-query/#pp-language">SPARQL 1.2</a>.
An RDF term <code>n</code> has value <code>v</code> for <a>SPARQL property path</a> expression
<code>p</code> in an RDF graph <code>G</code> if there is a solution mapping in the result of the SPARQL query
<code>SELECT ?s ?o WHERE { ?s p' ?o }</code> on <code>G</code> that binds <code>?s</code> to
<code>n</code> and <code>?o</code> to <code>v</code>, where <code>p'</code> is SPARQL surface syntax for <code>p</code>.
</div>
</div>
<div class="def">
<div class="term-def-header">SHACL Lists</div>
<div>
<span data-syntax-rule="SHACL-list">A <dfn data-lt="SHACL lists">SHACL list</dfn> in an RDF graph <code>G</code> is an <a>IRI</a> or a <a>blank node</a>
that is either <code>rdf:nil</code> (provided that <code>rdf:nil</code> has no <a>value</a>
for either <code>rdf:first</code> or <code>rdf:rest</code>), or has exactly one <a>value</a>
for the property <code>rdf:first</code> in <code>G</code> and exactly one <a>value</a>
for the property <code>rdf:rest</code> in <code>G</code> that is also a SHACL list in <code>G</code>,
and the list does not have itself as a value of the property path <code>rdf:rest+</code> in <code>G</code>.</span>
<br />
The <dfn data-lt="member">members</dfn> of any SHACL list except <code>rdf:nil</code> in an RDF
graph <code>G</code> consist of its value for <code>rdf:first</code> in <code>G</code> followed by
the members in <code>G</code> of its value for <code>rdf:rest</code> in <code>G</code>.
The SHACL list <code>rdf:nil</code> has no members in any RDF graph.
</div>
</div>
<div class="def">
<div class="term-def-header">Binding, Solution</div>
<div>
A <dfn data-lt="bindings">binding</dfn> is a pair (<a data-cite="sparql12-query/#defn_QueryVariable">variable</a>, <a>RDF term</a>), consistent with the term's use in [[!sparql12-query]].
A <dfn data-lt="solutions">solution</dfn> is a set of bindings, informally often understood as one row in the body of the result table of a SPARQL query.
Variables are not required to be bound in a solution.
</div>
</div>
<div class="def">
<div class="term-def-header">SHACL Subclass, SHACL superclass</div>
<div>
A <a>node</a> <code>Sub</code> in an <a>RDF graph</a> is a <dfn data-lt="subclasses|subclass|SHACL subclasses">SHACL subclass</dfn> of another <a>node</a> <code>Super</code>
in the <a>graph</a> if there is a sequence of <a>triples</a> in the <a>graph</a> each with predicate <code>rdfs:subClassOf</code> such that the <a>subject</a> of the first <a>triple</a> is <code>Sub</code>,
the <a>object</a> of the last triple is <code>Super</code>, and the <a>object</a> of each <a>triple</a> except the last is the <a>subject</a> of the next.
If <code>Sub</code> is a <a>SHACL subclass</a> of <code>Super</code> in an <a>RDF graph</a> then <code>Super</code>
is a <dfn data-lt="superclass|superclasses|SHACL superclasses|">SHACL superclass</dfn> of <code>Sub</code> in the <a>graph</a>.
</div>
</div>
<div class="def">
<div class="term-def-header">SHACL Type</div>
<div>
The <dfn data-lt="type|types|SHACL type">SHACL types</dfn> of an <a>RDF term</a> in an <a>RDF graph</a> is the set of its <a>values</a> for <code>rdf:type</code> in the
<a>graph</a> as well as the <a>SHACL superclasses</a> of these <a>values</a> in the <a>graph</a>.
</div>
</div>
<div class="def">
<div class="term-def-header">SHACL Class</div>
<div>
<a>Nodes</a> in an <a>RDF graph</a> that are subclasses, superclasses, or types of <a>nodes</a> in the <a>graph</a> are referred to as <dfn data-lt="class|classes|SHACL classes">SHACL class</dfn>.
</div>
</div>
<div class="def">
<div class="term-def-header">SHACL Class Instance</div>
<div>
A <a>node</a> <code>n</code> in an <a>RDF graph</a> <code>G</code> is a <dfn data-lt="SHACL instance|SHACL instances">SHACL instance</dfn> of a <a>SHACL class</a> <code>C</code> in <code>G</code>
if one of the <a>SHACL types</a> of <code>n</code> in <code>G</code> is <code>C</code>.
</div>
</div>
<div class="def">
<div class="term-def-header">Deep Copy</div>
<div>
For a <a>node</a> <code>n</code> in a <a>graph</a> <code>sourceGraph</code>,
the <dfn data-lt="deep copy">deep copy</dfn> of <code>n</code> in a <a>graph</a> <code>targetGraph</code>
is <code>n</code> in <code>targetGraph</code> plus, if <code>n</code> is a <a>blank node</a>,
any <a>triples</a> from <code>sourceGraph</code> that can be reached by transitively traversing
the <a>blank nodes</a> that appear in the <a>object</a> position of a triple that can be reached
starting with <code>n</code> as the <a>subject</a>. This is similar to
the <a href="https://www.w3.org/submissions/CBD/">Concise Bounded Description</a>, but without reification.
</div>
</div>
</section>
<section id="conventions">
<h3>Document Conventions</h3>
<p>
Within this document, the following namespace prefix definitions are used:
</p>
<table class="term-table">
<tr>
<th>Prefix</th>
<th>Namespace</th>
</tr>
<tr>
<td><code>rdf:</code></td>
<td><code>http://www.w3.org/1999/02/22-rdf-syntax-ns#</code></td>
</tr>
<tr>
<td><code>rdfs:</code></td>
<td><code>http://www.w3.org/2000/01/rdf-schema#</code></td>
</tr>
<tr>
<td><code>sh:</code></td>
<td><code><a href="http://www.w3.org/ns/shacl">http://www.w3.org/ns/shacl#</a></code></td>
</tr>
<tr>
<td><code>xsd:</code></td>
<td><code>http://www.w3.org/2001/XMLSchema#</code></td>
</tr>
<tr>
<td><code>ex:</code></td>
<td><code>http://example.com/ns#</code></td>
</tr>
</table>
<p>
Within this document, the following JSON-LD context is used:
</p>
<pre class="jsonld">{
"@context": {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"sh": "http://www.w3.org/ns/shacl#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"ex": "http://example.com/ns#"
}
}</pre>
<p>
Note that the URI of the graph defining the SHACL vocabulary itself is equivalent to
the namespace above, i.e., it includes the <code>#</code>.
References to the SHACL vocabulary, e.g., via <code>owl:imports</code> should include the <code>#</code>.
</p>
<p>
Throughout the document, color-coded boxes containing RDF graphs in Turtle and JSON-LD will appear.
These fragments of Turtle documents use the prefix bindings given above.
The JSON-LD document fragments use the context given above.
Only the Turtle documents may highlight certain parts.
</p>
<div class="shapes-graph">
<div class="turtle">
# This box represents an input shapes graph
# Triples that can be omitted are marked as grey, e.g. --
<span class="triple-can-be-skipped"><s> <p> <o> .</span>
</div>
<div class="jsonld">
<pre class="text">// This box represents an input shapes graph</pre>
<pre class="jsonld">{
"@id": "ex:s",
"ex:p": {
"@id": "ex:o"
}
}</pre>
</div>
</div>
<div class="data-graph">
<div class="turtle">
# This box represents an input data graph.
# When highlighting is used in the examples:
# Elements highlighted in blue are <a>focus nodes</a>
<span class="focus-node-selected">ex:Bob</span> a ex:Person .
# Elements highlighted in red are focus nodes that fail validation
<span class="focus-node-error">ex:Alice</span> a ex:Person .
</div>
<div class="jsonld">
<pre class="text">// This box represents an input data graph</pre>
<pre class="jsonld">{
"@graph": [
{
"@id": "ex:Alice",
"@type": "ex:Person"
},
{
"@id": "ex:Bob",
"@type": "ex:Person"
}
]
}</pre>
</div>
</div>
<div class="results-graph">
<div class="turtle">
# This box represents an output results graph
</div>
<div class="jsonld">
<pre class="text">// This box represents an output results graph</pre>
</div>
</div>
<p class="syntax">
Grey boxes such as this include syntax rules that apply to the <a>shapes graph</a>.
</p>
<p>
<code>true</code> denotes the RDF term <code>"true"^^xsd:boolean</code>.
<code>false</code> denotes the RDF term <code>"false"^^xsd:boolean</code>.
</p>
</section>
<section id="conformance">
<p>
This document defines the <strong>SHACL Core</strong> language, also referred to as just <strong>SHACL</strong>.
This specification describes conformance criteria for:
</p>
<ul>
<li><strong>SHACL Core processors</strong> as processors that support validation with the SHACL Core Language</li>
</ul>
<p>
This document includes syntactic rules that shapes and other nodes need to fulfill in the <a>shapes graph</a>.
These rules are typically of the form <em>A shape must have...</em> or <em>The values of X are literals</em> or <em>All objects of triples with predicate P must be IRIs</em>.
The complete list of these rules can be found in the <a href="#syntax-rules">appendix</a>.
Nodes that violate any of these rules are called <dfn>ill-formed</dfn>.
Nodes that violate none of these rules are called <dfn>well-formed</dfn>.
A <a>shapes graph</a> is ill-formed if it contains at least one ill-formed node.
</p>
</section>
<section class="informative">
<h3>SHACL Example</h3>
<p>
The following example <a>data graph</a> contains three <a>SHACL instances</a> of the <a>class</a> <code>ex:Person</code>.
</p>
<aside class="example">
<div class="data-graph">
<div class="turtle">
ex:Alice
a ex:Person ;
ex:ssn "987-65-432A" .
ex:Bob
a ex:Person ;
ex:ssn "123-45-6789" ;
ex:ssn "124-35-6789" .
ex:Calvin
a ex:Person ;
ex:birthDate "1971-07-07"^^xsd:date ;
ex:worksFor ex:UntypedCompany .
</div>
<div class="jsonld">
<pre class="jsonld">{
"@graph": [
{
"@id": "ex:Alice",
"@type": "ex:Person",
"ex:ssn": "987-65-432A"
},
{
"@id": "ex:Bob",
"@type": "ex:Person",
"ex:ssn": [
"123-45-6789",
"124-35-6789"
]
},
{
"@id": "ex:Calvin",
"@type": "ex:Person",
"ex:birthDate": {
"@type": "xsd:date",
"@value": "1971-07-07"
},
"ex:worksFor": {
"@id": "ex:UntypedCompany"
}
}
]
}</pre>
</div>
</div>
<p>
The following conditions are shown in the example:
</p>
<ul>
<li>
A <a>SHACL instance</a> of <code>ex:Person</code> can have at most one <a>value</a> for the property <code>ex:ssn</code>,
and this <a>value</a> is a <a>literal</a> with the datatype <code>xsd:string</code> that matches
a specified regular expression.
</li>
<li>
A <a>SHACL instance</a> of <code>ex:Person</code> can have unlimited <a>values</a> for the property <code>ex:worksFor</code>,
and these <a>values</a> are <a>IRIs</a> and <a>SHACL instances</a> of <code>ex:Company</code>.
</li>
<li>
A <a>SHACL instance</a> of <code>ex:Person</code> cannot have <a>values</a> for any other property apart from
<code>ex:ssn</code>, <code>ex:worksFor</code> and <code>rdf:type</code>.
</li>
</ul>
<p>
The aforementioned conditions can be represented as <a>shapes</a> and <a>constraints</a> in the following <a>shapes graph</a>:
</p>
<div class="shapes-graph">
<div class="turtle">
ex:PersonShape
a sh:NodeShape ;
sh:targetClass ex:Person ; # Applies to all persons
sh:property [ # _:b1
sh:path ex:ssn ; # constrains the values of ex:ssn
sh:maxCount 1 ;
sh:datatype xsd:string ;
sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ;
] ;
sh:property [ # _:b2
sh:path ex:worksFor ;
sh:class ex:Company ;
sh:nodeKind sh:IRI ;
] ;
sh:closed true ;
sh:ignoredProperties ( rdf:type ) .
</div>
<div class="jsonld">
<pre class="jsonld">{
"@id": "ex:PersonShape",
"@type": "sh:NodeShape",
"sh:closed": {
"@type": "xsd:boolean",
"@value": "true"
},
"sh:ignoredProperties": {
"@list": [
{
"@id": "rdf:type"
}
]
},
"sh:property": [
{
"sh:datatype": {
"@id": "xsd:string"
},
"sh:maxCount": {
"@type": "xsd:integer",
"@value": "1"
},
"sh:path": {
"@id": "ex:ssn"
},
"sh:pattern": "^\\d{3}-\\d{2}-\\d{4}$"
},
{
"sh:class": {
"@id": "ex:Company"
},
"sh:nodeKind": {
"@id": "sh:IRI"
},
"sh:path": {
"@id": "ex:worksFor"
}
}
],
"sh:targetClass": {
"@id": "ex:Person"
}
}</pre>
</div>
</div>
</aside>
<p>
We can use the shape declaration above to illustrate some of the key terminology used by SHACL.
The <a>target</a> for the <a>shape</a> <code>ex:PersonShape</code> is the set of all <a>SHACL instances</a> of the <a>class</a> <code>ex:Person</code>.
This is specified using the property <code>sh:targetClass</code>.
During the validation, these target nodes become <a>focus nodes</a> for the shape.
The <a>shape</a> <code>ex:PersonShape</code> is a <a>node shape</a>, which means that it applies to the focus nodes.
It declares <a>constraints</a> on the <a>focus nodes</a>, for example using the <a>parameters</a> <code>sh:closed</code> and <code>sh:ignoredProperties</code>.
The <a>node shape</a> also declares two other constraints with the property <code>sh:property</code>,
and each of these is backed by a <a>property shape</a>.
These <a>property shapes</a> declare additional <a>constraints</a> using <a>parameters</a> such as <code>sh:datatype</code> and <code>sh:maxCount</code>.
</p>
<p>
Some of the <a>property shapes</a> specify parameters from multiple <a>constraint components</a> in order to
restrict multiple aspects of the <a>property values</a>.
For example, in the <a>property shape</a> for <code>ex:ssn</code>, parameters from three <a>constraint components</a> are used.
The <a>parameters</a> of these <a>constraint components</a> are <code>sh:datatype</code>, <code>sh:pattern</code> and <code>sh:maxCount</code>.
For each <a>focus node</a> the <a>property values</a> of <code>ex:ssn</code> will be validated against all three components.
</p>
<p>
SHACL <a>validation</a> based on the provided <a>data graph</a> and <a>shapes graph</a> would produce the following <a>validation report</a>.
See the section <a href="#validation-report">Validation Report</a> for details on the format.
</p>
<aside class="example">
<div class="results-graph">
<div class="turtle">
[ a sh:ValidationReport ;
sh:conforms false ;
sh:result
[ a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:focusNode ex:Alice ;
sh:resultPath ex:ssn ;
sh:value "987-65-432A" ;
sh:sourceConstraintComponent sh:PatternConstraintComponent ;
sh:sourceShape _:b1 ; # ... blank node _:b1 on ex:ssn above ...
] ,
[ a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:focusNode ex:Bob ;
sh:resultPath ex:ssn ;
sh:sourceConstraintComponent sh:MaxCountConstraintComponent ;
sh:sourceShape _:b1 ; # ... blank node _:b1 on ex:ssn above ...
] ,
[ a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:focusNode ex:Calvin ;
sh:resultPath ex:worksFor ;
sh:value ex:UntypedCompany ;
sh:sourceConstraintComponent sh:ClassConstraintComponent ;
sh:sourceShape _:b2 ; # ... blank node _:b2 on ex:worksFor above ...
] ,
[ a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:focusNode ex:Calvin ;
sh:resultPath ex:birthDate ;
sh:value "1971-07-07"^^xsd:date ;
sh:sourceConstraintComponent sh:ClosedConstraintComponent ;
sh:sourceShape sh:PersonShape ;
]
] .
</div>
<div class="jsonld">
<pre class="jsonld">{
"@type": "sh:ValidationReport",
"sh:conforms": {
"@type": "xsd:boolean",
"@value": "false"
},
"sh:result": [
{
"@type": "sh:ValidationResult",
"sh:focusNode": {
"@id": "ex:Alice"
},
"sh:resultPath": {
"@id": "ex:ssn"
},
"sh:resultSeverity": {
"@id": "sh:Violation"
},
"sh:sourceConstraintComponent": {
"@id": "sh:PatternConstraintComponent"
},
"sh:sourceShape": {
"@id": "_:b3_b1"
},
"sh:value": "987-65-432A"
},
{
"@type": "sh:ValidationResult",
"sh:focusNode": {
"@id": "ex:Bob"
},
"sh:resultPath": {
"@id": "ex:ssn"
},
"sh:resultSeverity": {
"@id": "sh:Violation"
},
"sh:sourceConstraintComponent": {
"@id": "sh:MaxCountConstraintComponent"
},
"sh:sourceShape": {
"@id": "_:b3_b1"
}
},
{
"@type": "sh:ValidationResult",
"sh:focusNode": {
"@id": "ex:Calvin"
},
"sh:resultPath": {
"@id": "ex:worksFor"
},
"sh:resultSeverity": {
"@id": "sh:Violation"
},
"sh:sourceConstraintComponent": {
"@id": "sh:ClassConstraintComponent"
},
"sh:sourceShape": {
"@id": "_:b3_b2"
},
"sh:value": {
"@id": "ex:UntypedCompany"
}
},