forked from shexSpec/primer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stuff-removed-from-index.html
349 lines (340 loc) · 22.1 KB
/
stuff-removed-from-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
<html>
<head>
</head>
<body>
<section id="structure">
<h2>ShExC Structure</h2>
<p>
We've seen several examples of ShExC.
Here we'll describe more completely the structure of a ShExC schema.
</p>
<section id="Comments">
<h3>Comments</h3>
<p>
As in Turtle, Trig and SPARQL, comments in ShExC are prefixed by a <code class="comment">#</code> character.
There are <a href="http://stackoverflow.com/questions/244777/can-i-use-comments-inside-a-json-file">no comments in JSON</a>, though there are some <a href="http://stackoverflow.com/questions/244777/can-i-use-comments-inside-a-json-file#answer-18018493">diabolical workarounds leveraging overwritten object keys</a>.
</p>
<div class="example wrapper">
<pre class="schema shexc"><span class="comment"># schema (ShExC)</span>
<span class="shape-name">my:UserShape</span> { <span class="comment"># a user has</span>
( <span class="comment"># either</span>
<span class="predicate">foaf:name</span> <span class="value-constraint">xsd:string</span> <span class="comment"># a full name</span>
| <span class="comment"># or</span>
<span class="predicate">foaf:givenName</span> <span class="value-constraint">xsd:string</span><span class="keyword">+</span>;<span class="comment"># one or more given names</span>
<span class="predicate">foaf:familyName</span> <span class="value-constraint">xsd:string</span> <span class="comment"># and a family name</span>
);
<span class="predicate">foaf:mbox</span> <span class="value-constraint">IRI</span> <span class="comment"># and always an mbox.</span>
}</pre>
<pre class="schema json"><span class="comment"># schema (JSON)</span>
{ <span class="shape-name">"my:UserShape"</span>: { <span class="comment">"type": "a user has"</span>,
"type": "Shape",
"expression": { "type": "group",
"expressions": [
{ <span class="comment">"type": " either"</span>
"type": "OneOf",
"expressions": [
{ <span class="comment">"type": " a full name"</span>
"type": "TripleConstraint", <span class="predicate">"predicate": "foaf:name"</span>,
<span class="predicate">"value": { "type": "NodeConstraint", "datatype": "xsd:string" }</span>
},
{ <span class="comment">"type": " or"</span>
"type": "group",
"expressions": [
{ <span class="comment">"type": " one or more given names"</span>
"type": "TripleConstraint", <span class="predicate">"predicate": "foaf:givenName"</span>,
<span class="predicate">"value": { "type": "NodeConstraint", "datatype": "xsd:string" }</span>,
"min": 1, "max": "*"
},
{ <span class="comment">"type": " and a family name"</span>
"type": "TripleConstraint", <span class="predicate">"predicate": "foaf:familyName"</span>,
<span class="predicate">"value": { "type": "NodeConstraint", "datatype": "xsd:string" }</span>
}
]
}
]
},
{ <span class="comment">"type": "and always an mbox."</span>
"type": "TripleConstraint", <span class="predicate">"predicate": "foaf:mbox"</span>,
<span class="predicate">"value": { "type": "NodeConstraint", "datatype": "IRI" }</span>
}
]
}
}
}</pre>
</div>
</section>
<section id="RDF-terms">
<h3>RDF Terms</h3>
<p>
The terms ("terminals", to a language geek) in ShEx are the same as <a href="http://www.w3.org/TR/turtle/#h3_sec-parsing-terms">those in Turtle</a>.
The following list summarizes which terminals are allows where in the <a href="http://www.w3.org/2005/01/yacker/uploads/ShEx3?lang=perl&markup=html#productions">ShEx grammar</a>:
</p>
<ul>
<li><code>Shape labels</code> (seen in <a class="ref" href="#shape-declaration">shape declaration</a> and <a class="ref" href="#value-shape">value shapes</a>) are IRIs or blank nodes.</li>
<li><code>Constraint labels</code> (see <a class="ref" href="#value-class-definition">value class definitions</a> and <a class="ref" href="#value-class-reference">value class references</a> described below in <a href="#labeled-constraints">Reusing Triple Constraints</a>) are also IRIs or blank nodes.</li>
<li>Predicates are IRIs (reflecting a restriction in RDF that predicates are IRIs).
As in other RDF languages, the keyword <code class="keyword">a</code> is shorthand for <code>rdf:type</code>.
</li>
<li><code>Literal datatypes</code> are IRIs.</li>
</ul>
<p>
IRIs are parsed as they are in Turtle, respecting the current <a href="http://www.w3.org/TR/turtle/#prefixed-name">namespace prefix mapping</a> and <a href="http://www.w3.org/TR/turtle/#relative-iri">base</a> directives.
</p>
<p class="note">An additional non-RDF term called a <code>stem</code> appears in <a class="ref" href="#value-sets">value sets</a>.</p>
</section>
</section>
<section id="examples">
<h2>Additional Examples</h2>
<section id="xsd:length">
<h3>xsd:length</h3>
<div class="namespace">
<p>
Constrain the length of a foaf:name to be <span class="min lowlight2 top bot">>= 3</span> and <span class="max lowlight2 top bot"><= 255</span>:
</p>
<div class="example wrapper">
<!-- ShExC example -->
<pre class="schema shexc" style="float:left;"><span class="comment"># schema (ShExC)</span>
<span class="shape-name">my:UserShape</span> {
<span class="predicate">foaf:name</span> <span class="value-constraint">xsd:string
<span class="min lowlight2 top bot new">MinLength 3</span>
<span class="max lowlight2 top bot new">MaxLength 255</span></span>
}</pre>
<!-- JSON example -->
<pre class="schema json" style="float:left;"><span class="comment">// schema (JSON)</span>
{ <span class="shape-name">"my:UserShape"</span>: { "type": "Shape",
"expression": {
"type": "TripleConstraint", <span class="predicate">"predicate": "foaf:name"</span>,
<span class="value-constraint">"value": {
"type": "NodeConstraint", "datatype": "xsd:string",
<span class="min lowlight2 top bot new">"minlength": 3</span>, <span class="max lowlight2 top bot new">"maxlength": 255</span> }</span> } } }</pre>
<div class="verticalDivider"><!-- acts as a divider --></div>
<div style="float:left;">
<pre class="instance turtle"><span class="comment"># passing data</span>
<span class="name lowlight1 top bot"><span class="user lowlight2 top bot"><span class="function-name">inst:User2</span></span> <span class="type">foaf:</span><span class="constant">name</span> <span class="string top bot">"Bob Smith"</span></span> .</pre>
<pre class="instance turtle fail" style="float:left;"><span class="comment"># failing data</span>
<span class="name lowlight1 top bot"><span class="user lowlight2 top bot"><span class="function-name">inst:User9</span></span> <span class="type">foaf:</span><span class="constant">name</span> <span class="min lowlight2 top bot"><span class="string top bot errorSite">"BS"</span></span></span>.</pre>
</div>
<div style="clear:both;"></div>
</div>
<script type="text/javascript">
<!--
prepareHighlight(['min', 'max'], "highlight2", "lowlight2");
prepareHighlight(['name999'], "highlight1", "lowlight1");
-->
</script>
</div>
</section>
</section>
<section id="security" class="appendix informative">
<h2>Security and Privacy Considerations</h2>
<p>
RDF, like any general-purpose data language, can convey confidential information.
Trust in the information in RDF should be commensurate to the trust in the origin data.
Applying schema validation can somewhat reduce the need for defensive coding in applications consuming untrusted data but it is still important to consider what forms of data a malicious attacker my produce and how an application will respond to that data.
</p>
</section>
<section id="rel-to-shacl" class="appendix">
<h2>Relationship to SHACL</h2>
<p>
It is current unclear to what extend ShEx can be represented in SHACL.
Some of the obvious differences are captured as issues:
</p>
<ul>
<li><a href="https://www.w3.org/2014/data-shapes/track/issues/92">Should repeated properties be interpreted as additive or conjunctive?</a></li>
<li><a href="https://www.w3.org/2014/data-shapes/track/issues/22">Treatment of recursive shape definitions</a> - closed without a definition of recursion or stratification.</li>
<li><a href="https://www.w3.org/2014/data-shapes/track/issues/52">Define an Abstract Syntax for SHACL</a> - in progress.</li>
<li><a href="https://www.w3.org/2014/data-shapes/track/issues/57">Cardinalities on expressions or groups of triple constraints</a> - closed without a way to express e.g. optional groups.</li>
<li><a href="https://www.w3.org/2014/data-shapes/track/issues/80">Constraint to limit IRIs against scheme/namespace, possibly with dereferencing</a> - this issue was closed but lexical restrictions like PATTERN and stems capture some of this.</li>
</ul>
</section>
<p>
Node constraints can also be tested directly against the focus node à la the <a href="#example-school-enrolleeAge">first example in QuickStart</a>:
</p>
<pre class="schema shexc table"><span class="shape-name">foaf:age</span> xsd:integer MinValue 3 MaxValue 20</pre>
<p>
or used in conjunction with a shape:
</p>
<pre class="schema shexc table"><span class="shape-name">ex:UserShape</span> <span class="keyword">IRI</span> { foaf:name LITERAL }</pre>
<a href="http://www.w3.org/TR/json-ld/">JSON</a>
</body>
</html>
<!-- svg fill-opacity="0" xmlns:xlink="http://www.w3.org/1999/xlink" color-rendering="auto" color-interpolation="auto" stroke="rgb(0,0,0)" text-rendering="auto" stroke-linecap="square" width="466" stroke-miterlimit="10" stroke-opacity="0" shape-rendering="auto" fill="rgb(0,0,0)" stroke-dasharray="none" font-weight="normal" stroke-width="1" height="151" xmlns="http://www.w3.org/2000/svg" font-family="'Dialog'" font-style="normal" stroke-linejoin="miter" font-size="12" stroke-dashoffset="0" image-rendering="auto"
><defs id="genericDefs"
/><g
><defs id="defs1"
><linearGradient x1="65" gradientUnits="userSpaceOnUse" x2="65" y1="100" y2="0" id="linearGradient1" spreadMethod="reflect"
><stop stop-opacity="1" stop-color="rgb(118,148,200)" offset="0%"
/><stop stop-opacity="1" stop-color="rgb(238,243,251)" offset="100%"
/></linearGradient
><linearGradient x1="85" gradientUnits="userSpaceOnUse" x2="85" y1="100" y2="0" id="linearGradient2" spreadMethod="reflect"
><stop stop-opacity="1" stop-color="rgb(118,148,200)" offset="0%"
/><stop stop-opacity="1" stop-color="rgb(238,243,251)" offset="100%"
/></linearGradient
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath1"
><path d="M-7 -7 L141 -7 L141 111 L-7 111 L-7 -7 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath2"
><path d="M0 0 L0 85 L130 85 L130 0 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath3"
><path d="M0 0 L130 0 L130 15 L0 15 L0 0 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath4"
><path d="M-7 -7 L181 -7 L181 111 L-7 111 L-7 -7 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath5"
><path d="M0 0 L0 85 L170 85 L170 0 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath6"
><path d="M0 0 L170 0 L170 15 L0 15 L0 0 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath7"
><path d="M-7 -7 L48 -7 L48 26 L-7 26 L-7 -7 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath8"
><path d="M0 0 L37 0 L37 15 L0 15 L0 0 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath9"
><path d="M-7 -7 L50 -7 L50 26 L-7 26 L-7 -7 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath10"
><path d="M0 0 L39 0 L39 15 L0 15 L0 0 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath11"
><path d="M-7 -7 L37 -7 L37 27 L-7 27 L-7 -7 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath12"
><path d="M0 0 L26 0 L26 16 L0 16 L0 0 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath13"
><path d="M-7 -7 L47 -7 L47 26 L-7 26 L-7 -7 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath14"
><path d="M0 0 L36 0 L36 15 L0 15 L0 0 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath15"
><path d="M-7 -7 L49 -7 L49 26 L-7 26 L-7 -7 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath16"
><path d="M0 0 L38 0 L38 15 L0 15 L0 0 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath17"
><path d="M0 0 L171 0 L171 52 L0 52 L0 0 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath18"
><path d="M0 0 L162 0 L162 112 L0 112 L0 0 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath19"
><path d="M-77 -15 L154 -15 L154 30 L-77 30 L-77 -15 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath20"
><path d="M-92 -15 L184 -15 L184 30 L-92 30 L-92 -15 Z"
/></clipPath
><clipPath clipPathUnits="userSpaceOnUse" id="clipPath21"
><path d="M-57 -15 L114 -15 L114 30 L-57 30 L-57 -15 Z"
/></clipPath
></defs
><g fill="white" text-rendering="geometricPrecision" fill-opacity="1" stroke-opacity="1" stroke="white"
><rect x="0" width="466" height="151" y="0" stroke="none"
/></g
><g font-size="11" transform="translate(332,2)" fill-opacity="1" fill="url(#linearGradient1)" text-rendering="geometricPrecision" font-family="sans-serif" stroke="url(#linearGradient1)" font-weight="bold" stroke-opacity="1"
><rect x="0" width="130" height="100" y="0" clip-path="url(#clipPath1)" stroke="none"
/></g
><g font-size="11" stroke-linecap="butt" transform="translate(332,2)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke-linejoin="round" stroke="black" font-weight="bold" stroke-opacity="1" stroke-miterlimit="0"
><rect fill="none" x="0" width="130" height="100" y="0" clip-path="url(#clipPath1)"
/><line y2="15" fill="none" x1="0" clip-path="url(#clipPath1)" x2="130" y1="15"
/></g
><g font-size="11" transform="matrix(1,0,0,1,332,17)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" stroke-opacity="1"
><text x="2" xml:space="preserve" y="14" clip-path="url(#clipPath2)" stroke="none"
> :name : xsd:string</text
></g
><g font-size="11" transform="matrix(1,0,0,1,332,17)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" stroke-opacity="1"
>
<text x="2" xml:space="preserve" y="29" clip-path="url(#clipPath2)" stroke="none"
> :givenName : xsd:string</text
><text x="2" xml:space="preserve" y="44" clip-path="url(#clipPath2)" stroke="none"
> :familyName : xsd:string</text
>
<text x="2" xml:space="preserve" y="59" clip-path="url(#clipPath2)" stroke="none"
> :mbox : AnyURI</text
></g
><g font-size="11" transform="translate(332,2)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" font-weight="bold" stroke-opacity="1"
><text x="50" xml:space="preserve" y="12" clip-path="url(#clipPath3)" stroke="none"
>:User</text
></g
><g font-size="11" transform="translate(42,2)" fill-opacity="1" fill="url(#linearGradient2)" text-rendering="geometricPrecision" font-family="sans-serif" stroke="url(#linearGradient2)" font-weight="bold" stroke-opacity="1"
><rect x="0" width="170" height="100" y="0" clip-path="url(#clipPath4)" stroke="none"
/></g
><g font-size="11" stroke-linecap="butt" transform="translate(42,2)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke-linejoin="round" stroke="black" font-weight="bold" stroke-opacity="1" stroke-miterlimit="0"
><rect fill="none" x="0" width="170" height="100" y="0" clip-path="url(#clipPath4)"
/><line y2="15" fill="none" x1="0" clip-path="url(#clipPath4)" x2="170" y1="15"
/></g
><g font-size="11" transform="matrix(1,0,0,1,42,17)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" stroke-opacity="1"
><text x="2" xml:space="preserve" y="14" clip-path="url(#clipPath5)" stroke="none"
> :status = Assigned|Unassigned</text
></g
><g font-size="11" transform="matrix(1,0,0,1,42,17)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" stroke-opacity="1"
><text x="2" xml:space="preserve" y="29" clip-path="url(#clipPath5)" stroke="none"
> :reportedOn : xsd:dateTime</text
>
<text x="2" xml:space="preserve" y="44" clip-path="url(#clipPath5)" stroke="none"
> :reproducedOn : xsd:dateTime?</text
>
</g
><g font-size="11" transform="translate(42,2)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" font-weight="bold" stroke-opacity="1"
><text x="69" xml:space="preserve" y="12" clip-path="url(#clipPath6)" stroke="none"
>:Issue</text
></g
><g font-size="11" transform="translate(212,62)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" stroke-opacity="1"
><text x="10" xml:space="preserve" y="12" clip-path="url(#clipPath8)" stroke="none"
>0..*</text
></g
><g font-size="11" transform="translate(302,62)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" stroke-opacity="1"
><text x="10" xml:space="preserve" y="12" clip-path="url(#clipPath10)" stroke="none"
>0..1</text
></g
><g font-size="11" transform="translate(312,22)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" stroke-opacity="1"
><text x="10" xml:space="preserve" y="12" clip-path="url(#clipPath12)" stroke="none"
>1</text
></g
><g font-size="11" transform="translate(212,22)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" stroke-opacity="1"
><text x="10" xml:space="preserve" y="12" clip-path="url(#clipPath8)" stroke="none"
>0..*</text
></g
><g font-size="11" transform="translate(122,102)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" stroke-opacity="1"
><text x="9" xml:space="preserve" y="12" clip-path="url(#clipPath14)" stroke="none"
>0..*</text
></g
><g font-size="11" transform="translate(2,52)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" stroke-opacity="1"
><text x="10" xml:space="preserve" y="12" clip-path="url(#clipPath16)" stroke="none"
>0..1</text
></g
><g font-size="11" stroke-linecap="butt" transform="translate(188,18)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke-linejoin="round" stroke="black" stroke-opacity="1"
><line y2="24" fill="none" x1="143" clip-path="url(#clipPath17)" x2="24" y1="24"
/></g
><g font-size="11" stroke-linecap="butt" transform="translate(189,58)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke-linejoin="round" stroke="black" stroke-opacity="1"
><line y2="24" fill="none" x1="24" clip-path="url(#clipPath17)" x2="143" y1="24"
/></g
><g font-size="11" stroke-linecap="butt" transform="translate(-12,48)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke-linejoin="round" stroke="black" stroke-opacity="1"
><line y2="84" fill="none" x1="134" clip-path="url(#clipPath18)" x2="134" y1="55"
/><line y2="84" fill="none" x1="134" clip-path="url(#clipPath18)" x2="24" y1="84"
/><line y2="24" fill="none" x1="24" clip-path="url(#clipPath18)" x2="24" y1="84"
/><line y2="24" fill="none" x1="24" clip-path="url(#clipPath18)" x2="53" y1="24"
/></g
><g font-size="11" transform="translate(232,42)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" stroke-opacity="1"
><text x="10" xml:space="preserve" y="12" clip-path="url(#clipPath19)" stroke="none"
>:reportedBy</text
></g
><g font-size="11" transform="translate(222,82)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" stroke-opacity="1"
><text x="10" xml:space="preserve" y="12" clip-path="url(#clipPath20)" stroke="none"
>:reproducedBy</text
></g
><g font-size="11" transform="translate(22,132)" fill-opacity="1" fill="black" text-rendering="geometricPrecision" font-family="sans-serif" stroke="black" stroke-opacity="1"
><text x="10" xml:space="preserve" y="12" clip-path="url(#clipPath21)" stroke="none"
>:related</text
></g
><g fill="rgb(120,120,120)" text-rendering="geometricPrecision" fill-opacity="1" font-size="10" stroke-opacity="1" stroke="rgb(120,120,120)"
></g
></g
></svg
-->