The RDF library can read and write triples in RDF/XML and a
proprietary binary format. There is a plugin interface defined to
support additional formats. The
this plugin API to support loading Turtle files using rdf_load/2.
- Same as
rdf_load(FileOrList, ). See rdf_load/2.
- Load RDF data. Options provides additional processing
options. Defined options are:
- How to handle equivalent blank nodes. If
equivalent blank nodes are shared in the same resource.
- URI that is used for rdf:about="" and other RDF constructs
that are relative to the base uri. Default is the source URL.
- If FileOrList is a list of files, process the input files
using Jobs threads concurrently. Default is the mininum of
the number of cores and the number of inputs. Higher values can be
useful when loading inputs from (slow) network connections. Using 1
(one) does not use separate worker threads.
- Specify the source format explicitly. Normally this is deduced from the
filename extension or the mime-type. The core library understands the
formats xml (RDF/XML) and triples (internal quick load and cache
format). Plugins, such as
library(semweb/turtle) extend the
set of recognised extensions.
- Named graph in which to load the data. It is not allowed to load
two sources into the same named graph. If Graph is unbound,
it is unified to the graph into which the data is loaded. The default
graph is a
file:// URL when loading a file or, if the
specification is a URL, its normalized version without the optional #fragment.
- When to load the file. One of
- Unify Modified with one of
false, do not use or create a cache file.
namespace declarations or Turtle
@prefix prefixes using
if there is no conflict.
true, the message reporting completion is printed using
silent. Otherwise the level is
See also print_message/2.
- Returns the prefixes defined in the source data file as a list of pairs.
- Indicate that the addressed graph may be populated with triples from
multiple sources. This disables caching and avoids that an rdf_load/2
call affecting the specified graph cleans the graph.
Other options are forwarded to process_rdf/3.
rdf_load/2 only loads RDF/XML
from files. It can be extended to load data from other formats and
locations using plugins. The full set of plugins relevant to support
different formats and locations is below:
:- use_module(library(semweb/turtle)). % Turtle and TriG
- See also
- Identify the graph loaded from Source and use rdf_unload_graph/1
to erase this graph.
- For compatibility, this predicate also accepts a graph name instead of a
source specification. Please update your code to use
- Same as
rdf_save(Out, ). See rdf_save/2
- Write RDF data as RDF/XML. Options is a list of one or more
of the following options:
- Save only triples associated to the given named Graph.
true) do not save blank
nodes that do not appear (indirectly) as object of a named resource.
- BaseURI used. If present, all URIs that can be represented relative to
this base are written using their shorthand. See also
- Call Convertor(-Type, -Content, +RDFObject), providing the
opposite for the convert_typed_literal option of the RDF parser.
xml:lang saved with rdf:RDF element.
- Encoding for the output. Either utf8 or iso_latin_1.
false), inline resources when
encountered for the first time. Normally, only bnodes are handled this
- Explicitly specify saved namespace declarations. See
namespaces for details.
false), emit subjects sorted
on the full URI. Useful to make file comparison easier.
false, do not include the
declaration that is written normally when using the
true), never use xml
attributes to save plain literal attributes, i.e., always used an XML
element as in
|Out ||Location to save the data. This can also
be a file-url (|
file://path) or a stream wrapped in a term
- See also
- Reload all loaded files that have been modified since the last time they
Sometimes it is necessary to make more arbitrary selections of
material to be saved or exchange RDF descriptions over an open network
link. The predicates in this section provide for this. Character
encoding issues are derived from the encoding of the Stream,
providing support for
- Save XML document header, doctype and open the RDF environment. This
predicate also sets up the namespace notation.
Save an RDF header, with the XML header, DOCTYPE, ENTITY and opening
the rdf:RDF element with appropriate namespace declarations. It uses the
primitives from section 3.5 to generate the required namespaces and
desired short-name. Options is one of:
- Only search for namespaces used in triples that belong to the given
- Where List is a list of namespace abbreviations. With this
option, the expensive search for all namespaces that may be used by your
data is omitted. The namespaces
are added to the provided List. If a namespace is not
declared, the resource is emitted in non-abreviated form.
- Finish XML generation and write the document footer.
- See also
- rdf_save_header/2, rdf_save_subject/3.
- Save the triples associated to Subject to Out. Options:
- Only save properties from Graph.
- See also
- rdf_save/2 for a description of
Fast loading and saving
Loading and saving RDF format is relatively slow. For this reason we
designed a binary format that is more compact, avoids the complications
of the RDF parser and avoids repetitive lookup of (URL) identifiers.
Especially the speed improvement of about 25 times is worth-while when
loading large databases. These predicates are used for caching by
rdf_load/2 under certain
conditions as well as for maintaining persistent snapshots of the
- Save triples into File in a quick-to-load binary format. If Graph
is supplied only triples flagged to originate from that database are
added. Files created this way can be loaded using
- Load triples from a file created using rdf_save_db/2.