modules/rdf/serializer/turtle.zzm

rdf-0.0.3 documentation

NAME

rdf/serializer/turtle - Pretty Turtle serializer.

SYNOPSIS

  from rdf/serializer/turtle import TurtleSerializer;

  let text := (new TurtleSerializer()).serialize(quads);

DESCRIPTION

TurtleSerializer serializes default-graph RDF quads as RDF 1.1 Turtle. It uses the shared RDF serializer plan to group triples by subject, sort interesting subjects first, put rdf:type and configured labelling predicates before other predicates, and inline blank nodes which are the object of at most one triple using Turtle [ ... ] syntax.

The output algorithm follows the broad shape of RDF::TrineX::Serializer::MockTurtleSoup: predicates, class IRIs, and datatypes are abbreviated to QNames where possible; ordinary IRI subjects and objects remain full IRIs unless their namespace is explicitly listed for abbreviation.

EXPORTS

Classes

  • TurtleSerializer
    • serialize(Array quads)

      Returns pretty Turtle for the default graph in quads.

    • serialize_each(Array quads, Function emit)

      Calls emit with the serialized Turtle text when there is output. Returns the serializer.

COPYRIGHT AND LICENCE

rdf/serializer/turtle 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.