2.4.3 Datatypes

Datatypes are used by RDF in the representation of values such as integers, floating point numbers and dates.

RDF uses the datatype abstraction defined by XML Schema Part 2: Datatypes [XML-SCHEMA2]. A datatype consists of a lexical space, a value space and a datatype mapping.

A datatype mapping is a set of pairs whose first element belongs to the lexical space of the datatype, and the second element belongs to the value space of the datatype.:

With one exception, the datatypes used in RDF have a lexical space consisiting of a set of strings. The exception is rdfs:XMLLiteral, whose lexical space is a set of pairs of strings and language identifiers, and the value obtained through its datatype mapping depends on the language identifier.

For example, the datatype mapping for the XML Schema datatype xsd:boolean, where each member of the value space (represented here as 'T' and 'F') has two lexical representations, is as follows:

Value Space {T, F}
Lexical Space {"0", "1", "true", "false"}
Datatype Mapping {<"true", T>, <"1", T>, <"0", F>, <"false", F>}

RDF predefines just one datatype rdfs:XMLLiteral, used for embedding XML in RDF (see section 3).

There is no built-in concept of numbers or dates or other common values. Rather, RDF defers to datatypes that are defined separately, and identified with URIs.The predefined XML Schema datatypes [XML-SCHEMA2] are expected to be widely used for this purpose. The defining authority of a URI which identifies a datatype is responsible for specifying the datatype's lexical space, value space and datatype mapping.

RDF provides no mechanism for defining new datatypes. XML Schema Datatypes [XML-SCHEMA2] provides an extensibility framework suitable for defining new datatypes for use in RDF.

2.4.4 Literals

Literal labels are used to identify values such as numbers and dates by means of a lexical representation. Anything represented by a literal could also be represented by a URI, but it is often more convenient or intuitive to use literals.

A literal may label the object of an RDF statement, but not the subject or the arc.

Literals may be typed or untyped:

[[[Need to check WG outcome of no lang id vs empty lang id debate]]]

Continuing the example from section 2.4.3, the typed literals which can be defined using the XML Schema datatype xsd:boolean are:

Typed Literal Datatype Mapping Value
<xsd:boolean, "true"> <"true", T> T
<xsd:boolean, "1"> <"1", T> T
<xsd:boolean, "false"> <"false", F> F
<xsd:boolean, "0"> <"0", F> F