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_NSThe RDF namespace IRI.
XSD_NSThe XML Schema namespace IRI.
DEFAULT_GRAPH_KEYThe canonical key used for the default graph.
Classes
RDFIRIAn RDF IRI term. Construct with
new RDFIRI(value: iri)or userdf_iri.get_valuereturns the IRI string.to_Stringreturns the N-Triples-style angle-bracket form.RDFBlankAn RDF blank node term.
get_valuereturns the blank node label.RDFLiteralAn RDF literal term.
get_value,get_lang, andget_datatypereturn the lexical form, lowercased language tag, and datatype IRI. If no datatype is supplied, plain literals usexsd:stringand language literals userdf:langString.RDFDefaultGraphThe default graph marker used by quads when no graph is supplied.
RDFQuadA subject, predicate, object, and graph tuple.
get_subject,get_predicate,get_object, andget_graphreturn the components.to_Arrayreturns them in quad order.RDFError,RDFSyntaxError,RDFStoreError,SPARQLErrorException 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.valueis stringified.langanddatatypeare optional.rdf_default_graph()Returns an
RDFDefaultGraph.rdf_quad(subject, predicate, object, graph?)Returns an
RDFQuad. The graph defaults tordf_default_graph().rdf_term_kind(term)Returns
iri,blank,literal, ordefault. Throws iftermis 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.