Resource Description Framework (RDF)

RDF is a standard model for data interchange on the Web. It is the foundation of Linked Data and for this reason, the foundation of TreeLDR. Every TreeLDR set of documents is fundamentally an RDF dataset. TreeLDR builds upon the W3C Web Ontology Language (OWL) by using the same vocabulary and semantics, extended with its own vocabulary to define layouts.

Generating an RDF Dataset

Generating a JSON-LD context is done by using the rdf subcommand of the command line utility after the list of inputs. No need to specify what to export: everything will be exported in RDF.

tldrc -i input1 ... -i inputN rdf

For instance, consider the following layout for the schema:BlogPosting type:

base <https://example.com/>;
use <http://www.w3.org/2001/XMLSchema#> as xs;

/// An example.
type Example {
	/// A property.
	property: xs:string
}

Using the following command:

tldrc -i example/basic_post.tldr -i example/schema.org.tldr rdf

We can generate the following RDF dataset in N-Quads:

_:6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://treeldr.org/Layout> .
_:6 <https://treeldr.org/name> "example_property" .
_:6 <https://treeldr.org/option> <http://www.w3.org/2001/XMLSchema#string> .
<https://example.com/Example> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> .
<https://example.com/Example> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://treeldr.org/Layout> .
<https://example.com/Example> <https://treeldr.org/layoutFor> <https://example.com/Example> .
<https://example.com/Example> <https://treeldr.org/name> "Example" .
_:7 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://treeldr.org/Field> .
_:7 <https://treeldr.org/fieldFor> <https://example.com/Example/property> .
_:7 <https://treeldr.org/format> _:6 .
_:7 <https://treeldr.org/name> "property" .
_:7 <http://www.w3.org/2000/01/rdf-schema#label> "A property." .
_:8 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#List> .
_:8 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:7 .
_:8 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
<https://example.com/Example> <https://treeldr.org/fields> _:8 .
<https://example.com/Example> <http://www.w3.org/2000/01/rdf-schema#label> "An example." .
<https://example.com/Example/property> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> .
<https://example.com/Example/property> <http://www.w3.org/2000/01/rdf-schema#domain> <https://example.com/Example> .
<https://example.com/Example/property> <http://www.w3.org/2000/01/rdf-schema#range> <http://www.w3.org/2001/XMLSchema#string> .
<https://example.com/Example/property> <http://www.w3.org/2000/01/rdf-schema#label> "A property." .
_:2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://treeldr.org/Layout> .
_:2 <https://treeldr.org/name> "resource_id" .
_:2 <https://treeldr.org/option> _:1 .
_:5 <http://www.w3.org/2000/01/rdf-schema#label> "A property." .
_:1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://treeldr.org/Layout> .
_:1 <https://treeldr.org/layoutFor> <http://www.w3.org/2000/01/rdf-schema#Resource> .
_:1 <https://treeldr.org/reference> <https://treeldr.org/IRI> .

Importing an RDF Dataset

N-Quads import is not yet implemented.

The TreeLDR compiler (tldrc) can import an RDF dataset like any other input document using the -i option. For instance, we can import and export back the previously generated RDF dataset above, and we will get back the same document:

tldrc -i examples/basic_post.schema.nq rdf

Last updated