Reading and Writing RDF in Apache Jena

This page details the setup of RDF I/O technology (RIOT).

Formats

The following RDF formats are supported by Jena. In addition, other syntaxes can be integrated into both the parser and writer registries.

RDF/JSON is not JSON-LD - it is a direct encoding of RDF triples in JSON. See the description of RDF/JSON.

Command line tools

There are scripts in Jena download to run these commands.

These can be called directly as Java programs:

The file extensions understood are:

 Extension    Language 
.ttl Turtle
.nt N-Triples
.nq N-Quads
.trig TriG
.rdf RDF/XML
.owl RDF/XML

.n3 is supported but only as a synonym for Turtle.

In addition, if the extension is .gz the file is assumed to be gzip compressed. The file name is examined for an inner extension. For example, .nt.gz is gzip compressed N-Triples.

These scripts call java programs in the riotcmd package. For example:

java -cp ... riotcmd.riot file.ttl

The scripts all accept the same arguments (type "riot --help" to get command line reminders):

To aid in checking for errors in UTF8-encoded files, there is a utility which reads a file of bytes as UTF8 and checks the encoding.

Inference

RIOT support creation of inferred triples during the parsing process:

riotcmd.infer --rdfs VOCAB FILE FILE ...

Output will contain the base data and triples inferred based on RDF subclass, subproperty, domain and range declarations.