grafter.rdf.io

Functions & Protocols for serializing Grafter Statements to (and from) any Linked Data format supported by Sesame.

default-prefixes

FIXME: write docs

filename->rdf-format

deprecated in 0.8.0

(filename->rdf-format fname)

DEPRECATED: Use grafter.rdf.formats/filename->rdf-format instead.

Given a filename we attempt to return an appropriate RDFFormat object based on the files extension.

ISesameRDFConverter

protocol

members

->sesame-rdf-type

(->sesame-rdf-type this)

Convert a native type into a Sesame RDF Type

sesame-rdf-type->type

(sesame-rdf-type->type this)

Convert a Sesame RDF Type into a Native Type

IStatement->sesame-statement

(IStatement->sesame-statement is)

Convert a grafter IStatement into a Sesame statement.

language

(language s lang)

Create an RDF langauge string out of a value string and a given language tag. Language tags should be keywords representing the country code, e.g.

(language “Bonsoir” :fr)

literal

(literal val datatype-uri)

You can use this to declare an RDF typed literal value along with its URI. Note that there are implicit coercions already defined for many core clojure/java datatypes, so for common datatypes you shounld’t need this.

literal-datatype->type

multimethod

A multimethod to convert an RDF literal into a corresponding Clojure type. This method can be extended to provide custom conversions.

mimetype->rdf-format

deprecated in 0.8.0

(mimetype->rdf-format mime-type)

DEPRECATED: Use grafter.rdf.formats/mimetype->rdf-format instead.

Given a mimetype string we attempt to return an appropriate RDFFormat object based on the files extension.

rdf-serializer

(rdf-serializer destination & {:keys [append format encoding prefixes], :or {append false, encoding "UTF-8", prefixes default-prefixes}})

Coerces destination into an java.io.Writer using clojure.java.io/writer and returns an RDFSerializer.

Use this to capture the intention to write to a location in a specific RDF format, e.g.

(grafter.rdf/add (rdf-serializer “/tmp/foo.nt” :format :nt) quads)

Accepts also the following optional options:

  • :append If set to true it will append new values to the end of the file destination (default: false).

  • :format If a String or a File are provided the format parameter can be optional (in which case it will be infered from the file extension). This should be a sesame RDFFormat object.

  • :encoding The character encoding to be used (default: UTF-8)

  • :prefixes A map of RDF prefix names to URI prefixes.

sesame-statement->IStatement

(sesame-statement->IStatement st)

Convert a sesame Statement into a grafter Quad.

ToSesameURI

protocol

members

->sesame-uri

(->sesame-uri this)

Coerce an object into a sesame URIImpl