<img src="https://rml-star.goatcounter.com/count?p=/test-noscript">

RML-star

Draft Community Group Report

Latest editor's draft:
https://w3id.org/kg-construct/rml-star
Editors:
(Ontology Engineering Group – Universidad Politécnica de Madrid)
(Ontology Engineering Group – Universidad Politécnica de Madrid)
(Ghent University – imec – IDLab)
(KU Leuven)
(Ontology Engineering Group – Universidad Politécnica de Madrid)
This Version:
https://kg-construct.github.io/rml-star-spec/20221126/
Previous Version:
https://kg-construct.github.io/rml-star-spec/20220504/
Website:
https://rml.io/
Feedback:
GitHub kg-construct/rml-star-spec (issues, pull requests)

Abstract

RML-star is an extension of RML designed for expressing customized mappings from heterogeneous data structures and serializations to RDF-star. Such mappings describe how existing data can be represented using RDF-star.

This document describes RML-star through definitions and examples.

The version of this document is Unreleased.

Status of This Document

This specification was published by the Knowledge Graph Construction Community Group. It is not a W3C Standard nor is it on the W3C Standards Track. Please note that under the W3C Community Contributor License Agreement (CLA) there is a limited opt-out and other conditions apply. Learn more about W3C Community and Business Groups.

This is an early draft, yet efforts are made to keep things stable.

1. Overview

This section is non-normative.

RDF-star [RDF-star] is an extension of the Resource Description Framework (RDF) [RDF11-Concepts]. RDF covers triples that are built from three terms: subject, predicate and object, and each term is either an IRI, a blank node or a literal. RDF-star adds a fourth kind of term: the RDF-star triple. With RDF-star, it is possible to represent metadata about individual triples.

# This RDF-star example says that the triple ( :Alice a :Person ) is 80% likely to be true
<< :Alice a :Person >> :confidence 0.8 .

RDF-star distinguishes between different types of RDF-star triples: depending on where a triple occurs, it can be either an asserted triple, a quoted triple, or both asserted and quoted. For a given RDF-star graph, i.e., for a given set of RDF-star triples, an asserted triple is a triple that is an element of the graph. A quoted triple is a triple that occurs as the subject or object of another triple. Quoted triples can also be called "embedded triples".

The RDF Mapping Language (RML) [RML] is a language for expressing mappings between heterogeneous data and RDF. In RML, rules can be expressed to iterate over a data source and refer to specific data within an iteration. Using these iterators and references, RML rules define how to express data in the data source in RDF. RML is based on and extends R2RML [R2RML]. R2RML is defined to express customized mappings only from relational databases to RDF datasets.

This document describes RML-star: an extension of RML that enables the generation of RDF-star triples with RML.

1.1 Conformance

As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.

1.2 Document conventions

We assume readers have basic familiarity with RDF, RML and RDF-star concepts.

In this document, examples assume the following namespace prefix bindings unless otherwise stated:

Prefix Namespace
rml: http://semweb.mmlab.be/ns/rml#
rr: http://www.w3.org/ns/r2rml#
xsd: http://www.w3.org/2001/XMLSchema#
ex: http://example.org/
: http://example.org/

The examples are contained in color-coded boxes. We use the Turtle syntax [Turtle] to write RDF and the Turtle-star syntax [RDF-star] to write RDF-star.

# This box contains an example input
# This box contains an example mapping
# This box contains the example output

2. The RML-star vocabulary

The RML-star vocabulary namespace is http://semweb.mmlab.be/ns/rml#.

The RML-star vocabulary preferred prefix is rml.

An RML-star mapping defines a mapping from any data in a structured source format to RDF-star. It consists of one or more triples maps that can in turn contain triples maps within the subject or object.

The input to an RML-star mapping is called input data source. The output of an RML-star mapping is called output dataset.

The output dataset of an RML-star mapping is an RDF-star dataset that contains the generated RDF-star triples for each of the triples maps in the RML-star mapping. RML-star processor may provide additional triples or graphs.

As in RML, conforming RML-star processors may rename blank nodes when providing access to the output dataset.

As in RML, an RML-star processor has access to one of the followings:

