Copyright © 2021-2022 the Contributors to the RML-star Specification, published by the Knowledge Graph Construction Community Group under the W3C Community Contributor License Agreement (CLA). A human-readable summary is available.
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.
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.
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.
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.
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
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.
rr:TriplesMap
is the class of triples maps as defined by R2RML.rml:NonAssertedTriplesMap
is the class of triples maps that are not asserted, but only quoted.rml:LogicalSource
is the class of logical sources as defined by RML.rml:BaseSource
is the class of data sources used as input source as defined by RML. R2RML's rr:BaseTableOrView
is a subclass of rml:BaseSource
.rr:TermMap
is the class of term maps, as defined by R2RML. It has four subclasses:rr:SubjectMap
is the class of subject maps.rr:PredicateMap
is the class of predicate maps.rr:ObjectMap
is the class of object maps.rr:GraphMap
is the class of graph maps.rml:LanguageMap
is the class of language maps as defined by RML.rml:StarMap
is the class of RDF-star term maps.rr:PredicateObjectMap
is the class of predicate-object maps.rr:RefObjectMap
is the class of referencing object maps.rr:Join
is the class of join conditions.rml:ReferenceFormulation
is the class of supported reference formulations as defined by RML.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:objectMap
and 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:
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
.
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 .
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 .
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 .
Referenced in:
Referenced in:
Referenced in: