View Source RDF.Namespace behaviour (RDF.ex v1.1.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

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.

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

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

Link to this function

create(module, term_mapping, location)

View Source

See RDF.Namespace.Builder.create/3.

Link to this function

create(module, term_mapping, location, opts)

View Source

See RDF.Namespace.Builder.create/4.

Link to this function

create!(module, term_mapping, location)

View Source

See RDF.Namespace.Builder.create!/3.

Link to this function

create!(module, term_mapping, location, opts)

View Source

See RDF.Namespace.Builder.create!/4.

Link to this macro

defnamespace(module, term_mapping, opts \\ [])

View Source (macro)

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

Warning

This macro is intended to be used at compile-time, i.e. in the body of a defmodule definition. If you want to create RDF.Namespaces dynamically at runtime, please use create/4.

@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.

@spec resolve_term!(RDF.IRI.t() | module()) :: RDF.IRI.t()

Resolves a qualified term to a RDF.IRI or raises an error when that's not possible.

See resolve_term/1 for more.