├── .github └── CODEOWNERS ├── README.md ├── img ├── data_diagram.png └── data_diagram.svg └── index.html /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @rdfjs/data-model-spec 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RDF/JS Representation Task Force 2 | 3 | The RDF/JS Representation Task Force is a focus group of the [RDFJS Community Group](https://www.w3.org/community/rdfjs/). 4 | We strive to design interface specifications with the goal that different JavaScript implementations of RDF concepts can interoperate. 5 | 6 | The focus on this first [low level](https://github.com/rdfjs/rdfjs.org/wiki/Architecture#low-level) interface is to find a minimal API for access of RDF data which can be shared by JS Libraries. 7 | 8 | This repository contains documents created by the Representation Task Force: 9 | - [Interface Specification (Low Level)](http://rdf.js.org/) 10 | -------------------------------------------------------------------------------- /img/data_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdfjs/data-model-spec/77bcf6ebdb6d9c59b1089874b0ddcd5c6370a5b7/img/data_diagram.png -------------------------------------------------------------------------------- /img/data_diagram.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |81 |
82 |86 | This document provides a specification of a low level interface definition representing RDF data 87 | independent of a serialized format in a JavaScript environment. The task force which defines 88 | this interface was formed by RDF JavaScript library developers with the wish to make existing 89 | and future libraries interoperable. This definition strives to provide the minimal necessary 90 | interface to enable interoperability of libraries such as serializers, parsers and higher level 91 | accessors and manipulators. 92 |
93 |.equals()
.quad()
) or methods (e.g.,
112 | store.createQuad()
) create instances.
113 | 122 | A list of these properties maintained on the 123 | 124 | RDFJS Representation Task Force wiki 125 | . 126 |
127 |139 | [Exposed=(Window,Worker)] 140 | interface Term { 141 | attribute DOMString termType; 142 | attribute DOMString value; 143 | boolean equals(optional Term? other); 144 | }; 145 |146 | 147 |
148 | Term is an abstract interface. 149 |
150 |
151 | termType contains a value that identifies the concrete interface of the term, since
152 | Term itself is not directly instantiated. Possible values include "NamedNode"
,
153 | "BlankNode"
, "Literal"
, "Variable"
,
154 | "DefaultGraph"
and "Quad"
.
155 |
157 | value is refined by each interface which extends Term. 158 |
159 |
160 | equals() returns true
161 | when called with parameter other
162 | on an object term
if all of the conditions below hold:
163 |
other
is neither null
nor undefined
;term.termType
is the same string as other.termType
;other
follows the additional constraints of the specific Term
interface implemented by term
168 | (e.g., NamedNode, Literal, …);
171 | otherwise, it returns false
.
172 |
179 | [Exposed=(Window,Worker)] 180 | interface NamedNode : Term { 181 | attribute DOMString termType; 182 | attribute DOMString value; 183 | boolean equals(optional Term? other); 184 | }; 185 |186 | 187 |
188 | termType contains the constant "NamedNode"
.
189 |
191 | value the IRI of the named node (example: "http://example.org/resource"
).
192 |
194 | equals() returns true
if
195 | all general Term.equals conditions hold
196 | and term.value
is the same string as other.value
;
197 | otherwise, it returns false
.
198 |
205 | [Exposed=(Window,Worker)] 206 | interface BlankNode : Term { 207 | attribute DOMString termType; 208 | attribute DOMString value; 209 | boolean equals(optional Term? other); 210 | }; 211 |212 | 213 |
214 | termType contains the constant "BlankNode"
.
215 |
217 | value blank node name as a string, without any serialization specific prefixes,
218 | e.g. when parsing, if the data was sourced from Turtle, remove "_:"
, if it was
219 | sourced from RDF/XML, do not change the blank node name (example: "blank3"
)
220 |
222 | equals() returns true
if
223 | all general Term.equals conditions hold
224 | and term.value
is the same string as other.value
;
225 | otherwise, it returns false
.
226 |
233 | [Exposed=(Window,Worker)] 234 | interface Literal : Term { 235 | attribute DOMString termType; 236 | attribute DOMString value; 237 | attribute DOMString language; 238 | attribute DOMString? direction; 239 | attribute NamedNode datatype; 240 | boolean equals(optional Term? other); 241 | }; 242 |243 | 244 |
245 | termType contains the constant "Literal"
.
246 |
248 | value the text value, unescaped, without language or type (example:
249 | "Brad Pitt"
)
250 |
252 | language the language as lowercase [[BCP47]] string (examples:
253 | "en"
, "en-gb"
) or an empty string if the literal has no language.
254 |
256 | direction is not falsy if the string is a directional language-tagged string.
257 | In this case, the direction
MUST be either be "ltr"
or "rtl"
.
258 | Implementations supporting this feature should use an empty string when no direction is given.
259 | null
or undefined
values are allowed to maintain compatibility with legacy
260 | implementations.
261 |
263 | datatype a NamedNode
whose IRI represents the datatype of the literal.
264 |
266 | If the literal has a language and a direction, its datatype has the IRI
267 | "http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString"
.
268 | If the literal has a language without direction, its datatype has the IRI
269 | "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
. Otherwise, if no
270 | datatype is explicitly specified, the datatype has the IRI
271 | "http://www.w3.org/2001/XMLSchema#string"
.
272 |
274 | equals() returns true
if
275 | all general Term.equals conditions hold,
276 | term.value
is the same string as other.value
,
277 | term.language
is the same string as other.language
,
278 | term.direction
is the same string as other.direction
or are both falsy, and
279 | term.datatype.equals(other.datatype)
evaluates to true
;
280 | otherwise, it returns false
.
281 |
288 | [Exposed=(Window,Worker)] 289 | interface Variable : Term { 290 | attribute DOMString termType; 291 | attribute DOMString value; 292 | boolean equals(optional Term? other); 293 | }; 294 |295 | 296 |
297 | termType contains the constant "Variable"
.
298 |
300 | value the name of the variable without leading "?"
(example:
301 | "a"
).
302 |
304 | equals() returns true
if
305 | all general Term.equals conditions hold
306 | and term.value
is the same string as other.value
;
307 | otherwise, it returns false
.
308 |
315 | [Exposed=(Window,Worker)] 316 | interface DefaultGraph : Term { 317 | attribute DOMString termType; 318 | attribute DOMString value; 319 | boolean equals(optional Term? other); 320 | }; 321 |322 | 323 |
324 | An instance of DefaultGraph
represents the default graph. It's only allowed to
325 | assign a DefaultGraph
to the graph
property of a Quad
.
326 |
328 | termType contains the constant "DefaultGraph"
.
329 |
331 | value contains an empty string as constant value. 332 |
333 |
334 | equals() returns true
if
335 | all general Term.equals conditions hold;
336 | otherwise, it returns false
.
337 |
344 | [Exposed=(Window,Worker)] 345 | interface Quad : Term { 346 | attribute DOMString termType; 347 | attribute DOMString value; 348 | attribute Term subject; 349 | attribute Term predicate; 350 | attribute Term _object; 351 | attribute Term graph; 352 | boolean equals(optional Quad? other); 353 | }; 354 |355 | 356 |
357 | termType contains the constant "Quad"
.
358 |
360 | value contains an empty string as constant value. 361 |
362 |
363 | subject the subject, which is a NamedNode
, BlankNode
,
364 | Variable
or Quad
.
365 |
367 | predicate the predicate, which is a NamedNode
or
368 | Variable
.
369 |
371 | object the object, which is a NamedNode
, Literal
,
372 | BlankNode
or Variable
.
373 |
375 | graph the named graph, which is a DefaultGraph
,
376 | NamedNode
, BlankNode
or Variable
.
377 |
379 | Triple
MUST be represented as Quad
with graph
set to a DefaultGraph
380 |
382 | equals() returns true
383 | when called with parameter other
384 | on an object quad
if
385 | all of the conditions below hold:
386 |
other
is neither null
nor undefined
;quad.subject.equals(other.subject)
evaluates to true
;quad.predicate.equals(other.predicate)
evaluates to true
;quad.object.equals(other.object)
evaluates to a true
;quad.graph.equals(other.graph)
evaluates to a true
;
395 | otherwise, it returns false
.
396 |
403 | [Exposed=(Window,Worker)] 404 | interface DataFactory { 405 | NamedNode namedNode(DOMString value); 406 | BlankNode blankNode(optional DOMString value); 407 | Literal literal(DOMString value, optional (DOMString or NamedNode or DirectionalLanguage) languageOrDatatype); 408 | Variable variable(DOMString value); 409 | DefaultGraph defaultGraph(); 410 | Quad quad(Term subject, Term predicate, Term _object, optional Term? graph); 411 | Term fromTerm(Term original); 412 | Quad fromQuad(Quad original); 413 | }; 414 | 415 | [Exposed=(Window,Worker)] 416 | interface DirectionalLanguage { 417 | attribute DOMString language; 418 | attribute DOMString? direction; 419 | }; 420 |421 | 422 |
423 | For default values of the instance properties and valid values requirements, 424 | see the individual interface definitions. 425 |
426 |
427 | namedNode() returns a new instance of NamedNode
.
428 |
430 | blankNode() returns a new instance of BlankNode
. If the value
431 | parameter is undefined a new identifier for the blank node is generated for each call.
432 |
434 | literal() returns a new instance of Literal
.
435 | If languageOrDatatype
is a NamedNode
,
436 | then it is used for the value of datatype
.
437 | If languageOrDatatype
is a DirectionalLanguage
,
438 | then its language
and direction
attributes
439 | are respectively used for the literal's language
and direction
, where direction
is optional or can be falsy.
440 | Otherwise languageOrDatatype
is used for the value of language
.
441 |
443 | variable() returns a new instance of Variable
. This method is
444 | optional.
445 |
447 | defaultGraph() returns an instance of DefaultGraph
.
448 |
450 | quad()returns a new instance of Quad
.
451 | If graph
is undefined
or null
452 | it MUST set graph
to a DefaultGraph
.
453 |
455 | fromTerm() returns a new instance of the specific Term
subclass given by original.termType
456 | (e.g., NamedNode
, BlankNode
, Literal
, etc.),
457 | such that newObject.equals(original)
returns true
.
458 |
460 | fromQuad() returns a new instance of Quad
,
461 | such that newObject.equals(original)
returns true
.
462 |