├── .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 |
Term
Term
termType: String
value: String
termType: String<div>value: String</div>
equals( other:Term ): boolean
equals( other:Term ): boolean
NamedNode
NamedNode
termType: String = "NamedNode"
value: String
termType: String = "NamedNode"<div>value: String</div>
equals( other:Term ): boolean

equals( <span>other:</span>Term ): boolean<div><br></div>
Extends
Extends
BlankNode
BlankNode
termType: String = "BlankNode"
value: String
termType: String = "BlankNode"<div>value: String</div>
equals( other:Term ): boolean

equals( <span>other:</span>Term ): boolean<div><br></div>
Literal
Literal
termType: String = "Literal"
value: String
language: BCP47 String
datatype: NamedNode
[Not supported by viewer]
equals( other:Term ): boolean

equals( <span>other:</span>Term ): boolean<div><br></div>
Extends
Extends
Extends
Extends
Variable
Variable
termType: String = "Variable"
value: String
termType: String = "Variable"<div>value: String</div>
equals( other:Term ): boolean

equals( <span>other:</span>Term ): boolean<div><br></div>
Extends
Extends
Quad
Quad
subject: Term
predicate: Term
object: Term
graph: Term
[Not supported by viewer]
equals( other:Quad ): boolean

equals( <span>other:</span>Quad ): boolean<div><br></div>
4
4
DefaultGraph
DefaultGraph
termType: String = "DefaultGraph"
value: String = ""
termType: String = "DefaultGraph"<div>value: String = ""</div>
equals( other:Term ): boolean

equals( <span>other:</span>Term ): boolean<div><br></div>
Extends
Extends
DataFactory
DataFactory
 

[Not supported by viewer]
namedNode( value:String ): NamedNode
blankNode( [value:String] ): BlankNode
literal( value:String, [languageOrDatatype:String|NamedNode] ): Literal
variable( value:String ): Variable
defaultGraph( ): DefaultGraph
quad( subject:Term, predicate:Term, object:Term, [graph:Term] ): Quad
[Not supported by viewer]
-------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RDF/JS: Data model specification 6 | 7 | 77 | 78 | 79 |
80 |

81 |

82 |
83 | 84 |
85 |

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 |
94 | 95 |
96 |

Design elements and principles

97 | 98 | 120 | 121 |

122 | A list of these properties maintained on the 123 | 124 | RDFJS Representation Task Force wiki 125 | . 126 |

127 |
128 | 129 |
130 |

Data interfaces

131 | 132 | UML data interface diagram 133 | 134 | 135 |
136 |

Term interface

137 | 138 |
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 |

156 |

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 |

164 | 170 |

171 | otherwise, it returns false. 172 |

173 |
174 | 175 |
176 |

NamedNode interface

177 | 178 |
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 |

190 |

191 | value the IRI of the named node (example: "http://example.org/resource"). 192 |

193 |

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 |

199 |
200 | 201 |
202 |

BlankNode interface

203 | 204 |
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 |

216 |

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 |

221 |

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 |

227 |
228 | 229 |
230 |

Literal interface

231 | 232 |
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 |

247 |

248 | value the text value, unescaped, without language or type (example: 249 | "Brad Pitt") 250 |

251 |

252 | language the language as lowercase [[BCP47]] string (examples: 253 | "en", "en-gb") or an empty string if the literal has no language. 254 |

255 |

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 |

262 |

263 | datatype a NamedNode whose IRI represents the datatype of the literal. 264 |

265 |

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 |

273 |

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 |

282 |
283 | 284 |
285 |

Variable interface

286 | 287 |
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 |

299 |

300 | value the name of the variable without leading "?" (example: 301 | "a"). 302 |

303 |

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 |

309 |
310 | 311 |
312 |

DefaultGraph interface

313 | 314 |
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 |

327 |

328 | termType contains the constant "DefaultGraph". 329 |

330 |

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 |

338 |
339 | 340 |
341 |

Quad interface

342 | 343 |
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 |

359 |

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 |

366 |

367 | predicate the predicate, which is a NamedNode or 368 | Variable. 369 |

370 |

371 | object the object, which is a NamedNode, Literal, 372 | BlankNode or Variable. 373 |

374 |

375 | graph the named graph, which is a DefaultGraph, 376 | NamedNode, BlankNode or Variable. 377 |

378 |

379 | Triple MUST be represented as Quad with graph set to a DefaultGraph 380 |

381 |

382 | equals() returns true 383 | when called with parameter other 384 | on an object quad if 385 | all of the conditions below hold: 386 |

387 | 394 |

395 | otherwise, it returns false. 396 |

397 |
398 | 399 |
400 |

DataFactory interface

401 | 402 |
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 |

429 |

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 |

433 |

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 |

442 |

443 | variable() returns a new instance of Variable. This method is 444 | optional. 445 |

446 |

447 | defaultGraph() returns an instance of DefaultGraph. 448 |

449 |

450 | quad()returns a new instance of Quad. 451 | If graph is undefined or null 452 | it MUST set graph to a DefaultGraph. 453 |

454 |

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 |

459 |

460 | fromQuad() returns a new instance of Quad, 461 | such that newObject.equals(original) returns true. 462 |

463 |
464 |
465 | 466 |
467 | 468 | 469 | --------------------------------------------------------------------------------