modules/rdf/prefix.zzm

rdf-0.0.3 documentation

NAME

rdf/prefix - Namespace and prefix registry helpers.

SYNOPSIS

  from rdf/prefix import RDFPrefixRegistry;

  let prefixes := new RDFPrefixRegistry();
  prefixes.set("ex", "http://example.com/");
  let term := prefixes.expand("ex:thing");

DESCRIPTION

RDFPrefixRegistry stores namespace prefix mappings and converts between prefixed names and IRI terms. New registries include the rdf, rdfs, owl, and xsd prefixes.

EXPORTS

Classes

  • RDFPrefixRegistry
    • set(String prefix, String iri)

      Registers prefix and returns the registry.

    • get(String prefix, fallback := null)

      Returns the namespace IRI for prefix, or fallback.

    • exists(String prefix)

      Returns true if prefix is registered.

    • expand(String value)

      Expands a prefixed name to an RDFIRI. Throws if the prefix is unknown. Values without a colon are treated as absolute IRIs.

    • compact(value)

      Returns the shortest registered prefixed-name form for an IRI when possible, otherwise the full IRI string.

    • as_dict()

      Returns a dictionary copy of the prefix mappings.

COPYRIGHT AND LICENCE

rdf/prefix is copyright Toby Inkster.

It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.