From 264c6bead90d077ffebe5795796d7bd0fb86d873 Mon Sep 17 00:00:00 2001
From: bergi
+
+ 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.
+
+ A list of these properties maintained on the
+
+ RDFJS Representation Task Force wiki
+ .
+
+ Term is an abstract interface.
+
+ termType contains a value that identifies the concrete interface of the term, since
+ Term itself is not directly instantiated. Possible values include
+ value is refined by each interface which extends Term.
+
+ equals() returns
+ termType contains the constant
+ value the IRI of the named node (example:
+ equals() returns
+ termType contains the constant
+ value blank node name as a string, without any serialization specific prefixes,
+ e.g. when parsing, if the data was sourced from Turtle, remove
+ equals() returns
+ termType contains the constant
+ value the text value, unescaped, without language or type (example:
+
+ language the language as lowercase BCP-47 [[!BCP47]] string (examples:
+
+ datatype a
+ If the literal has a language, its datatype has the IRI
+
+ equals() returns
+ termType contains the constant
+ value the name of the variable without leading
+ equals() returns
+ An instance of
+ termType contains the constant
+ value contains an empty string as constant value.
+
+ equals() returns
+ Triple is an alias of Quad.
+
+ subject the subject, which is a
+ predicate the predicate, which is a
+ object the object, which is a
+ graph the named graph, which is a
+ equals() returns
+ For default values of the instance properties and valid values requirements,
+ see the individual interface definitions.
+
+ namedNode() returns a new instance of
+ blankNode() returns a new instance of
+ literal() returns a new instance of
+ variable() returns a new instance of
+ defaultGraph() returns an instance of
+ triple() returns a new instance of
+ quad()returns a new instance of
+ Streams are used only in a readable manner. This requires only a single queue per stream, which
+ simplifies implementations and doesn't have performance drawbacks, compared to writeable
+ streams.
+
+ read() This method pulls a quad out of the internal buffer and returns it. If there
+ is no quad available, then it will return null.
+
+ readable When a quad can be read from the stream, it will emit this event.
+
+ end This event fires when there will be no more quads to read.
+
+ error `error(Error error)` This event fires if any error occurs. The `message` describes the error.
+
+ data `data(Quad quad)` This event is emitted for every quad that can be read from the stream. The `quad` is the content of the data.
+
+ These events are not required, but if an implementation wishes to support such events, they should conform to these definitions:
+
+ prefix `prefix(string prefix, NamedNode iri)` This event is emitted every time a prefix is mapped to some IRI.
+
+ A Source is an object that emits quads. It can contain quads but also generate them on the
+ fly. For example, parsers and transformations which generate quads can implement the Source
+ interface.
+
+ match() Returns a stream that processes all quads matching the pattern.
+
+ A Sink is an object that consumes data from different kinds of streams. It can store the
+ content of the stream or do some further processing. For example parsers, serializers,
+ transformations and stores can implement the Sink interface.
+
+ import() Consumes the given stream. The
+ A Store is an object that usually used to persist quads. The interface allows removing quads,
+ beside read and write access. The quads can be stored locally or remotely. Access to stores
+ LDP or SPARQL endpoints can be implemented with a Store inteface.
+
+ remove() Removes all streamed quads. The
+ removeMatches() All quads matching the pattern will be removed. The
+
+ deleteGraph() Deletes the given named graph. The Design elements and principles
+
+
+
+
+ .equals()
.quad()
) or methods (e.g.,
+ store.createQuad()
) create instances.
+ Data interfaces
+
+
+
+
+ Term interface
+
+
+ interface Term {
+ attribute string termType;
+ attribute string value;
+ boolean equals(Term other);
+ };
+
+
+ "NamedNode"
,
+ "BlankNode"
, "Literal"
, "Variable"
and
+ "DefaultGraph"
.
+ true
if and only if other
has the same
+ termType
and the same contents (as defined by concrete subclasses).
+ NamedNode interface
+
+
+ interface NamedNode : Term {
+ attribute string termType;
+ attribute string value;
+ boolean equals(Term other);
+ };
+
+
+ "NamedNode"
.
+ "http://example.org/resource"
).
+ true
if and only if other
has
+ termType
"NamedNode"
and the same value.
+
BlankNode interface
+
+
+ interface BlankNode : Term {
+ attribute string termType;
+ attribute string value;
+ boolean equals(Term other);
+ };
+
+
+ "BlankNode"
.
+ "_:"
, if it was
+ sourced from RDF/XML, do not change the blank node name (example: "blank3"
)
+ true
if and only if other
has
+ termType
"BlankNode"
and the same value
.
+ Literal interface
+
+
+ interface Literal : Term {
+ attribute string termType;
+ attribute string value;
+ attribute string language;
+ attribute NamedNode datatype;
+ boolean equals(Term other);
+ };
+
+
+ "Literal"
.
+ "Brad Pitt"
)
+ "en"
, "en-gb"
) or an empty string if the literal has no language.
+ NamedNode
whose IRI represents the datatype of the literal.
+ "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
. Otherwise, if no
+ datatype is explicitly specified, the datatype has the IRI
+ "http://www.w3.org/2001/XMLSchema#string"
.
+ true
if and only if other
has
+ termType
"Literal"
and the same value
,
+ language
, and datatype
.
+ Variable interface
+
+
+ interface Variable : Term {
+ attribute string termType;
+ attribute string value;
+ boolean equals(Term other);
+ };
+
+
+ "Variable"
.
+ "?"
(example:
+ "a"
).
+ true
if and only if other
has
+ termType
"Variable"
and the same value
.
+ DefaultGraph interface
+
+
+ interface DefaultGraph : Term {
+ attribute string termType;
+ attribute string value;
+ boolean equals(Term other);
+ };
+
+
+ DefaultGraph
represents the default graph. It's only allowed to
+ assign a DefaultGraph
to the graph
property of a Quad
.
+ "DefaultGraph"
.
+ true
if and only if other
has
+ termType
"DefaultGraph"
.
+ Triple interface
+
+
+ interface Triple {};
+
+ Triple implements Quad;
+
+
+ Quad interface
+
+
+ interface Quad {
+ attribute Term subject;
+ attribute Term predicate;
+ attribute Term object;
+ attribute Term graph;
+ boolean equals(Quad other);
+ };
+
+
+ NamedNode
, BlankNode
or
+ Variable
.
+ NamedNode
or
+ Variable
.
+ NamedNode
, Literal
,
+ BlankNode
or Variable
.
+ DefaultGraph
,
+ NamedNode
, BlankNode
or Variable
.
+ true
if and only if the argument is a) of the same
+ type b) has all components equal.
+ DataFactory interface
+
+
+ interface DataFactory {
+ NamedNode namedNode(string value);
+ BlankNode blankNode(optional string value);
+ Literal literal(string value, optional (string or NamedNode) languageOrDatatype);
+ Variable variable(string value);
+ DefaultGraph defaultGraph();
+ Quad triple(Term subject, Term predicate, Term object);
+ Quad quad(Term subject, Term predicate, Term object, optional Term graph);
+ };
+
+
+ NamedNode
.
+ BlankNode
. If the value
+ parameter is undefined a new identifier for the blank node is generated for each call.
+ Literal
. If
+ languageOrDatatype
is a NamedNode
, then it is used for the value of
+ datatype
. Otherwise languageOrDatatype
is used for the value of
+ language
.
+ Variable
. This method is
+ optional.
+ DefaultGraph
.
+ Quad
with graph
set to
+ DefaultGraph
.
+ Quad
.
+ Stream interfaces
+ Stream interface
+
+
+ interface Stream : EventEmitter {
+ Quad read();
+ attribute Event readable;
+ attribute Event end;
+ attribute Event error;
+ attribute Event data;
+ attribute Event prefix;
+ };
+
+
+ Optional Events
+ Source interface
+
+
+ interface Source {
+ Stream match(optional (Term or RegExp) subject, optional (Term or RegExp) predicate, optional (Term or RegExp) object, optional (Term or RegExp) graph);
+ };
+
+
+ Sink interface
+
+
+ interface Sink {
+ EventEmitter import(Stream stream);
+ };
+
+
+ end
and error
+ events are used like described in the Stream
interface. Depending on the use
+ case, subtypes of EventEmitter
or Stream
are used.
+ Typical use cases
+
+
+ Stream<Quad> import(Stream stream)
Stream import(Stream<Quad> stream)
Stream<Quad> import(Stream<Quad> stream)
EventEmitter .import(Stream<Quad> stream)
Store interface
+
+
+ interface Store {
+ EventEmitter remove(Stream stream);
+ EventEmitter removeMatches(optional (Term or RegExp) subject, optional (Term or RegExp) predicate, optional (Term or RegExp) object, optional (Term or RegExp) graph);
+ EventEmitter deleteGraph((Term or string) graph);
+ };
+
+ Store implements Source;
+ Store implements Sink;
+
+
+ end
and error
+ events are used like described in the Stream
interface.
+ end
and error
events are used like described in the
+ Stream
interface.
+ end
and
+ error
events are used like described in the Stream
interface.
+ Design elements and principles
Data interfaces
-
+
Stream interfaces
streams.