The TQL export command is used to export the contents of an individual RDF graph (stored in a Mulgara server) to an external RDF file on the filesystem. At the moment, the supported file formats for exporting are RDF/XML and N-Triples. The extension of the output file name is used to determine the file format for exporting: if the file name has one of the extensions .nt, .n3, or .ttl then the graph is exported in N-Triples format, else it is exportd as RDF/XML.

The TQL load command is used to import the contents of an external RDF file into a graph on a Mulgara server. The load command supports importing zip and GNUzip (gzip) compressed files, as determined by an extension of .zip or .gz, in addition to uncompressed files. By default, the imported file is parsed using the RDF/XML format. To load an N-Triples file, the imported filename must have one of the following extensions: .nt, .n3, .nt.gz, .n3.gz,, If the destination graph already contains RDF data, then after a load operation its contents will be the union of any existing data and the RDF contents of the imported file.

Supported Graph Types

The export command supports exporting graphs of the following type URIs. Note that the graph type can be determined by querying for the <rdf:type> value associated with the graph in the Mulgara system graph (<#>). Also, note that in this list the prefix mulgara maps to the namespace

  • mulgara:Model - This is the default graph type for an internally stored Mulgara graph.
  • mulgara:MemoryModel - This is the type for in-memory (non-persistent) Mulgara graphs.
  • mulgara:FileSystemModel - A Mulgara graph for accessing filesystem metadata.
  • mulgara:LuceneModel - A Mulgara graph for doing fulltext search using Lucene.
  • mulgara:GISModel - A Mulgara graph for estimating distances between geographic points.
  • mulgara:ViewModel - A Mulgara graph for evaluating constraints against boolean combinations of other graphs.

In addition to the internal graph types listed above, Mulgara is also capable of exporting external graphs accessed via the file:, http:, and jar: protocols, as well as graphs stored on a remote Mulgara server and accessed via the rmi: protocol. In each of these cases, the export command essentially acts as an RDF graph copy.


The syntax for the export command is:
export <graph> to [local|remote] <file>;

  • <graph> is the URI of the graph to be exported.
  • <file> is the URI of the destination file to receive the exported contents of the graph. This must be an absolute URI using the file: protocol.
  • [local|remote] specifies the location of the destination file. If local is specified, the contents of the graph are streamed to the client and stored on the client filesystem. If remote is specified, the contents of the graph are stored on the remote server filesystem. If neither is specified, the default is remote. This option is not valid in the WebUI.

The syntax for the load command is:

load [local|remote] <source> into <graph>;

* @<graph>@ is the URI of the graph to receive the loaded content.
* @[local|remote]@ specifies the location of the source document if the source URI protocol is @file:@. @local@ specifies that the document resides on the client, and is streamed to the server first before loading into the graph. @remote@ specifies that the document resides on the server. If neither is specified, the default is @remote@.

h2. Defining Namespace Prefixes

The RDF/XML file that is exported from a graph creates a set of namespace prefix definitions. These prefixes are used to abbreviate URI's to a form allowed by XML for attribute names, and also to make them more readable (for more on XML namespaces see "Namespaces in XML":

The RDF/XML exporter uses a set of default prefix definitions for several common namespaces: RDF, RDFS, OWL, and DC (Dublin Core). Any URI in the exported graph that does not use one of these namespaces will have a new namespace prefix generated for it.  The prefix will be of the form "ns4", "ns5", etc.

Many tools that work with RDF will use the namespace definitions contained in the RDF/XML file as a way of abbreviating URI's when displaying them to make them more readable.  If you are working with one of these tools, it may be useful to define your own namespace prefixes so that resource URI's from the RDF/XML make more sense to you.  In TQL, this is accomplished through the use of the [[Alias|alias]] command.  Any alias that is defined for a namespace will also be defined as a namespace prefix in the RDF/XML file when you use the @export@ command.

h2. Examples

export <rmi://> to <file:/tmp/graphexport.rdf>;
export <rmi://> to remote <file:/tmp/graphexport.rdf>;
Both of these commands export the RDF content of the graph located at @<rmi://>@ to the file @/tmp/graphexport.rdf@ on the server filesystem.

export <rmi://> to local <file:/tmp/graphexport.rdf>;
This command will export the RDF content of the graph located at @<rmi://>@, streaming it across the network and storing it in the file @/tmp/graphexport.rdf@ on the client filesystem.

alias <> as ex;
export <rmi://> to <file:/tmp/graphexport.rdf>;
Executing these two commands in the same TQL shell will cause "ex" to be defined as a prefix for the namespace URI @ in the exported @graphexport.rdf@ file.

load <file:/tmp/mydata.rdf> into <rmi://>;
load remote <file:/tmp/mydata.rdf> into <rmi://>;
Both of these commands load the RDF content of the file @/tmp/mydata.rdf@ residing on the server filesystem into the graph @<rmi://>@.

load local <file:/tmp/mydata.rdf.gz> into <rmi://>;
This command opens the gzipped file @/tmp/mydata.rdf.gz@ on the client filesystem, decompresses it, and streams it to the server, where its contents are stored in the graph @<rmi://>@.

load <> into <rmi://>;
This command causes the server to open an HTTP input stream to the RDF content located at @<>@ and load it into the graph @<rmi://>@.

Updated by Gregg - almost 15 years ago ยท 6 revisions