Module zotonic_rdf

Support routies for handling RDF triples.

Copyright © Copyright (c) 2021 Driebit BV

Description

Support routies for handling RDF triples. A typical triple has two variations.

One is for a value:

  #{
      <<"subject">> => <<"_:n1">>,
      <<"predicate">> => <<"http://....">>,
      <<"@value">> => <<"...">>,
      <<"@type">> => <<"http://....">>,
      <<"@language">> => <<"nl">>
  }.

And, if the object is a uri:

  #{
      <<"subject">> => <<"_:n1">>,
      <<"predicate">> => <<"http://....">>,
      <<"@id">> => <<"...">>
  }.

Data Types

rdf_doc()

rdf_doc() = map()

rdf_triple()

rdf_triple() = map()

uri()

uri() = binary()

Function Index

blank_id/0Generate an unique blank node identifier.
compact/1Compact a doc using the known namespaces and simplify values.
compact/2Compact a doc, add namespaces and simplify values.
namespaces/0Default JSON-LD RDF namespace context.
ns_compact/1Compact a namespace in a predicate using the default namespaces.
ns_compact/2Compact a namespace in a predicate.
ns_expand/1Expand a namespace in a predicate using the default namespaces.
ns_expand/2Expand a namespace in a predicate.
triples_to_docs/1Combine triples to one or more documents.

Function Details

blank_id/0

blank_id() -> binary()

Generate an unique blank node identifier.

compact/1

compact(Doc) -> Doc

Compact a doc using the known namespaces and simplify values.

compact/2

compact(Doc, Namespaces) -> Doc

Compact a doc, add namespaces and simplify values.

namespaces/0

namespaces() -> #{binary() := binary()}

Default JSON-LD RDF namespace context.

ns_compact/1

ns_compact(Pred) -> Pred

Compact a namespace in a predicate using the default namespaces. For example, replaces: http://www.w3.org/2001/XMLSchema#integer with xsd:integer

ns_compact/2

ns_compact(Pred, Ns) -> Pred

Compact a namespace in a predicate. For example, replaces: http://www.w3.org/2001/XMLSchema#integer with xsd:integer

ns_expand/1

ns_expand(Pred) -> Pred

Expand a namespace in a predicate using the default namespaces. For example, replaces: xsd:integer with http://www.w3.org/2001/XMLSchema#integer

ns_expand/2

ns_expand(Pred, Ns) -> Pred

Expand a namespace in a predicate. For example, replaces: xsd:integer with http://www.w3.org/2001/XMLSchema#integer

triples_to_docs/1

triples_to_docs(Triples) -> {ok, Docs}

Combine triples to one or more documents. Every document with a non-blank id is returned separately. The documents are mapped using uri => rdf_doc


Generated by EDoc