Information about RDF data
The data command can be used to parse one or more RDF data files in different formats.
Obtaining information about an RDF data file
Assuming the following content appears in a file called simple.ttl:
prefix : <http://example.org/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
:a :name "Alice" ;
:birthdate "1990-05-02"^^xsd:date ;
:enrolledIn :cs101 .
:b :name "Bob", "Robert" .
:cs101 :name "Computer Science" .
The following command parses the file simple.ttl and shows its contents:
rudof data simple.ttl
Converting between different RDF data syntaxes
It is possible to specify the output format to serialize the RDF data using the -r option. Possible values are: rdfxml, ntriples, trig, etc.:
rudof data -r rdfxml simple.ttl
The output would be something like:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns="http://example.org/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:its="http://www.w3.org/2005/11/its">
<rdf:Description rdf:about="http://example.org/b">
<name>Bob</name>
<name>Robert</name>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/cs101">
<name>Computer Science</name>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/a">
<name>Alice</name>
<birthdate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1990-05-02</birthdate>
<enrolledIn rdf:resource="http://example.org/cs101"/>
</rdf:Description>
</rdf:RDF>
It is possible to convert RDF data to a visual representation using the options svg, png or plantuml (see RDF visualization section).
Obtaining information about an RDF data located remotely
It is also possible to get RDF data from files which are remotely available through URIs like:
rudof data https://raw.githubusercontent.com/rudof-project/rudof/refs/heads/master/examples/simple.ttl
Merging RDF data
The data command can also be used to parse more than one RDF data files, merge them and serialize them to any of the RDF formats supported.
We carse several files, merge and serialize them in any of the RDF supported formats.
rudof data user.ttl simple.ttl -r rdfxml -o output.rdf
It is possible to serialize the files using a different format, like
ntriples,rdfxml, etc.
This merges multiple files given to the same data call. Inside rudof shell, where separate data calls can chain across a session, a second data FILE instead replaces the currently loaded data by default — add --merge to merge instead. See shell.
Reader mode
--reader-mode says how much the parser checks what it reads. It applies to every command that
reads RDF data, not just data.
In strict mode, the default, every term is validated. The first error stops
the whole document.
$ cat langstring.ttl
@prefix ex: <http://example.org/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
ex:a ex:b "x"^^rdf:langString .
$ rudof data langstring.ttl
Error: ... Parser error at line 3 between columns 16 and 30: The datatype of a literal without a language tag must not be rdf:langString
In lax mode the document is assumed to be valid, which skips those checks and makes parsing
faster, and what cannot be read at all is skipped instead of stopping the document. It is best
effort.
rudof data --reader-mode lax langstring.ttl
RDF visualization
It is possible to generate a visual representation of simple RDF graphs by using the --result-format option and selecting a visual format like svg or png.
By default this is rendered with PlantUML, so it is necessary to have the PlantUML binary downloaded and available through the PLANTUML variable — see convert: Prerequisites for how to set it up, and for the --viz-engine graphviz alternative (which needs Graphviz’s dot on PATH instead, no environment variable required).
Another alternative is to use the plantuml result format to generate an intermediate file and pass that file to some PlantUML processor.
As an example, the following command generates a plantuml file:
rudof data examples/simple.ttl -r plantuml -o file.plantuml
If you have PlantUML available you can use directly:
rudof data examples/simple.ttl -r svg -o file.svg
To render with Graphviz instead, pass --viz-engine graphviz:
rudof data examples/simple.ttl -r svg --viz-engine graphviz -o file.svg
Selecting the RDF backend
By default, rudof parses the input file(s) into an in-process RDF graph (the memory backend). The --backend flag lets you switch to a local QLever Docker container (qlever) or a remote SPARQL endpoint (endpoint=<URL_OR_NAME>, with --endpoint <URL_OR_NAME> / -e as a shortcut).
rudof data --backend qlever simple.ttl
rudof data --endpoint https://my.sparql.server/sparql simple.ttl
See the RDF backend (--backend) reference for full documentation.
RDF Config file
--config-file (-c in short form) passes a TOML configuration file, including the [rdf] section (base IRI, registered SPARQL endpoints). See Configuration and config.