Work on this document has been put on hold indefinitely due to lack of interest. While a significant amount of design work went into this document, at present, there are no known implementations of the specification. There are numerous design issues with this specification and it is not advised that developers implement this API unless they are fully familiar with the drawbacks present in the current design.
The RDF Interfaces Specification defines a set of standardized interfaces for working with RDF data in a programming environment. This specification outlines three distinct sets of interfaces:
Work on this document has been put on hold indefinitely due to lack of interest. While a significant amount of design work went into this document, at present, there are no known implementations of the specification. There are numerous design issues with this specification and it is not advised that developers implement this API unless they are fully familiar with the drawbacks present in the current design.
This document is a detailed specification for the RDF Interfaces. The document is primarily intended for the following audiences:
This is a preliminary specification and is therefore fairly unstable. Implementers are warned that the interfaces in this document may change on a frequent basis until the specification reaches W3C Last Call status.
If you are not familiar with RDF, you should read about the Resource Description Framework (RDF) [[RDF-CONCEPTS]] before reading this document.
Readers who are not familiar with the Terse RDF Triple Language [[TURTLE]] may want to read the specification in order to understand the short-hand RDF notation used in some of the examples.
This document uses the Web Interface Definition Language [[WEBIDL]] to specify all language bindings. If you intend to implement any part of the RDF Interfaces you should be familiar with the Web IDL language [[WEBIDL]].
Examples may contain references to existing vocabularies and use abbreviations in CURIEs and source code. The following is a list of all vocabularies and their abbreviations, as used in this document:
rdf
, e.g., rdf:type
)xsd
, e.g., xsd:integer
)rdfs
, e.g., rdfs:label
)foaf
, e.g., foaf:name
)Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. In particular, the algorithms defined in this specification are intended to be easy to follow, and not intended to be performant.
User agents may impose implementation-specific limits on otherwise unconstrained inputs, e.g. to prevent denial of service attacks, to guard against running out of memory, or to work around platform-specific limitations.
Implementations that use ECMAScript or Java to implement the Interfaces defined in this specification must implement them in a manner consistent with the respective ECMAScript or Java Bindings defined in the Web IDL specification, as this specification uses that specification's terminology. [[!WEBIDL]]
Implementations that use any other language to implement the Interfaces defined in this specification that do not have bindings defined in the Web IDL specification should attempt to map the Interfaces as closely as possible to the implementation language's native mechanisms and datatypes. Developers are encouraged to work with other developers who are providing the RDF Interfaces in the same langauge to ensure that implementations are modular and easily exchangable.
The RDF Concept Interfaces in this specification provide a low level API for working with RDF data.
The concepts described in this specification are more generalized than those defined by the RDF Data Model [[RDF-CONCEPTS]]. Whilst this may appear to be a mismatch, the RDF specification is intended to define a notation for transmitting data on the Web, however this specification defines a set of interfaces for working with that data, behind the public interface, where more generalized notions of Triples are often required by libraries and modules.
The core interfaces for working with RDF defined by this specification are as follows:
A Triple consists of three components:
subject
, which is an RDFNode
predicate
, which is an RDFNode
object
, which is an RDFNode
Triples are the basic data structure utilized by RDF to express statements.
Throughout documentation and examples, Triples are conventionally written in the order subject, predicate, object - for example:
<http://example.org/hp> rdfs:label "Harry
Potter" .
A node identified by an IRI. For example: <http://example.org/people#mark>
Note: IRIs are defined by International Resource Identifier [[!IRI]] and are compatible with RDF URI references as defined by RDF Concepts [[!RDF-CONCEPTS]].
A blank node is a reference to an unnamed resource (one for
which an IRI is not known), and may be used in a
BlankNodes are typically stringified by prepending "_:
"
to a unique value, for instance _:b142
or _:me
,
this stringified form is referred to as a "blank node identifier".
Note: Blank node identifiers are only guaranteed to be unique
within a single instance of a single
A literal value, optionally combined with a language attribute and/or a datatype attribute.
Literals are used for untyped string data, plain text in a natural language, or values which have a specific datatype. For example:
"Harry Potter and the Half-Blood Prince"@en
is
plain text expressed in the English language."7"^^xsd:integer
is a value with a datatype of xsd:integer
.In addition to the above, this specification provides an
Implementers may provide additional types and/or a deeper type or class hierarchy so long as it includes these basic types.
The
Implementors should be aware that a UTF-8 version of N-Triples may be defined by the RDF WG,
as such the definition/implementation of the toString
method may change.
true
if otherTriple
is equivalent to this triple.
A
This method removes those triples in the current instance which match the given arguments, that is, for each triple in this graph, it is removed, if:
triple.subject.equals
with the specified subject
as an argument returns true
, or the subject
argument is null
, ANDtriple.predicate.equals
with the specified predicate
as an argument returns true
, or the predicate
argument is null
, ANDtriple.object.equals
with the specified object
as an argument returns true
, or the object
argument is null
null
.null
.null
.Returns the set of Array
in ECMAScript-262.
Note: a sequence
in [[!WEBIDL]] is passed by value,
not by reference.
Note: the order of the
Existential quantification method, tests whether some
This method will return boolean true
when the first
Note: this method is aligned with Array.prototype.some()
in ECMAScript-262.
Universal quantification method, tests whether every
This method will return boolean false
when the
first
Note: this method is aligned with Array.prototype.every()
in ECMAScript-262.
Creates a new
Note: this method is aligned with Array.prototype.filter()
in ECMAScript-262.
Executes the provided
Note: this method is aligned with Array.prototype.forEach()
in ECMAScript-262.
This method returns a new
triple.subject.equals
with the specified subject
as an argument returns true
, or the subject
argument is null
, ANDtriple.predicate.equals
with the specified predicate
as an argument returns true
, or the predicate
argument is null
, ANDtriple.object.equals
with the specified object
as an argument returns true
, or the object
argument is null
This method implements AND functionality, so only triples matching all of the given non-null arguments will be included in the result.
Note, this method always returns a new Graph, even if that Graph contains no Triples.
Note, Graphs represent Sets of Triples, the order is arbitrary, so this method may result in differing results when called repeatedly with a limit.
null
.null
.null
.Imports the graph
in to this graph. This method
returns the graph instance it was called on.
This method differes from Graph.merge
in that it adds all triples from graph
to the current instance, rather than combining the two graphs to create a new instance.
run
method
of each run
argument is specified as true
then
each The nominalValue
of an
Provides access to the string name of the current interface,
normally one of "NamedNode"
, "BlankNode"
or "Literal"
.
This method serves to disambiguate instances of
The stringification of an interfaceName
is
NamedNode
then return the stringified nominalValue
.BlankNode
then prepend "_:"
to the
stringified value
and return the result.Literal
then return the stringified nominalValue
.This method provides access to the implementations host environment native value
for this RDFNode, if the interfaceName
is
nominalValue
.nominalValue
if the datatype of the Literal is unknown or the value is out
of the range supported. See the definition of Returns the N-Triples representation of the
If tocompare
is an instance of
If tocompare
is NOT an instance of toValue
on this node.
You cannot simply test two RDF Nodes for equivalence using
general language constructs such as ==
.
A node identified by an IRI. IRIs are defined by International Resource Identifier [[!IRI]].
A
_:
"
to a unique value, for instance _:b142
or _:me
,
this stringified form is referred to as a "blank node identifier".
The temporary identifier of the number
or a string
.
The nominalValue MUST NOT be relied upon in any way between two
separate processing runs of the same document, or two instances of
Developers and authors must not assume that the
nominalValue of a
Implementers MUST ensure that
Literals represent values such as numbers, dates and strings in
RDF data. A
nominalValue
language
represented by a string tokendatatype
specified by a Literals representing plain text in a natural language may have a
language
attribute specified by a text string token, as
specified in [[!BCP47]], normalized to lowercase (e.g., 'en'
, 'fr'
, 'en-gb'
).
They may also have a datatype attribute such as xsd:string
.
The RDF Working Group is currently looking at the handling of "Plain Literals", with regards to datatypes, further guidance may result in changes to this specification.
Literals representing values with a specific datatype, such as
the integer 72, may have a datatype
attribute specified in
the form of a <http://www.w3.org/2001/XMLSchema#integer>
).
Literals often represent values for which the host environment of an RDF Interface implementation
has a corresponding native value, this value can be accessed by the valueOf
method of the
Implementations MUST provide native value type conversion, via the valueOf
method,
for the following XML Schema datatypes:
When a Literal contains both a datatype and a language, and the serialization or stringification does not support a lexical representation of both attributes, language SHOULD take precedence.
RDF specifies that Literal equality is based on the lexical representation
of values rather than the value space, for this reason the Literals
"100"^^xsd:double
and "1e2"^^xsd:double
are not considered equal.
This method provides access to a corresponding host environment specific native value, where one exists.
If the datatype identifier of the valueOf
MUST return
the DOMString
lexical representation of the nominalValue
.
The chart below provides a datatype map for the XSD datatypes which must be supported.
Specified Datatype | IDL | ECMAScript |
---|---|---|
xsd:string | DOMString | string |
xsd:boolean | boolean | boolean |
xsd:dateTime | - | Date |
xsd:date | - | Date |
xsd:time | - | Date |
xsd:int | long | number |
xsd:double | double | number |
xsd:float | float | number |
xsd:decimal | double | number |
xsd:positiveInteger | long | number |
xsd:integer | long | number |
xsd:nonPositiveInteger | long | number |
xsd:negativeInteger | long | number |
xsd:long | long | number |
xsd:int | long | number |
xsd:short | short | number |
xsd:byte | short | number |
xsd:nonNegativeInteger | unsigned long | number |
xsd:unsignedLong | unsigned long | number |
xsd:unsignedInt | unsigned long | number |
xsd:unsignedShort | unsigned short | number |
xsd:unsignedByte | unsigned short | number |
xsd:positiveInteger | unsigned long | number |
Implementations MUST convert xsd:boolean
values to native boolean
s rather than Boolean Objects to
limit unexpected behaviour.
The true
means that the test has been passed.
When used with the filter
method of the true
indicates the
The following shows an example set of common TripleFilters
exposed on a filter
attribute of
The
This interface is typically used with the forEach
method of the
test
and an action
, the run
method will execute the action
if, and only if, it passes the test
.
action
should be executed on a specific test
.
action
on the
specified test
.
The RDF Environment Interfaces provide all basic functionality needed to work with RDF data in a programming environment, and within specific contexts, for instance within a Parser, Serializer or Data Store.
Within a programming context, and within various RDF serializations, it is increasingly important to be able to simplify access to properties and refer to full IRIs by using CURIEs or Terms.
In order to accomplish this a Profile of Prefix and Term mappings is needed.
This specification includes the definition of three Interfaces which serve to address these needs:
Given a valid CURIE for which a prefix is known (for example "rdfs:label"
),
this method will return the resulting IRI (for example "http://www.w3.org/2000/01/rdf-schema#label"
)
If the prefix is not known then this method will return null.
"http://www.w3.org/2000/01/rdf-schema#label"
)
this method returns a CURIE (for example "rdfs:label"
), if
no prefix is known the original IRI is returned.
":this"
.This method returns the instance on which it was called.
true
then conflicting prefixes will be
overridden by those specified on the This example illustrates how
:
(single-colon) character:
(single-colon) character:
(single-colon) characterGiven a valid term for which an IRI is known (for example "label"
),
this method will return the resulting IRI (for example "http://www.w3.org/2000/01/rdf-schema#label"
).
If no term is known and a default
has been set, the
IRI is obtained by concatenating the term
and the default
iri.
If no term is known and no default
is set, then
this method returns null.
"http://www.w3.org/2000/01/rdf-schema#label"
)
this method returns a term (for example "label"
), if no
term is known the original IRI is returned.
iri
with
the term
being resolved.This method returns the instance on which it was called.
true
then conflicting terms will be
overridden by those specified on the This example illustrates how
Profiles provide an easy to use context for negotiating between CURIEs, Terms and IRIs.
Given an Term or CURIE this method will return an IRI, or null if it cannot be resolved.
If toresolve
contains a :
(colon) then this method returns the result of calling prefixes.resolve(toresolve)
otherwise this method returns the result of calling terms.resolve(toresolve)
setDefault
method on terms
.
":me"
, it is
identical to calling the setDefault
method on prefixes
.
set
method on term
.
:
(single-colon) characterset
method on prefixes
.
This method functions the same as calling prefixes.addAll(profile.prefixes,
override)
and terms.addAll(profile.terms, override)
, and
allows easy updating and merging of different profiles, such as those
exposed by parsers.
This method returns the instance on which it was called.
true
then conflicting terms and prefixes will
be overridden by those specified on the The RDF Interfaces are primarily intended to enable interoperability between RDF libraries and extensions, and for usage by advanced users. Implementations are encouraged to provide their own sets of abstracted interfaces and methods tailored to the use-cases they are addressing.
Implementors are encouraged to share implementations of various interfaces defined in this specification, offering specialized or highly optimized implementations of interfaces, for instance rigourously tested parsers and serializers for specific RDF serializations, or highly optimized Graph interfaces.
Methods to instantiate the basic interfaces required to work with RDF data in a programming environment, are all exposed by a single interface, as described in the following section.
The RDF Environment is an interface which exposes a high level API for working with RDF in a programming environment.
The RDF Environment interface extends
Prefix | IRI |
---|---|
owl | http://www.w3.org/2002/07/owl# |
rdf | http://www.w3.org/1999/02/22-rdf-syntax-ns# |
rdfs | http://www.w3.org/2000/01/rdf-schema# |
rdfa | http://www.w3.org/ns/rdfa# |
xhv | http://www.w3.org/1999/xhtml/vocab# |
xml | http://www.w3.org/XML/1998/namespace |
xsd | http://www.w3.org/2001/XMLSchema# |
This interface also exposes all methods required to create instances of TermMaps, PrefixMaps, Profiles and all the Concept Interfaces.
Implementations of the RDFEnvironment MUST expose all the methods defined on this interface, as defined by this specification.
Future RDF Interface extensions and modules MAY supplement this interface with methods and attributes which expose the functionality they define, in a manner consistent with this API.
The value to be represented by the value
MUST be a lexical representation of the value.
toArray
method of the test
the test
.true
is specified then a profile with an
empty TermMap and PrefixMap will be returned, by default the true
is specified then an empty true
is specified then an empty The RDF Data Interfaces are modular, standalone interfaces which can be implemented by RDF Libraries and API extensions to enable interoperability.
Developers and Specification authors are encouraged to use these interfaces when defining functionality within one of the realms covered by these interfaces.
Parser and Serializer implementors SHOULD provide relevant parse,
process or serialize methods on the RDF Environment interface for their
implementations. For example a Turtle parser SHOULD augment
RDFEnvironment with parseTurtle
and processTurtle
methods which accept a String toparse
argument, whilst an
RDFa parser SHOULD augment RDFEnvironment with a parseRDFa
method which accepts a Document
argument.
The
Parses the triples serialized within an input RDF document in to
a
If a
By default a new
A boolean response is given indicating if the parse was successful or not.
Document
,
whilst a Turtle
parser may require a String
.Parses the triples serialized within an input RDF document and
passes each (non filtered)
If a
Document
,
whilst a Turtle
parser may require a String
.Example of basic and advanced DataParser.parse usage:
Example of basic and advanced DataParser.process usage:
The
Implementations of this interface may further constrain the
return type, for instance an RDFa serializer may return an instance of Document
,
whilst a Turtle
serializer may return a String
.
The parse
method of the
The process
method of the
At the time of publication, the members of the RDF Web Application Working Group were: