RDF.ex v0.3.0 RDF.Datatype behaviour View Source

A behaviour for natively supported literal datatypes.

A RDF.Datatype implements the foundational functions for the lexical form, the validation, conversion and canonicalization of typed RDF.Literals.

Link to this section Summary

Functions

Returns the RDF.Datatype for a directly datatype IRI or the datatype IRI of a RDF.Literal

The IRIs of all datatypes with a RDF.Datatype defined

The mapping of IRIs of datatypes to their RDF.Datatype

All defined RDF.Datatype modules

Callbacks

Produces the canonical form of a RDF.Literal

Produces the lexical form of a value

Converts a value into a proper native value

The IRI of the datatype

Produces the lexical form of an invalid value of a typed Literal

Produces the lexical form of a RDF.Literal

Determines if the value of a RDF.Literal is a member of lexical value space of its datatype

Link to this section Functions

Returns the RDF.Datatype for a directly datatype IRI or the datatype IRI of a RDF.Literal.

The IRIs of all datatypes with a RDF.Datatype defined.

The mapping of IRIs of datatypes to their RDF.Datatype.

Link to this section Callbacks

Link to this callback canonical(literal) View Source
canonical(literal :: RDF.Literal.t) :: RDF.Literal.t

Produces the canonical form of a RDF.Literal.

Link to this callback canonical_lexical(any) View Source
canonical_lexical(any) :: binary

Produces the lexical form of a value.

Link to this callback convert(any, keyword) View Source
convert(any, keyword) :: any

Converts a value into a proper native value.

If an invalid value is given an implementation should call super, which by default currently just returns nil.

Note: If a value is valid is determined by the lexical space of the implemented datatype, not by the Elixir semantics. For example, although 42 is a falsy value according to the Elixir semantics, this is not an element of the lexical value space of an xsd:boolean, so the RDF.Boolean implementation of this datatype calls super.

The IRI of the datatype.

Link to this callback invalid_lexical(any) View Source
invalid_lexical(any) :: binary

Produces the lexical form of an invalid value of a typed Literal.

The default implementation of the _using__ macro just returns to_string representation of the value.

Link to this callback lexical(literal) View Source
lexical(literal :: RDF.Literal.t) :: any

Produces the lexical form of a RDF.Literal.

Link to this callback valid?(literal) View Source
valid?(literal :: RDF.Literal.t) :: boolean

Determines if the value of a RDF.Literal is a member of lexical value space of its datatype.