8. Import and Export¶
In order to apply RDFox’s querying and reasoning capabilities to a given data
set, the data must first be loaded into RDFox together with any applicable
rules and axioms. Small amounts of data may be loaded using SPARQL
DATA statements, but in most cases it is preferable to import the content
from one of the supported formats. Later, it may be necessary to extract
content from RDFox in one of these formats, and the most efficient way of
achieving this is to use the export operation. This section begins by listing
the formats supported by RDFox for import and export and then looks at the
specifics of each of these operations in turn.
8.1. Data Store Content Formats¶
The following formats can be imported into or exported from RDFox data stores.
The N-Triples format has MIME type
The Turtle format has MIME type
The N-Quads format has MIME type
The TriG format has MIME type
The OWL 2 Functional-Style Syntax format has the MIME type
RDFox supports proprietary formats
application/x.gen-trigwhich extend the corresponding standard formats by support for generalized triples and quads (i.e., triples/quads where any component can be an IRI, a blank node, or a literal).
RDFox uses a proprietary format described in Section 10.4 to capture datalog rules and facts. The MIME type of this format is
The list of MIME types supported for import and export of data store content
can also be viewed using the
help command in the RDFox shell.
This section describes how facts, rules and axioms may be imported into RDFox data stores. The goal is to help users understand those aspects of import operations that are true no matter which interface (such as the RDFox shell, REST or Java) is used. If you are looking for details of how to perform an import using a specific interface, please refer to Section 15.2.23 for the RDFox shell or to Section 16.8 for the REST or Java APIs. Reading this section first will help you make sense of the various options available in those sections.
RDFox uses the concept of domains to segregate content according to how it
came to be present in the system. Facts are imported into the
fact domain. Rules are imported into the
8.2.1. Import Parameters¶
This section describes the parameters of each import operation. Other aspects
of import are determined by the configuration of the data store that is
receiving the content; for details, please refer to the data store parameters
in Section 5.4.1 whose names begin with
- Target Default Graph
According to the RDF 1.1 standards, an RDF dataset includes a default graph, which has no name, and zero or more named graphs. While only some of the formats supported by RDFox have a syntax for specifying named graphs, all of them have a syntax for the default graph. For each import operation, RDFox allows the user to specify a named graph to act as the default graph. For facts, this determines the graph that receives the imported content’s default graph triples. For rules, it determines the graph that default graph atoms refer to. For OWL axioms, it determines in which graph the axioms will be applied. Note that the data store parameter
default-graph-name, if set, supplies a default value for this import parameter. If no value is available for the target default graph, default graph triples are written to the data store’s
DefaultTriplestuple table if it exists or cause an error to be raise if not. See also Section 5.2.
- Add or Delete
RDFox can import content for the purpose of adding it to or deleting it from a data store. When content is being added, it is possible to also add any prefix definitions found in the content to the data store’s prefixes. These defintions override any existing definitions where there is a conflict.
- Content Sources
For each import operation, the source or sources of the content to add or delete must be specified. All interfaces provide ways to supply the content directly, or as a list of file paths or URIs. Please refer to the
sandbox-directoryserver parameters that, for security purposes, restrict the URI schemes and file paths that can be used in an import operation.
- Content Format
It is possible to explicitly specify the format of the content being imported or allow RDFox to “guess” the format by inspecting the content. When a format is specified using its MIME type, an error will result if the content in any of the specified sources does not conform to that format. If the content type is not specified explicitly, RDFox will try to parse the beginning of the content from each specified content source in each of its supported formats to determine which format does not result in an error, and then proceeds to import the content in that format.
When importing data in N-Quads, the content type (
application/n-quads) must be specified explicitly.
8.2.2. Parallelization of Imports¶
RDFox will always attempt to parallelize the import of facts using the available server threads (see the num-threads server parameter). If only one source is given, the available threads will be divided between parsing the content and loading the parsed facts into tuple tables. If multiple sources are given, each will be assigned to a thread that is then responsible for both parsing and loading facts from that source.
This section describes how facts, rules and axioms may be exported from RDFox data stores. The goal is to help users understand those aspects of the export operation which are true no matter which interface (RDFox shell, REST or Java) is used. If you are looking for details of how to perform an export in the RDFox shell or using an API, please refer to Section 15.2.20 or Section 16.8, respectively. Reading this section first will help you make sense of the various options available in those sections.
8.3.1. Export Parameters¶
This section describes the parameters that control the behaviour of export operations.
For each export operation, the user must specify the destination. All interfaces provide ways to either receive the content directly or specify the path to which RDFox should write the output file. See the
sandbox-directoryserver parameter which restricts, for security purposes, the file paths to which a server can write.
- Content Format
The format for the export must be specified using its MIME type. Some interfaces satisfy this requirement by having their own default value. The choice of the format determines which portion of the data store content is exported. For RDF formats that do not support named graphs (specifically Turtle, N-Triples and their generalized equivalents), only the triples from the default graph will be exported (exporting specific named graphs into these formats can be achieved using a query that has variables
?O). For RDF formats that do support named graphs (specifically TriG, N-Quads and their generalized equivalents), both the default graph triples and named-graph quads are exported. If the Datalog format is specified, the data store’s rules are exported. If OWL 2 Functional-Style syntax is specified, the data store’s axioms are exported.
- Fact or Rule Domain
RDFox supports restricting imports by fact or rule domain. When exporting RDF, the triples or quads from the
explicitdomain are exported by default. This can be overridden by specifying a single fact domain. When exporting Datalog, the rules from the
userdomain are exported by default but this can be overridden by specifying a space-separated list of rule domains.
8.4. Access Control¶
Like all operations, import and export are subject to the rules of RDFox’s access control system (see Section 12). When specifying access control policies at the granularity of named graphs, it is important to be aware that triples in unreadable named graphs are silently skipped during export. For a more detailed explanation of this see Section 126.96.36.199.