modules/rdf/term.zzm

rdf-0.0.3 documentation

NAME

rdf/term - RDF terms and quads.

SYNOPSIS

  from rdf/term import rdf_iri, rdf_literal, rdf_quad;

  let quad := rdf_quad(
      rdf_iri("http://example.com/s"),
      rdf_iri("http://example.com/p"),
      rdf_literal("value"),
  );

DESCRIPTION

This module defines value objects for RDF IRIs, blank nodes, literals, the default graph, and RDF quads. It also provides constructors and stable term keys suitable for comparison, hashing, storage, and test output.

EXPORTS

Constants

  • RDF_NS

    The RDF namespace IRI.

  • XSD_NS

    The XML Schema namespace IRI.

  • DEFAULT_GRAPH_KEY

    The canonical key used for the default graph.

Classes

  • RDFIRI

    An RDF IRI term. Construct with new RDFIRI(value: iri) or use rdf_iri. get_value returns the IRI string. to_String returns the N-Triples-style angle-bracket form.

  • RDFBlank

    An RDF blank node term. get_value returns the blank node label.

  • RDFLiteral

    An RDF literal term. get_value, get_lang, and get_datatype return the lexical form, lowercased language tag, and datatype IRI. If no datatype is supplied, plain literals use xsd:string and language literals use rdf:langString.

  • RDFDefaultGraph

    The default graph marker used by quads when no graph is supplied.

  • RDFQuad

    A subject, predicate, object, and graph tuple. get_subject, get_predicate, get_object, and get_graph return the components. to_Array returns them in quad order.

  • RDFError, RDFSyntaxError, RDFStoreError, SPARQLError

    Exception classes used by the RDF parsers, store, and SPARQL modules.

Functions

  • rdf_iri(String value)

    Returns an RDFIRI.

  • rdf_blank(String value)

    Returns an RDFBlank.

  • rdf_literal(value, String lang := "", datatype := null)

    Returns an RDFLiteral. value is stringified. lang and datatype are optional.

  • rdf_default_graph()

    Returns an RDFDefaultGraph.

  • rdf_quad(subject, predicate, object, graph?)

    Returns an RDFQuad. The graph defaults to rdf_default_graph().

  • rdf_term_kind(term)

    Returns iri, blank, literal, or default. Throws if term is not an RDF term.

  • rdf_term_key(term)

    Returns a stable string key for exact term identity.

  • rdf_term_hash(term)

    Returns a SHA-256 hash of rdf_term_key(term).

  • rdf_term_equals(left, right)

    Returns true when two RDF terms have the same key.

COPYRIGHT AND LICENCE

rdf/term 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.