View Source

The RDF Export tool is used to export the result of a {{SPARQL-CONSTRUCT}} or {{[SeRQL-CONSTRUCT|]}} 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|] or [TopBraid Composer|] .

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}

|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 ** 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:


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.

rdf export "PREFIX rdfs: <>
construct {?p rdfs:label ?l}
WHERE {?d <> ?p .
?p rdfs:label ?l }" names.nt

* 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:

construct distinct {P} rdfs:label {L} from
{D} <> {P} rdfs:label {L}

Now execute the following command using the system shell:

rdf export query.txt output-rdf.rdf rdfxml

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