A base IRI is used in resolving relative IRIs produced by the RML-star mappings. According to the [R2RML] specification, the base IRI must be a valid [IRI]. It should not contain question mark (“?”) or hash (“#”) characters and should end in a slash (“/”) character.

The RML-star vocabulary consists of the RML-star specific defined classes but also includes all the [R2RML] and [RML] classes.

2.1 Overview of RML-star terms

The new terms and extensions or existing terms are summarized in the following tables. This vocabulary extension involves two class additions (rml:StarMap and rml:NonAssertedTriplesMap), three object property additions (rml:quotedTriplesMap, rml:subjectMap and rml:objectMap) and one property modification (rml:joinCondition). Note that the properties rr:objectMapand rr:subjectMap have been replaced for rml:subjectMap and rml:objectMap respectively. The original properties from R2RML had cardinality restrictions that prevent them from including rml:StarMap in their range.

Property Domain Range
rml:quotedTriplesMap rr:StarMap rml:TriplesMap
rml:subjectMap rr:TriplesMap Union of rr:SubjectMap, rml:StarMap
rml:objectMap rr:PredicateObjectMap Union of rr:ObjectMap, rr:RefObjMap, rml:StarMap
Class Superclass
rml:StarMap owl:Thing
rml:NonAssertedTriplesMap rr:TriplesMap

In certain cases, a join is needed to generate quoted triples. To achieve this, the domain of the property rr:joinCondition has been changed.

Property Old domain New domain
rr:joinCondition rr:RefObjMap Union of rr:RefObjMap, rml:StarMap

All RML-star additions and changes to RML are shown in Figure 1:

Target structure
Figure 1 To enable the generation of RDF-star graphs, RML-star adds three properties and two classes to the RML ontology, and it also modifies the domain of one property.

3. Generating quoted triples with RML-star

A star map (rml:StarMap) is similar to a term map that generates quoted triples. It can be used within subject and object maps. A star map is linked to a triples map by the quoted triples map property (rml:quotedTriplesMap). The quoted triples generated by a star map are exactly those triples generated by its quoted triples map. If a star map has the same logical source as its quoted triples map, then for each logical iteration, the quoted triples generated by a star map are those triples generated by its quoted triples map for the same logical iteration. If a star map has a different logical source than its quoted triples map then a join is used, as described in the next section.

In the following example, for each logical iteration (i.e., each CSV row) a "type" triple is generated by <#innerTriplesMap> that occurs in the resulting graph both as an asserted and as an quoted triple:

# contents of the ex:ConfidenceSource logical source
entity,class,confidence
Alice,Person,0.8
Bobby,Dog,0.6
# triples map that generates "type" triples
<#innerTriplesMap>
  a rr:TriplesMap ;
  rml:logicalSource ex:ConfidenceSource ;
  rml:subjectMap [
    rr:template "http://example.com/{entity}"
  ] ;
  rr:predicateObjectMap [
    rr:predicate rdf:type ;
    rml:objectMap [ rr:template "http://example.com/{class}" ]
  ] .

# triples map that generates "confidence" triples
<#outerTriplesMap>
  a rr:TriplesMap ;
  rml:logicalSource ex:ConfidenceSource ;
  rml:subjectMap [
    rml:quotedTriplesMap <#innerTriplesMap>
  ] ;
  rr:predicateObjectMap [
    rr:predicate ex:confidence ;
    rml:objectMap [ rml:reference "confidence" ]
  ] .
# Triples generated by <#innerTriplesMap>
ex:Alice a ex:Person .
ex:Bobby a ex:Dog .

# Triples generated by <#outerTriplesMap>
<< ex:Alice a ex:Person >> ex:confidence 0.8 .
<< ex:Bobby a ex:Dog >> ex:confidence 0.6 .

The previous example shows a quoted triple within a subject map. Since quoted triples can be both subjects and objects, star maps can also be used in the position of object maps, as the following example shows:

# contents of the ex:ConfidenceSource logical source
entity,pet,class
Alice,Bobby,Dog
Steve,Pumpkin,Cat
# triples map that generates "type" triples
<#innerTriplesMap>
  a rr:TriplesMap ;
  rml:logicalSource ex:ConfidenceSource ;
  rml:subjectMap [
    rr:template "http://example.com/{pet}"
  ] ;
  rr:predicateObjectMap [
    rr:predicate rdf:type ;
    rml:objectMap [ rr:template "http://example.com/{class}" ]
  ] .

# triples map that generates "has pet" triples
<#outerTriplesMap>
  a rr:TriplesMap ;
  rml:logicalSource ex:ConfidenceSource ;
  rml:subjectMap [
    rr:template "http://example.com/{entity}"
  ] ;
  rr:predicateObjectMap [
    rr:predicate ex:has_pet ;
    rml:objectMap [rml:quotedTriplesMap <#innerTriplesMap>]
  ] .
# Triples generated by <#innerTriplesMap>
ex:Bobby a ex:Dog .
ex:Pumpkin a ex:Cat .

# Triples generated by <#outerTriplesMap>
ex:Alice ex:has_pet << ex:Bobby a ex:Dog >> .
ex:Steve ex:has_pet << ex:Pumpkin a ex:Cat >> .

By default, triples generated by a triples map are generated as asserted triples. If the triples map is also used in a star map, the triples it generates also occur in the resulting graph as quoted triples, by the process explained above. The generation of asserted triples by a triples map can be supressed by declaring it an non-asserted triples map (rml:NonAssertedTriplesMap), a subclass of rr:TriplesMap. A triples map of subclass non-asserted triples map does not generate asserted triples, but might generate quoted triples if it is used in a star map.

The following example is different than the previous in that <#innerTriplesMap> is declared to be an instance of rml:NonAssertedTriplesMap, with the effect that the generated "type" triples are only present in the resulting graph as quoted triples, not as asserted triples:

# contents of the ex:ConfidenceSource logical source
entity,class,confidence
Alice,Person,0.8
Bobby,Dog,0.6
# triples map that generates "type" triples
<#innerTriplesMap>
  a rml:NonAssertedTriplesMap ;
  rml:logicalSource ex:ConfidenceSource ;
  rml:subjectMap [
    rr:template "http://example.com/{entity}"
  ] ;
  rr:predicateObjectMap [
    rr:predicate rdf:type ;
    rml:objectMap [ rr:template "http://example.com/{class}" ]
  ] .

# triples map that generates "confidence" triples
<#outerTriplesMap>
  a rr:TriplesMap ;
  rml:logicalSource ex:ConfidenceSource ;
  rml:subjectMap [
    rml:quotedTriplesMap <#innerTriplesMap>
  ] ;
  rr:predicateObjectMap [
    rr:predicate ex:confidence ;
    rml:objectMap [ rml:reference "confidence" ]
  ] .
<< ex:Alice a ex:Person >> ex:confidence 0.8 .
<< ex:Bobby a ex:Dog >> ex:confidence 0.6 .

A summary of how to generate triples in any combination of asserted and/or quoted triples is given in the following table, where rr:TriplesMap refers to instances of rr:TriplesMap that are not of the rml:NonAssertedTriplesMap subclass:

Quoted Not quoted
Asserted rr:TriplesMap with rml:StarMap rr:TriplesMap without rml:StarMap
Not asserted rml:NonAssertedTriplesMap with rml:StarMap -

It should be noted that not quoted and not asserted triples don't generate any triple at all. For that reason, the use of rml:NonAssertedTriplesMap without rml:StarMap is not allowed. rml:NonAssertedTriplesMap must always be called with rml:NonAssertedTriplesMap.

4. Generating quoted triples from multiple sources

RML-star can create RDF-star triples from multiple logical sources. When creating RDF-star triples from multiple logical sources, join conditions are used, just like when using referencing object maps in RML.

If a star map has a join condition, it generates quoted triples as follows. Each combination of iterations, i.e., the Cartesian product, from the child source and the parent source is looked at. Here, we consider as child source the logical source of the triples map in which the star map occurs, and as parent source the logical source of the star map's quoted triples map. A star map only generates quoted triples for combinations in which the join condition holds true. As is the case when join conditions are used in in referencing object maps, a join condition checks for equality of the reference values of the child/parent reference between iterations of the child/parent source.

If the logical source of triples map in which a star map occurs and the logical source of star map's quoted triples map are not identical, then the star map must have at least one join condition.

# contents of logical source ex:ClassesSource
entity,class
Alice,Person
Bobby,Dog
# contents of logical source ex:ConfidencesSource
entity,confidence
Alice,0.8
Bobby,0.6
# triples map that generates "type" triples
<#innerTriplesMap>
  a rml:NonAssertedTriplesMap ;
  rml:logicalSource ex:ClassesSource ;
  rml:subjectMap [
    rr:template "http://example.com/{entity}"
  ] ;
  rr:predicateObjectMap [
    rr:predicate rdf:type ;
    rml:objectMap [ rr:template "http://example.com/{class}" ]
  ] .

# triples map that generates "confidence" triples
<#outerTriplesMap> a rr:TriplesMap ;
  rml:logicalSource ex:ConfidencesSource ;
  rml:subjectMap [
    rml:quotedTriplesMap <#innerTriplesMap>
    rr:joinCondition [
      rr:parent "entity" ;
      rr:child "entity" ;
    ]
  ] ;
  rr:predicateObjectMap [
    rr:predicate ex:confidence ;
    rml:objectMap [ rml:reference "confidence" ]
  ] .
<< ex:Alice a ex:Person >> ex:confidence 0.8 .
<< ex:Bobby a ex:Dog >> ex:confidence 0.6 .

4.1 Using star map together with referencing object maps

It is also possible to generate quoted triples which themselves are built from multiple sources. This is done by using a quoted triples map which contains a referencing object map.

Note: this process for generating quoted triples with a referencing object map is not different from the general process to create quoted triples described earlier, but we include this section for clarity.

# contents of logical source ex:ClassesSource
entity,class
Alice,Person
Bobby,Dog
# contents of logical source ex:ConfidencesSource
entity,confidence
Alice,0.8
Bobby,0.6
# triples map that generates objects of "type" triples
<#classTriplesMap>
  a rr:TriplesMap ;
  rml:logicalSource ex:ClassesSource ;
  rml:subjectMap [
    rr:template "http://example.com/{class}"
  ] .

# triples map that generates "type" triples using a join
<#innerTriplesMap>
  a rml:NonAssertedTriplesMap ;
  rml:logicalSource ex:ConfidencesSource ;
  rml:subjectMap [
    rr:template "http://example.com/{entity}"
  ] ;
  rr:predicateObjectMap [
    rr:predicate rdf:type ;
    rml:objectMap [
      rr:parentTriplesMap <#classTriplesMap> ;
      rr:joinCondition [
        rr:parent "entity" ;
        rr:child "entity" ;
      ]
    ]
  ] .

# triples map that generates "confidence" triples
<#outerTriplesMap>
  a rr:TriplesMap ;
  rml:logicalSource ex:ConfidencesSource ;
  rml:subjectMap [
    rml:quotedTriplesMap <#innerTriplesMap>
  ] ;
  rr:predicateObjectMap [
    rr:predicate ex:confidence ;
    rml:objectMap [ rml:reference "confidence" ]
  ] .
<< ex:Alice a ex:Person >> ex:confidence 0.8 .
<< ex:Bobby a ex:Dog >> ex:confidence 0.6 .

5. Generating deeply nested quoted triples

It is possible to create more deeply nested RDF-star by using a quoted triples map that on its own turn also uses a quoted triples map.

Note: this process for generating deeply nested quoted triples is not different from the general process to create quoted triples described earlier, but we include this section for clarity.

# contents of logical source ex:PredictionsSource
entity,class,confidence,predictor
Alice,Person,0.8,alpha
Alice,Giraffe,1.0,alpha
Bobby,Dog,0.6,alpha
Bobby,Giraffe,1.0,beta
# triples map that generates "type" triples
<#innerTriplesMap>
  a rml:NonAssertedTriplesMap ;
  rml:logicalSource ex:PredictionsSource ;
  rml:subjectMap [
    rr:template "http://example.com/{entity}"
  ] ;
  rr:predicateObjectMap [
    rr:predicate rdf:type ;
    rml:objectMap [ rr:template "http://example.com/{class}" ]
  ] .

# triples map that generates "confidence" triples
<#middleTriplesMap>
  a rml:NonAssertedTriplesMap ;
  rml:logicalSource ex:PredictionsSource ;
  rml:subjectMap [
    rml:quotedTriplesMap <#innerTriplesMap>
  ] ;
  rr:predicateObjectMap [
    rr:predicate ex:confidence ;
    rml:objectMap [ rml:reference "confidence" ]
  ] .

# triples map that generates "predicted by" triples
<#outerTriplesMap>
  a rr:TriplesMap ;
  rml:logicalSource ex:PredictionsSource ;
  rml:subjectMap [
    rml:quotedTriplesMap <#middleTriplesMap>
  ] ;
  rr:predicateObjectMap [
    rr:predicate ex:predictedBy ;
    rml:objectMap [ rr:template "http://example.com/{predictor}" ]
  ] .
<< << ex:Alice a ex:Person >> ex:confidence 0.8 >> ex:predictedBy ex:alpha .
<< << ex:Alice a ex:Giraffe >> ex:confidence 1.0 >> ex:predictedBy ex:beta .
<< << ex:Bobby a ex:Dog >> ex:confidence 0.6 >> ex:predictedBy ex:alpha .
<< << ex:Bobby a ex:Giraffe >> ex:confidence 1.0 >> ex:predictedBy ex:beta .

A. References

A.1 Informative references

[IRI]
Internationalized Resource Identifiers (IRIs). M. Duerst; M. Suignard. IETF. January 2005. Proposed Standard. URL: https://www.rfc-editor.org/rfc/rfc3987
[R2RML]
R2RML: RDB to RDF Mapping Language. W3C. 27 September 2012. W3C Recommendation. URL: https://www.w3.org/TR/r2rml/
[RDF-star]
RDF-star and SPARQL-star. W3C. 17 December 2021. Final Community Group Report. URL: https://www.w3.org/2021/12/rdf-star.html
[RDF11-Concepts]
RDF 1.1 Concepts and Abstract Syntax. W3C. 25 February 2014. W3C Recommendation. URL: https://www.w3.org/TR/rdf11-concepts/
[RML]
RDF Mapping Language. https://rml.io. 06 October 2020. Unofficial draft. URL: https://rml.io/specs/rml/
[Turtle]
RDF 1.1 Turtle. W3C. 25 February 2014. W3C Recommendation. URL: https://www.w3.org/TR/turtle/