RDF Mapping Language (RML)


The RDF Mapping language (RML) is a generic scalable mapping language defined to express rules that map data in heterogeneous structures and serializations to the RDF data model.
RML deals with the mapping definitions in a uniform, modular, interoperable and extensible fashion.
RML is defined as a superset of the W3C-recommended mapping language, R2RML, that maps data in relational databases to RDF.

In RML, the mapping of data to the RDF data model is based on one or more Triples Maps that defines how the triples will be generated.

Triples Map

A Triples Map defines rules to generate zero or more RDF triples sharing the same subject.
A Triples Map consists of a Logical Source, a Subject Map and zero or more Predicate-Object Maps.
RML Vs R2RML
In blue R2RML's components.
In green R2RML's extended components.
In red RML's specific components.

Logical Source

A Logical Source consists of (i) a reference to input source(s), (ii) the Reference Formulation to specify how to refer to the data and (iii) the iterator that specifies how to iterate over the data.
The following reference formulations are predefined but not limited:
ql:CSV, ql:CSS3, ql:JSONPath, rr:SQL2008 and ql:XPath.
RML Logical Source

<#PersonMapping>
  rml:logicalSource [
    rml:source "People.json";
    rml:referenceFormulation ql:JSONPath;
    rml:iterator "$.[*].Person" ]. 

Subject Map

The Subject Map consists of the URI pattern that defines how each triple's subject is generated and optionally its type.

The references to the input data occurs using valid references according to reference formulation specified at the Logical Source.
Subject Map

<#PersonMapping>
  rr:subjectMap [
    rr:template "http://ex.com/Person/{name}_{surname}";
    rr:class ex:Person ].  


Predicate Object Map

Triples are generated using Predicate Object Maps.
A Predicate Object Map consists of Predicate and an Object Map(s).
A Predicate Map specifies how the triple's predicate is generated.
An Object Map specifies how the triple's object(s) are generated.
Predicate Object Map

<#PersonMapping>
  rr:predicateObjectMap [
    rr:predicate ex:name;
    rr:objectMap [ rml:reference "name" ] ].  



The aforementioned examples refer to the following JSON file as Input and generate the following RDF output.

Input in JSON format (People.json)

[ ...   { "Title": "Multimedia Lab",
          "People": [ { "name": "Anastasia",  "surname": "Dimou" },
                      { "name": "Ruben", "surname": "Verborgh" } ],
        { "Title": "Media and ICT",
          "People": [ ... ] } ,  ... ]
Output RDF representation

ex:Anastasia_Dimou a ex:Person ;
  ex:name "Anastasia".

ex:Ruben_Verborgh a ex:Person ;
  ex:name "Ruben".