NAME
rdf/builder - RDF graph builder DSL.
SYNOPSIS
from rdf/builder import RDFBuilder;
from rdf/vocab import rdf_type;
let builder := new RDFBuilder();
builder
.prefix("ex", "http://example.com/")
.triple("ex:alice", rdf_type(), "ex:Person")
.triple("ex:alice", "ex:name", builder.literal("Alice"));
DESCRIPTION
RDFBuilder is a small convenience layer for constructing arrays of RDF quads. It expands prefixed names through an RDFPrefixRegistry, accepts existing RDF terms, creates literals, and can add accumulated quads to an RDFStore.
EXPORTS
Classes
RDFBuilderprefix(String name, String iri)Registers a namespace prefix and returns the builder.
iri(value)Returns
valueas an IRI term. Existing IRI terms are returned as-is; strings containing a known prefix are expanded.blank(String label)Returns a blank node term.
literal(value, String lang := "", datatype := null)Returns an RDF literal.
term(value)Converts RDF terms and supported string forms into terms. Strings that look like prefixed names become IRIs; other strings become literals.
quad(subject, predicate, object, graph := null)Builds and stores a quad, returning the builder.
triple(subject, predicate, object)Builds a default-graph triple or a triple in the current graph.
in_graph(graph, Function todo)Temporarily sets the current graph while running
todo.add_to(RDFStore store)Adds accumulated quads to
storeand returns the store.clear()Clears the builder's accumulated quads and returns the builder.
COPYRIGHT AND LICENCE
rdf/builder 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.