Copyright © 2023 the Contributors to the RML-star Specification, published by theKnowledge Graph Construction Community Group under theW3C Community Contributor License Agreement (CLA). A human-readablesummary is available.
This document describes the [RML] vocabulary and approach to generate RDF-star [RDF-star].
This specification was published by theKnowledge Graph Construction Community Group. It is not a W3C Standard nor is it on the W3C Standards Track. Please note that under theW3C Community Contributor License Agreement (CLA) there is a limited opt-out and other conditions apply. Learn more aboutW3C Community and Business Groups.
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.
This section is non-normative.
RDF-star [RDF-star] is an extension of the Resource Description Framework (RDF) [RDF11-Concepts] that introduces a new kind of term, thequoted triple, which can be referred from the subjects or objects of other triples. Triples that include a quoted triple are known asRDF-star triples.
# The triple ( :Alice a :Person ) is 80% likely to be true<< :Alice a :Person >> :confidence 0.8 .
In RDF 1.1, anasserted triple is an element of the set of triples that compose anRDF graph. In RDF-star, a quoted triple can be asserted, if it is also included in the RDF graph, or not, if it only occurs as a quoted triple.
# The triple ( :Alice a :Person ) is asserted and quoted< :Alice a :Person > .<< :Alice a :Person >> :confidence 0.8 .
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 graphs with RML.
This document assumes that the reader is familiar with RDF, RML and RDF-star concepts.
In this document, examples assume that the following prefixes have been declared to represent the IRIs shown with them:
Prefix | Namespace |
---|---|
rml: | http://w3id.org/rml/ |
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 N-Triples-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
AnRML-star mapping defines a mapping from any data in a structured source format to RDF-star. It consists of one or moreTriples Maps that can in turn contain Triples Maps within the subject or object. A Triples Map can be Asserted or Non Asserted, depending on whether the triples that they generate should be included in the output graph.
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 generatedRDF-star triples for each of theTriples Maps in the RML-star mapping. AnRML-star processor may provide additional triples or graphs.
As in RML, conformingRML-star processors may rename blank nodes when providing access to the output dataset.
AnRML-star processor has access to one of the followings:
Abase IRI is used in resolving relativeIRIs produced by theRML-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 some [RML] classes.
rml:TriplesMap
is the class of Triples Maps as defined by RML-core.rml:AssertedTriplesMap
is the class of Triples Maps that are asserted.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-core.rml:TermMap
is the class of Term Maps, as defined by RML-core. It has the following subclasses:rml:SubjectMap
is the class of Subject Maps.rml:PredicateMap
is the class of Predicate Maps.rml:ObjectMap
is the class of Object Maps.rml:GraphMap
is the class of graph maps.rml:LanguageMap
is the class of language maps as defined by RML-core.rml:DatatypeMap
is the class of datatype maps as defined by RML-core.rml:StarMap
is the class of RDF-star Term Maps.rml:PredicateObjectMap
is the class of Predicate-Object Maps.rml:RefObjectMap
is the class of referencing Object Maps.rml:Join
is the class of join conditions.rml:ReferenceFormulation
is the class of supported reference formulations as defined by RML.The RML-star terms are summarized in the following tables.This vocabulary involves three classes (rml:StarMap
,rml:AssertedTriplesMap
andrml:NonAssertedTriplesMap
), and one object property (rml:quotedTriplesMap
).
Property | Domain | Range |
---|---|---|
rml:quotedTriplesMap | rml:StarMap | rml:AssertedTriplesMap or rml:NonAssertedTriplesMap |
Class | Superclass |
---|---|
rml:StarMap | owl:Thing |
rml:AssertedTriplesMap | rml:TriplesMap |
rml:NonAssertedTriplesMap | rml:TriplesMap |
All RML-star additions and changes to RML are shown in Figure 1:
AStar Map (rml:StarMap
) is similar to aterm map that generatesquoted triples.It can be used within Subject or Object Maps.A Star Map is linked to aTriples Map by thequoted Triples Map property (rml:quotedTriplesMap
).Thequoted triples generated by aStar Map are exactly those triples generated by itsquoted Triples Map.If a Star Map has the samelogical source as itsquoted Triples Map, then for eachlogical iteration, thequoted triples generated by a Star Map are those triples generated by itsquoted Triples Mapfor 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 inthe next section.
In the following example, for each logical iteration (i.e., each CSV row) a "type" triple is generated by<#innerTriplesMap>
that occursin the resulting graph both as an asserted and as a quoted triple:
# Contents of the ex:ConfidenceSource logical sourceentity , class , confidenceAlice , Person , 0.8Bobby , Dog , 0.6
# Triples Map that generates "type" triples that are asserted and quoted<#innerTriplesMap> a rml:AssertedTriplesMap; rml:logicalSource ex:ConfidenceSource; rml:subjectMap [ rml:template "http://example.com/{entity}" ]; rml:predicateObjectMap [ rml:predicate rdf:type; rml:objectMap [ rml:template "http://example.com/{class}" ]; ].# Triples Map that generates "confidence" triples<#outerTriplesMap> a rml:AssertedTriplesMap; rml:logicalSource ex:ConfidenceSource; rml:subjectMap [rml:quotedTriplesMap <#innerTriplesMap>; ]; rml:predicateObjectMap [ rml: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 aquoted triple within a Subject Map.Sincequoted triples can be both subjects or objects,Star Maps can alsobe used in the position of Object Maps, as shown in the following example:
# Contents of the ex:ConfidenceSource logical sourceentity , pet , classAlice , Bobby , DogSteve , Pumpkin , Cat
# Triples Map that generates "type" triples that are asserted and quoted<#innerTriplesMap> a rml:AssertedTriplesMap; rml:logicalSource ex:ConfidenceSource; rml:subjectMap [ rml:template "http://example.com/{pet}" ]; rml:predicateObjectMap [ rml:predicate rdf:type; rml:objectMap [ rml:template "http://example.com/{class}" ]; ].# Triples Map that generates "has pet" triples<#outerTriplesMap> a rml:AssertedTriplesMap; rml:logicalSource ex:ConfidenceSource; rml:subjectMap [ rml:template "http://example.com/{entity}"; ]; rml:predicateObjectMap [ rml: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 >> .
Asserted Triples Map generateasserted triples.If an Asserted Triples Map is also used in aStar Map, the triples it generatesalso occur in the resulting graph asquoted triples, by the process explained above.To generatequoted triples without assering them, Non Asserted Triples Maps are used instead.A Triples Map of subclassnon-asserted Triples Map does not generateasserted triples,but might generatequoted triples if it is used in aStar Map.
The following example is different than the previous in that<#innerTriplesMap>
is declared to be an instance ofrml:NonAssertedTriplesMap
, with the effect that the generated "type" triples are only present in the resulting graph asquoted triples, not asasserted triples:
# Contents of the ex:ConfidenceSource logical sourceentity , class , confidenceAlice , Person , 0.8Bobby , Dog , 0.6
# Triples Map that generates "type" triples that are only quoted, not asserted<#innerTriplesMap>a rml:NonAssertedTriplesMap; rml:logicalSource ex:ConfidenceSource; rml:subjectMap [ rml:template "http://example.com/{entity}"; ]; rml:predicateObjectMap [ rml:predicate rdf:type; rml:objectMap [ rml:template "http://example.com/{class}" ]; ].# Triples Map that generates "confidence" triples<#outerTriplesMap> a rml:AssertedTriplesMap; rml:logicalSource ex:ConfidenceSource; rml:subjectMap [ rml:quotedTriplesMap <#innerTriplesMap>; ]; rml:predicateObjectMap [ rml: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 ofasserted and/orquoted triples is given in the following table:
Quoted | Not quoted | |
---|---|---|
Asserted | rml:AssertedTriplesMap withrml:StarMap | rml:AssertedTriplesMap withoutrml:StarMap |
Not asserted | rml:NonAssertedTriplesMap withrml:StarMap | - |
It should be noted that Non Asserted Triples Maps that are not quoted do not generate any triple. For this reason, the use ofrml:NonAssertedTriplesMap
withoutrml:StarMap
is not allowed.rml:NonAssertedTriplesMap
must always be called withrml:quotedTriplesMap
.
RML-star can create RDF-star triples from multiplelogical sources.When creating RDF-star triples from multiplelogical sources,join conditions are used, just like when usingreferencing object maps in RML.
If astar map has ajoin condition, it generatesquoted triples as follows. Each combination of iterations, i.e., theCartesian product, from thechild source and theparent source is looked at. Here, we consider as child source thelogical source of theTriples Map in which the star map occurs, and as parent source the logical source of the star map'sQuoted Triples Map. A star map only generates quoted triples for combinations in which the join condition holds true. As is the case whenjoin conditions are used in in referencing object maps, a join condition checks for equality of thereference values of thechild/parent reference between iterations of the child/parent source.
If thelogical source of Triples Map in which astar map occurs and the logical source of star map'sQuoted Triples Map are not identical, then the star map must have at least onejoin condition.
# Contents of logical source ex:ClassesSourceentity , classAlice , PersonBobby , Dog
# Contents of logical source ex:ConfidencesSourceentity , confidenceAlice , 0.8Bobby , 0.6
# Triples Map that generates "type" triples<#innerTriplesMap> a rml:NonAssertedTriplesMap ; rml:logicalSource ex:ClassesSource ; rml:subjectMap [ rml:template "http://example.com/{entity}" ]; rml:predicateObjectMap [ rml:predicate rdf:type ; rml:objectMap [ rml:template "http://example.com/{class}" ] ].# Triples Map that generates "confidence" triples<#outerTriplesMap> a rml:AssertedTriplesMap; rml:logicalSource ex:ConfidencesSource; rml:subjectMap [ rml:quotedTriplesMap <#innerTriplesMap>rml:joinCondition [ rml:parent "entity"; rml:child "entity"; ]; ]; rml:predicateObjectMap [ rml: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 generatequoted triples which themselves are built from multiple sources.This is done by using aQuoted Triples Map which contains areferencing object map.
Note: this process for generatingquoted triples with areferencing object map is not different from the general process to create quoted triplesdescribed earlier, but we include this section for clarity.
# Contents of logical source ex:ClassesSourceentity , classAlice , PersonBobby , Dog
# Contents of logical source ex:ConfidencesSourceentity , confidenceAlice , 0.8Bobby , 0.6
# Triples Map that generates objects of "type" triples<#classTriplesMap> a rml:AssertedTriplesMap; rml:logicalSource ex:ClassesSource; rml:subjectMap [ rml:template "http://example.com/{class}"; ].# Triples Map that generates "type" triples using a join<#innerTriplesMap> a rml:NonAssertedTriplesMap; rml:logicalSource ex:ConfidencesSource; rml:subjectMap [ rml:template "http://example.com/{entity}"; ]; rml:predicateObjectMap [ rml:predicate rdf:type ; rml:objectMap [rml:parentTriplesMap <#classTriplesMap> ; rml:joinCondition [ rml:parent "entity" ; rml:child "entity" ; ]; ]; ].# Triples Map that generates "confidence" triples<#outerTriplesMap> a rml:AssertedTriplesMap; rml:logicalSource ex:ConfidencesSource; rml:subjectMap [ rml:quotedTriplesMap <#innerTriplesMap>; ]; rml:predicateObjectMap [ rml: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 aQuoted Triples Map that on its own turn also uses a Quoted Triples Map.
Note: this process for generating deeply nestedquoted triples is not different from the general process to create quoted triplesdescribed earlier, but we include this section for clarity.
# Contents of Logical Source ex:PredictionsSourceentity , class , confidence , predictorAlice , Person , 0.8 , alphaAlice , Giraffe , 1.0 , alphaBobby , Dog , 0.6 , alphaBobby , Giraffe , 1.0 , beta
# Triples Map that generates "type" triples<#innerTriplesMap> a rml:NonAssertedTriplesMap; rml:logicalSource ex:PredictionsSource; rml:subjectMap [ rml:template "http://example.com/{entity}"; ]; rml:predicateObjectMap [ rml:predicate rdf:type; rml:objectMap [ rml:template "http://example.com/{class}" ]; ].# Triples Map that generates "confidence" triples<#middleTriplesMap> a rml:NonAssertedTriplesMap; rml:logicalSource ex:PredictionsSource; rml:subjectMap [rml:quotedTriplesMap <#innerTriplesMap>; ]; rml:predicateObjectMap [ rml:predicate ex:confidence; rml:objectMap [ rml:reference "confidence" ]; ].# Triples Map that generates "predicted by" triples<#outerTriplesMap> a rml:AssertedTriplesMap; rml:logicalSource ex:PredictionsSource; rml:subjectMap [rml:quotedTriplesMap <#middleTriplesMap>; ]; rml:predicateObjectMap [ rml:predicate ex:predictedBy; rml:objectMap [ rml: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: