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.

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. An example of a Logical Source is shown below.


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

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. An example of a Subject Map is shown below.

        
<#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. An example of a Predicate Object Map is shown below.

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

The aforementioned examples refer to the following JSON file called People.json as input

            

[ ...   { "Title": "IDLab",
          "People": [ { "name": "Anastasia",  "surname": "Dimou" },
                      { "name": "Ruben", "surname": "Verborgh" } ],
        { "Title": "Media and ICT",
          "People": [ ... ] } ,  ... ]
            
        

and generate the following RDF output.

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

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