This module implements the Turtle language for representing the RDF triple model as defined by Dave Beckett from the Institute for Learning and Research Technology University of Bristol in the document:
The Turtle format is designed as an RDF serialization that is easy to read and write by both machines and humans. Due to the latter property, this library goes a long way in trying to produce human-readable output.
In addition to the human-readable format, this library can write a canonical representation of RDF graphs. The canonical representation has the following properties:
- Equivalent graphs result in the same document. Graphs are considered equivalent iff they contain the same set of triples, regardless of the labeling of blank nodes in the graph.
- Changes to the graph are diff-friendly. This means
- Prefixes are combined in the header and thus changes to the namespaces only result in changes in the header.
- Blank nodes that are used only once (including collections) are written in-line with the object they belong to.
- For other blank nodes we to realise stable labeling that is based on property-values.
- rdf_save_turtle(+Out, :Options) is det
- Save an RDF graph as Turtle. Options processed are:
afor the predicate
rdf:type. Otherwise use the full resource.
- Nicely align the @prefix declarations
- Save relative to the given Base
false), emit numeric datatypes using Prolog's write to achieve canonical output.
true(default), write some informative comments between the output segments
- Encoding used for the output stream. Default is UTF-8.
- Query an alternative graph-representation. See below.
- Indentation for ; -lists. `0' does not indent, but writes on the same line. Default is 8.
- Save only the named graph
true(default), using P-O and O-grouping.
true(default), inline bnodes that are used once.
true(default), omit the type if allowed by turtle.
- Only use prefix notation for known prefixes. Without, some documents produce huge amounts of prefixes.
- If provided, uses exactly these prefixes. List is a list of prefix specifications, where each specification is either a term Prefix_-_URI or a prefix that is known to rdf_current_prefix/2.
false), do not print the final informational message.
false), write [...] and (...) on a single line.
- Extra white lines to insert between statements about a different subject. Default is 1.
- Distance between tab-stops. `0' forces the library to use only spaces for layout. Default is 8.
true(default), use prefixes from rdf_current_prefix/2.
expandallows for serializing alternative graph representations. It is called through call/5, where the first argument is the expand-option, followed by S,P,O,G. G is the graph-option (which is by default a variable). This notably allows for writing RDF graphs represented as
rdf(S,P,O)using the following code fragment:
triple_in(RDF, S,P,O,_G) :- member(rdf(S,P,O), RDF). ..., rdf_save_turtle(Out, [ expand(triple_in(RDF)) ]),
- rdf_save_canonical_turtle(+Spec, :Options) is det
- Save triples in a canonical format. This is the same as
rdf_save_turtle/2, but using different defaults. In particular:
- rdf_save_ntriples(+Spec, :Options) is det
- Save RDF using ntriples format. The ntriples format is a subset of Turtle, writing each triple fully qualified on its own line.
- rdf_save_trig(+Spec, :Options) is det
- Save multiple RDF graphs into a TriG file. Options are the same
as for rdf_save_turtle/2. rdf_save_trig/2 ignores the
graph(+Graph)option and instead processes one additional option:
- List of graphs to save. When omitted, all graphs in the RDF store are stored in the TriG file.
- rdf_save_canonical_trig(+Spec, :Options) is det
- Save triples in a canonical format. See rdf_save_canonical_turtle/2 foir details.