Skip to content

RML in a nutshell

RML, the RDF Mapping Language, describes how structured data becomes RDF. It generalizes R2RML, the W3C Recommendation for mapping relational databases, to other sources such as JSON, XML and CSV.

RML terms live in the http://w3id.org/rml/ namespace, usually bound to the prefix rml:.

Triples maps

A mapping is a set of triples maps. A triples map names a source, says how to iterate over it, and says which triples to produce for each record.

@prefix rml:  <http://w3id.org/rml/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<TriplesMap1> a rml:TriplesMap ;

  # where the data comes from and how to iterate over it
  rml:logicalSource [ a rml:LogicalSource ;
      rml:source [ a rml:RelativePathSource ; rml:path "student.json" ] ;
      rml:referenceFormulation rml:JSONPath ;
      rml:iterator "$.students[*]" ] ;

  # the subject of each record's triples
  rml:subjectMap [ rml:template "http://example.com/{$.Name}" ] ;

  # the predicate and object pairs for each record
  rml:predicateObjectMap [
      rml:predicate foaf:name ;
      rml:objectMap [ rml:reference "$.Name" ] ] .
Term Meaning
rml:logicalSource The input (rml:source), the query language for it (rml:referenceFormulation) and the iteration (rml:iterator).
rml:subjectMap How to build the subject for each record.
rml:predicateObjectMap One or more predicate and object pairs.
rml:referenceFormulation rml:JSONPath, rml:XPath, rml:CSV, rml:SQL2008Query or rml:SQL2008Table.

Term maps

Subjects, predicates, objects and graphs come from term maps. A term map gets its value in one of these ways:

  • rml:constant is a fixed value.
  • rml:reference is one expression evaluated against the current record, such as a JSONPath.
  • rml:template is a string with {reference} placeholders.
  • rml:functionExecution calls a function.

Modules

RML is split into modules. CARML supports these:

Module Adds Guide
RML-Core Triples maps and term maps this page
RML-LV Logical views: named fields, nested iteration, joins Logical views
RML-IO Source descriptions and logical targets Data sources, Logical targets
RML-FNML Functions Functions
RML-CC rdf:List, rdf:Bag, rdf:Seq and rdf:Alt

RML-star is not supported. Conformance has the test results per module.

Older mappings

CARML also reads legacy RML (http://semweb.mmlab.be/ns/rml#) and R2RML (rr:), so existing mappings keep working. Write new mappings in the http://w3id.org/rml/ namespace. The vocabulary page lists every namespace CARML reads.