View Source

The RDF Export tool is used to export the result of a {{SPARQL-CONSTRUCT}} or {{[SeRQL-CONSTRUCT|http://www.openrdf.org/doc/sesame/users/ch06.html#d0e1371]}} into RDF XML or N-Triple files. The tool allows you to export structured data, generated by KIM, to be used in other applications that can work with RDF, like [Protege-OWL|http://protege.stanford.edu/overview/protege-owl.html] or [TopBraid Composer|http://www.topquadrant.com/products/TB_Composer.html] .

The RDF Export tool is located in *<KIM_HOME>/bin/tools* folder and requires a running instance of KIM.

Usage: {code}rdf export <query> <output file> [<outputformat>]{code}

||Parameters||Description||
|query| {{SPARQL-CONSTRUCT}} or {{SeRQL-CONSTRUCT}} query or a file containing one|
|output file|name of the file where the output will be written; If a file with the same name exists, it will be rewritten|
|output format| type either {{NTRIPLES}} or {{RDFXML}}, case-insensitive. The parameter is optional; default is {{NTRIPLES}}.|

By default, the tool will export data from a KIM server running at {{localhost}}. To export data from a KIM server, running on a remote machine, users need to create a configuration file named *kim_connection.properties* within the directory from which they are running the tool script. The file should contain at least two key-value pairs representing the KIM server host and port.

An example:

{code:title=kim_connection.properties|borderStyle=solid}
com.ontotext.kim.KIMConstants.RMI_HOST=192.168.1.200
com.ontotext.kim.KIMConstants.RMI_PORT=1199
{code}

h2. Examples

* Exporting all names of entities that KIM has found in documents using {{SPARQL-CONSTRUCT}}

New lines are added for clarification. The command should be executed as a single line.

{code}
rdf export "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
construct {?p rdfs:label ?l}
WHERE {?d <http://proton.semanticweb.org/2006/05/protonkm#mentions> ?p .
?p rdfs:label ?l }" names.nt
{code}

* Exporting all names of entities that KIM has found in documents using {{SeRQL-CONSTRUCT}} query in a file

To shorten the command, create a text file in *<KIM_HOME>/bin/tools* called *query.txt* with the following contents:

{code}
construct distinct {P} rdfs:label {L} from
{D} <http://proton.semanticweb.org/2006/05/protonkm#mentions> {P} rdfs:label {L}
{code}

Now execute the following command using the system shell:

{code}
rdf export query.txt output-rdf.rdf rdfxml
{code}

After the tool finishes, the results can be found in the *output-rdf.rdf* file written with RDF-XML format.