-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
438 lines (406 loc) · 15.1 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>RDF/JS: Data model specification</title>
<script src="https://www.w3.org/Tools/respec/respec-w3c" class="remove"></script>
<script class="remove">
var respecConfig = {
specStatus: "CG-DRAFT",
shortName: "rdfjs",
subtitle: "RDF/JS: Data model specification",
processVersion: 2017,
edDraftURI: "https://github.com/rdfjs/data-model-spec/",
issueBase: "https://github.com/rdfjs/data-model-spec/issues/",
githubAPI: "https://api.github.com/repos/rdfjs/data-model-spec",
// TODO: testSuiteURIkey: "",
editors: [{
name: "Thomas Bergwinkl",
url: "https://www.bergnet.org/"
}, {
name: "Ruben Verborgh",
url: "https://ruben.verborgh.org/",
company: "Ghent University – imec",
companyURL: "http://idlab.ugent.be/"
}],
authors: [{
name: "Thomas Bergwinkl",
url: "https://www.bergnet.org/"
}, {
name: "Michael Luggen",
url: "http://oiu.ch",
company: "Bern University of Applied Sciences",
companyURL: "http://www.bfh.ch"
}, {
name: "elf Pavlik",
url: "https://elf-pavlik.hackers4peace.net/"
}, {
name: "Blake Regalia",
company: "STKO Lab @ UCSB",
companyURL: "http://stko.geog.ucsb.edu/"
}, {
name: "Piero Savastano",
url: "http://pieroit.org",
company: "Freelance Data Scientist"
}, {
name: "Ruben Verborgh",
url: "https://ruben.verborgh.org/",
company: "Ghent University – imec",
companyURL: "http://idlab.ugent.be/"
}],
bugTracker: {
open: "https://github.com/rdfjs/data-model-spec/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20",
new: "https://github.com/rdfjs/data-model-spec/issues/new"
},
otherLinks: [{
key: "Version control",
data: [{
value: "Github Repository",
href: "https://github.com/rdfjs/data-model-spec"
}]
}],
group: "cg/rdfjs",
wgPublicList: "public-rdfjs",
maxTocLevel: 2
};
</script>
</head>
<body>
<section id="abstract">
<p>
</p>
</section>
<section id="sotd">
<p>
This document provides a specification of a low level interface definition representing RDF data
independent of a serialized format in a JavaScript environment. The task force which defines
this interface was formed by RDF JavaScript library developers with the wish to make existing
and future libraries interoperable. This definition strives to provide the minimal necessary
interface to enable interoperability of libraries such as serializers, parsers and higher level
accessors and manipulators.
</p>
</section>
<section>
<h2>Design elements and principles</h2>
<ul>
<li>
We define data interfaces to represent <strong>quads</strong>,
<strong>named nodes</strong>, <strong>blank nodes</strong>, <strong>literals</strong> and
<strong>variables</strong>.
</li>
<li>Instances of the interfaces created with different libraries should be interoperable.</li>
<li>Interfaces do <em>not</em> specify how instances are stored in memory.</li>
<li>Interfaces mandate specific pre-defined methods such as <code>.equals()</code>.</li>
<li>
Interfaces are not expected to expose internal objects or return the same object from sucessive calls. Equivalence is tested with the `Term.equals()` function instead of `===` or `==`.
</li>
<li>
Factory functions (e.g., <code>quad()</code>) or methods (e.g.,
<code>store.createQuad()</code>) create instances.
</li>
<li>Interfaces may have additional implementation specific properties.</li>
<li>
We don't define any validation of given values (e.g. IRI, URI, CURIE).
Implementations that apply validation should make this fact clear in their documentation.
</li>
</ul>
<p>
A list of these properties maintained on the
<a href="https://github.com/rdfjs/data-model-spec/wiki/Additional-properties">
RDFJS Representation Task Force wiki
</a>.
</p>
</section>
<section>
<h2>Data interfaces</h2>
<img src="img/data_diagram.svg" alt="UML data interface diagram" style="width: 100%;">
<section data-dfn-for="Term">
<h3><dfn>Term</dfn> interface</h3>
<pre class="idl">
[Exposed=(Window,Worker)]
interface Term {
attribute DOMString termType;
attribute DOMString value;
boolean equals(optional Term? other);
};
</pre>
<p>
<a>Term</a> is an abstract interface.
</p>
<p>
<dfn>termType</dfn> contains a value that identifies the concrete interface of the term, since
Term itself is not directly instantiated. Possible values include <code>"NamedNode"</code>,
<code>"BlankNode"</code>, <code>"Literal"</code>, <code>"Variable"</code>,
<code>"DefaultGraph"</code> and <code>"Quad"</code>.
</p>
<p>
<dfn>value</dfn> is refined by each interface which extends Term.
</p>
<p>
<dfn>equals()</dfn> returns <code>true</code>
when called with parameter <code>other</code>
on an object <code>term</code> if all of the conditions below hold:
</p>
<ul>
<li><code>other</code> is <em>neither</em> <code>null</code> nor <code>undefined</code>;</li>
<li><code>term.termType</code> is the same string as <code>other.termType</code>;</li>
<li><code>other</code> follows the additional constraints of the specific <code>Term</code> interface implemented by <code>term</code>
(e.g., <a>NamedNode</a>, <a>Literal</a>, …);</li>
</ul>
<p>
otherwise, it returns <code>false</code>.
</p>
</section>
<section data-dfn-for="NamedNode">
<h3><dfn>NamedNode</dfn> interface</h3>
<pre class="idl">
[Exposed=(Window,Worker)]
interface NamedNode : Term {
attribute DOMString termType;
attribute DOMString value;
boolean equals(optional Term? other);
};
</pre>
<p>
<dfn>termType</dfn> contains the constant <code>"NamedNode"</code>.
</p>
<p>
<dfn>value</dfn> the IRI of the named node (example: <code>"http://example.org/resource"</code>).
</p>
<p>
<dfn>equals()</dfn> returns <code>true</code> if
all general <a>Term.equals</a> conditions hold
and <code>term.value</code> is the same string as <code>other.value</code>;
otherwise, it returns <code>false</code>.
</p>
</section>
<section data-dfn-for="BlankNode">
<h3><dfn>BlankNode</dfn> interface</h3>
<pre class="idl">
[Exposed=(Window,Worker)]
interface BlankNode : Term {
attribute DOMString termType;
attribute DOMString value;
boolean equals(optional Term? other);
};
</pre>
<p>
<dfn>termType</dfn> contains the constant <code>"BlankNode"</code>.
</p>
<p>
<dfn>value</dfn> blank node name as a string, without any serialization specific prefixes,
e.g. when parsing, if the data was sourced from Turtle, remove <code>"_:"</code>, if it was
sourced from RDF/XML, do not change the blank node name (example: <code>"blank3"</code>)
</p>
<p>
<dfn>equals()</dfn> returns <code>true</code> if
all general <a>Term.equals</a> conditions hold
and <code>term.value</code> is the same string as <code>other.value</code>;
otherwise, it returns <code>false</code>.
</p>
</section>
<section data-dfn-for="Literal">
<h3><dfn>Literal</dfn> interface</h3>
<pre class="idl">
[Exposed=(Window,Worker)]
interface Literal : Term {
attribute DOMString termType;
attribute DOMString value;
attribute DOMString language;
attribute NamedNode datatype;
boolean equals(optional Term? other);
};
</pre>
<p>
<dfn>termType</dfn> contains the constant <code>"Literal"</code>.
</p>
<p>
<dfn>value</dfn> the text value, unescaped, without language or type (example:
<code>"Brad Pitt"</code>)
</p>
<p>
<dfn>language</dfn> the language as lowercase [[BCP47]] string (examples:
<code>"en"</code>, <code>"en-gb"</code>) or an empty string if the literal has no language.
</p>
<p>
<dfn>datatype</dfn> a <code>NamedNode</code> whose IRI represents the datatype of the literal.
</p>
<p>
If the literal has a language, its datatype has the IRI
<code>"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"</code>. Otherwise, if no
datatype is explicitly specified, the datatype has the IRI
<code>"http://www.w3.org/2001/XMLSchema#string"</code>.
</p>
<p>
<dfn>equals()</dfn> returns <code>true</code> if
all general <a>Term.equals</a> conditions hold,
<code>term.value</code> is the same string as <code>other.value</code>,
<code>term.language</code> is the same string as <code>other.language</code>, and
<code>term.datatype.equals(other.datatype)</code> evaluates to <code>true</code>;
otherwise, it returns <code>false</code>.
</p>
</section>
<section data-dfn-for="Variable">
<h3><dfn>Variable</dfn> interface</h3>
<pre class="idl">
[Exposed=(Window,Worker)]
interface Variable : Term {
attribute DOMString termType;
attribute DOMString value;
boolean equals(optional Term? other);
};
</pre>
<p>
<dfn>termType</dfn> contains the constant <code>"Variable"</code>.
</p>
<p>
<dfn>value</dfn> the name of the variable without leading <code>"?"</code> (example:
<code>"a"</code>).
</p>
<p>
<dfn>equals()</dfn> returns <code>true</code> if
all general <a>Term.equals</a> conditions hold
and <code>term.value</code> is the same string as <code>other.value</code>;
otherwise, it returns <code>false</code>.
</p>
</section>
<section data-dfn-for="DefaultGraph">
<h3><dfn>DefaultGraph</dfn> interface</h3>
<pre class="idl">
[Exposed=(Window,Worker)]
interface DefaultGraph : Term {
attribute DOMString termType;
attribute DOMString value;
boolean equals(optional Term? other);
};
</pre>
<p>
An instance of <code>DefaultGraph</code> represents the default graph. It's only allowed to
assign a <code>DefaultGraph</code> to the <code>graph</code> property of a <code>Quad</code>.
</p>
<p>
<dfn>termType</dfn> contains the constant <code>"DefaultGraph"</code>.
</p>
<p>
<dfn>value</dfn> contains an empty string as constant value.
</p>
<p>
<dfn>equals()</dfn> returns <code>true</code> if
all general <a>Term.equals</a> conditions hold;
otherwise, it returns <code>false</code>.
</p>
</section>
<section data-dfn-for="Quad">
<h3><dfn>Quad</dfn> interface</h3>
<pre class="idl">
[Exposed=(Window,Worker)]
interface Quad : Term {
attribute DOMString termType;
attribute DOMString value;
attribute Term subject;
attribute Term predicate;
attribute Term _object;
attribute Term graph;
boolean equals(optional Quad? other);
};
</pre>
<p>
<dfn>termType</dfn> contains the constant <code>"Quad"</code>.
</p>
<p>
<dfn>value</dfn> contains an empty string as constant value.
</p>
<p>
<dfn>subject</dfn> the subject, which is a <code>NamedNode</code>, <code>BlankNode</code>,
<code>Variable</code> or <code>Quad</code>.
</p>
<p>
<dfn>predicate</dfn> the predicate, which is a <code>NamedNode</code> or
<code>Variable</code>.
</p>
<p>
<dfn>object</dfn> the object, which is a <code>NamedNode</code>, <code>Literal</code>,
<code>BlankNode</code> or <code>Variable</code>.
</p>
<p>
<dfn>graph</dfn> the named graph, which is a <code>DefaultGraph</code>,
<code>NamedNode</code>, <code>BlankNode</code> or <code>Variable</code>.
</p>
<p class="note">
<code>Triple</code> MUST be represented as <code>Quad</code> with <code>graph</code> set to a <code>DefaultGraph</code>
</p>
<p>
<dfn>equals()</dfn> returns <code>true</code>
when called with parameter <code>other</code>
on an object <code>quad</code> if
all of the conditions below hold:
</p>
<ul>
<li><code>other</code> is <em>neither</em> <code>null</code> nor <code>undefined</code>;</li>
<li><code>quad.subject.equals(other.subject)</code> evaluates to <code>true</code>;</li>
<li><code>quad.predicate.equals(other.predicate)</code> evaluates to <code>true</code>;</li>
<li><code>quad.object.equals(other.object)</code> evaluates to a <code>true</code>;</li>
<li><code>quad.graph.equals(other.graph)</code> evaluates to a <code>true</code>;</li>
</ul>
<p>
otherwise, it returns <code>false</code>.
</p>
</section>
<section data-dfn-for="DataFactory">
<h3><dfn>DataFactory</dfn> interface</h3>
<pre class="idl">
[Exposed=(Window,Worker)]
interface DataFactory {
NamedNode namedNode(DOMString value);
BlankNode blankNode(optional DOMString value);
Literal literal(DOMString value, optional (DOMString or NamedNode) languageOrDatatype);
Variable variable(DOMString value);
DefaultGraph defaultGraph();
Quad quad(Term subject, Term predicate, Term _object, optional Term? graph);
Term fromTerm(Term original);
Quad fromQuad(Quad original);
};
</pre>
<p>
For default values of the instance properties and valid values requirements,
see the individual <a href="#data-interfaces">interface definitions</a>.
</p>
<p>
<dfn>namedNode()</dfn> returns a new instance of <code>NamedNode</code>.
</p>
<p>
<dfn>blankNode()</dfn> returns a new instance of <code>BlankNode</code>. If the value
parameter is undefined a new identifier for the blank node is generated for each call.
</p>
<p>
<dfn>literal()</dfn> returns a new instance of <code>Literal</code>. If
<code>languageOrDatatype</code> is a <code>NamedNode</code>, then it is used for the value of
<code>datatype</code>. Otherwise <code>languageOrDatatype</code> is used for the value of
<code>language</code>.
</p>
<p>
<dfn>variable()</dfn> returns a new instance of <code>Variable</code>. This method is
optional.
</p>
<p>
<dfn>defaultGraph()</dfn> returns an instance of <code>DefaultGraph</code>.
</p>
<p>
<dfn>quad()</dfn>returns a new instance of <code>Quad</code>.
If <code>graph</code> is <code>undefined</code> or <code>null</code>
it MUST set <code>graph</code> to a <code>DefaultGraph</code>.
</p>
<p>
<dfn>fromTerm()</dfn> returns a new instance of the specific <code>Term</code> subclass given by <code>original.termType</code>
(e.g., <code>NamedNode</code>, <code>BlankNode</code>, <code>Literal</code>, etc.),
such that <code>newObject.equals(original)</code> returns <code>true</code>.
</p>
<p>
<dfn>fromQuad()</dfn> returns a new instance of <code>Quad</code>,
such that <code>newObject.equals(original)</code> returns <code>true</code>.
</p>
</section>
</section>
<section id="conformance"></section>
</body>
</html>