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 and later standardized by
the W3C RDF working group.
This module acts as a plugin to rdf_load/2, for processing files with
one of the extensions .ttl
or .n3
.
- See also
- - http://www.w3.org/TR/turtle/ (used W3C Recommendation 25
February 2014)
rdf_read_turtle(+Input, -Triples, +Options)- Read a stream or file into a set of triples or quadruples (if
faced with TriG input) of the format
rdf(Subject, Predicate, Object [, Graph])
The representation is consistent with the SWI-Prolog RDF/XML
and ntriples parsers. Provided options are:
- base_uri(+BaseURI)
- Initial base URI. Defaults to file://<file> for loading
files.
- anon_prefix(+Prefix)
- Blank nodes are generated as <Prefix>1, <Prefix>2, etc.
If Prefix is not an atom blank nodes are generated as
node(1)
, node(2)
, ...
- format(+Format)
- One of
auto
(default), turtle
or trig
. The
auto mode switches to TriG format of there is a
{
before the first triple. Finally, of the
format is explicitly stated as turtle
and the
file appears to be a TriG file, a warning is printed
and the data is loaded while ignoring the graphs.
- resources(URIorIRI)
- Officially, Turtle resources are IRIs. Quite a
few applications however send URIs. By default we
do URI->IRI mapping because this rarely causes errors.
To force strictly conforming mode, pass
iri
.
- prefixes(-Pairs)
- Return encountered prefix declarations as a
list of Alias-URI
- namespaces(-Pairs)
- Same as
prefixes(Pairs)
. Compatibility to rdf_load/2.
- base_used(-Base)
- Base URI used for processing the data. Unified to
[] if there is no base-uri.
- on_error(+ErrorMode)
- In
warning
(default), print the error and continue
parsing the remainder of the file. If error
, abort
with an exception on the first error encountered.
- error_count(-Count)
- If
on_error(warning)
is active, this option cane be
used to retrieve the number of generated errors.
- Arguments:
-
Input | - is one of stream(Stream) , atom(Atom) , a http ,
https or file url or a filename specification as
accepted by absolute_file_name/3. |
rdf_load_turtle(+Input, -Triples, +Options)-
- deprecated
- - Use rdf_read_turtle/3
rdf_process_turtle(+Input, :OnObject, +Options) is det- Streaming Turtle parser. The predicate rdf_process_turtle/3
processes Turtle data from Input, calling OnObject with a list
of triples for every Turtle statement found in Input. OnObject
is called as below, where ListOfTriples is a list of
rdf(S,P,O)
terms for a normal Turtle file or rdf(S,P,O,G)
terms
if the GRAPH
keyword is used to associate a set of triples in
the document with a particular graph. The Graph argument
provides the default graph for storing the triples and Line is
the line number where the statement started.
call(OnObject, ListOfTriples, Graph:Line)
This predicate supports the same Options as rdf_load_turtle/3.
Errors encountered are sent to print_message/2, after which the
parser tries to recover and parse the remainder of the data.
- See also
- - This predicate is normally used by load_rdf/2 for
processing RDF data.
turtle_pn_local(+Atom:atom) is semidet- True if Atom is a valid Turtle PN_LOCAL name. The PN_LOCAL
name is what can follow the : in a resource. In the new Turtle,
this can be anything and this function becomes meaningless. In
the old turtle, PN_LOCAL is defined similar (but not equal) to
an XML name. This predicate is used by rdf_save_turtle/2 to
write files such that can be read by old parsers.
- See also
- - xml_name/2.
turtle_write_quoted_string(+Out, +Value) is det- Same as
turtle_write_quoted_string(Out, Value, false)
, writing a
string with only a single "
. Embedded newlines are escapes
as \n
.
turtle_write_uri(+Out, +Value) is det- Write a URI as
<...>
rdf_db:rdf_load_stream(+Format, +Stream, :Options)[multifile]- (Turtle clauses)
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.
- rdf_save_turtle(Arg1, Arg2)
- rdf_save_canonical_turtle(Arg1, Arg2)
- rdf_save_trig(Arg1, Arg2)
- rdf_save_canonical_trig(Arg1, Arg2)
- rdf_save_ntriples(Arg1, Arg2)