View Source RDF.Term protocol (RDF.ex v2.0.0)

Shared behaviour for all RDF terms.

A RDF.Term is anything which can be an element of RDF statements of an RDF graph:

see https://www.w3.org/TR/sparql11-query/#defn_RDFTerm

Summary

Functions

Converts a given value into an RDF term.

Tests for term equality.

Tests for equality of values.

Checks if the given value is an RDF term.

Returns the native Elixir value of an RDF term.

Types

Functions

Converts a given value into an RDF term.

Returns nil if the given value is not convertible into any valid RDF.Term.

Examples

iex> RDF.Term.coerce("foo")
~L"foo"
iex> RDF.Term.coerce(42)
RDF.XSD.integer(42)

Tests for term equality.

see http://www.w3.org/TR/rdf-sparql-query/#func-sameTerm

Link to this function

equal_value?(term1, term2)

View Source

Tests for equality of values.

Non-RDF terms are tried to be coerced via RDF.Term.coerce/1 before comparison.

Returns nil if the given terms are not comparable.

see http://www.w3.org/TR/rdf-sparql-query/#func-RDFterm-equal and the value equality semantics of the different literal datatypes here: https://www.w3.org/TR/sparql11-query/#OperatorMapping

Checks if the given value is an RDF term.

Note: As opposed to RDF.term? this function returns false on atoms and does not try to resolve them to IRIs.

Examples

iex> RDF.Term.term?(RDF.iri("http://example.com/resource"))
true
iex> RDF.Term.term?(EX.Resource)
false
iex> RDF.Term.term?(RDF.bnode)
true
iex> RDF.Term.term?(RDF.XSD.integer(42))
true
iex> RDF.Term.term?(42)
false

Returns the native Elixir value of an RDF term.

Returns nil if the given value is not a valid RDF term or a value convertible to an RDF term.

Examples

iex> RDF.Term.value(~I<http://example.com/>)
"http://example.com/"
iex> RDF.Term.value(~L"foo")
"foo"
iex> RDF.XSD.integer(42) |> RDF.Term.value()
42