View Source RDF.Namespace behaviour (RDF.ex v1.0.0)
A behaviour and generator for modules of terms resolving to RDF.IRIs.
Note: A RDF.Namespace is NOT a IRI namespace! The terms of a RDF.Namespace don't
have to necessarily refer to IRIs from the same IRI namespace. "Namespace" here is
just meant in the sense that an Elixir module is a namespace. Most of the
Most of the time you'll want to use a RDF.Vocabulary.Namespace, a special type of
RDF.Namespace where all terms indeed resolve to IRIs of a shared base URI namespace.
For an introduction into RDF.Namespaces and RDF.Vocabulary.Namespaces see
this guide.
Link to this section Summary
Callbacks
All RDF.IRIs of a RDF.Namespace.
Resolves a term to a RDF.IRI.
All terms of a RDF.Namespace.
Functions
See RDF.Namespace.Builder.create/3.
See RDF.Namespace.Builder.create/4.
See RDF.Namespace.Builder.create!/3.
See RDF.Namespace.Builder.create!/4.
A macro to define a RDF.Namespace.
Resolves a qualified term to a RDF.IRI.
Resolves a qualified term to a RDF.IRI or raises an error when that's not possible.
Link to this section Types
@type t() :: module()
Link to this section Callbacks
@callback __iris__() :: [RDF.IRI.t()]
All RDF.IRIs of a RDF.Namespace.
@callback __resolve_term__(atom()) :: {:ok, RDF.IRI.t()} | {:error, Exception.t()}
Resolves a term to a RDF.IRI.
@callback __terms__() :: [atom()]
All terms of a RDF.Namespace.
Link to this section Functions
See RDF.Namespace.Builder.create/3.
See RDF.Namespace.Builder.create/4.
See RDF.Namespace.Builder.create!/3.
See RDF.Namespace.Builder.create!/4.
A macro to define a RDF.Namespace.
example
Example
defmodule YourApp.NS do
import RDF.Namespace
defnamespace EX, [
foo: ~I<http://example1.com/foo>,
Bar: "http://example2.com/Bar",
]
end
@spec resolve_term(RDF.IRI.t() | module()) :: {:ok, RDF.IRI.t()} | {:error, Exception.t()}
Resolves a qualified term to a RDF.IRI.
It determines a RDF.Namespace from the qualifier of the given term and
delegates to remaining part of the term to __resolve_term__/1 of this
determined namespace.
Resolves a qualified term to a RDF.IRI or raises an error when that's not possible.
See resolve_term/1 for more.