@@ -403,14 +392,16 @@ RML-CC: Collections and Containers in RML
The associated RML mapping starts as follows:
@prefix rml: <http://w3id.org/rml/>.
-@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
@prefix ex: <http://example.com/ns>.
-@base <http://example.com/ns>.
<#TM> a rml:TriplesMap;
rml:logicalSource [
- rml:source "data.json" ;
- rml:referenceFormulation ql:JSONPath ;
+ rml:referenceFormulation rml:JSONPath;
+ rml:source [
+ a rml:RelativePathSource;
+ rml:root rml:MappingDirectory;
+ rml:path "data.json"
+ ] ;
rml:iterator "$.*" ;
];
@@ -448,18 +439,18 @@ RML-CC: Collections and Containers in RML
rml:predicateObjectMap [
rml:predicate ex:with ;
rml:objectMap [
- rml:template "list/{id}" ;
+ rml:template "list{id}" ;
rml:gather ( [ rml:reference "values.*" ; ] ) ;
rml:gatherAs rdf:List ;
] ;
] ;
will yield the following output:
-:a ex:with :list/a . :list/a rdf:first "1" ; rdf:rest ("2" "3") .
-:b ex:with :list/b . :list/b rdf:first "4" ; rdf:rest ("5" "6") .
-:c ex:with :list/c . :list/c rdf:first "7" ; rdf:rest ("8" "9") .
+:a ex:with :lista . :lista rdf:first "1" ; rdf:rest ("2" "3") .
+:b ex:with :listb . :listb rdf:first "4" ; rdf:rest ("5" "6") .
+:c ex:with :listc . :listc rdf:first "7" ; rdf:rest ("8" "9") .
-This is similar to the previous example, yet in this case the head node of each produced collection is assigned an IRI :list/a
, :list/b
and :list/c
.
+This is similar to the previous example, yet in this case the head node of each produced collection is assigned an IRI :lista
, :listb
and :listc
.
This section introduces the classes, properties, and constants of the RML Containers and Collections specification.
@@ -470,6 +461,7 @@ RML-CC: Collections and Containers in RML
A rml:GatherMap
MUST have exactly one rml:gatherAs
property.
A rml:GatherMap
MAY have zero or exactly one rml:strategy
property.
+A strategy is a plan or set of actions designed to achieve a specific goal or outcome. Instances of rml:Strategy
represent ways to perform an action such as combining two collections and containers. See constants for examples.
The rml:gather
informs the RML processor where the terms of a collection or container come from. This property relates a gather map with a non-empty list of term maps.
@@ -478,7 +470,7 @@
RML-CC: Collections and Containers in RML
The domain of rml:gather
is rml:GatherMap
.
The range of rml:gather
is a non-empty list (rdf:List) of rml:TermMap
instances. In particular, this list may include instances of rml:GatherMap
thus allowing for nested gather maps.
-
Declaring an rml:strategy
in a gather map informs the processor about how to create collections and containers when faced with multi-valued term maps.
This specification defines rml:append
and rml:cartesianProduct
as instances of rml:Strategy
.
In the rml:append
strategy, the sets of RDF terms generated by each term map of the gather map are simply appended to the collection (respectively container) being constructed. Thus, only one collection (respectively container) is generated.
@@ -500,8 +492,7 @@ RML-CC: Collections and Containers in RML
The range of rml:allowEmptyListAndContainer
is xsd:boolean
.
Property rml:allowEmptyListAndContainer
is optional, it takes the value false by default.
-
rml:append
is an instance of class rml:Strategy
.
Used as the object of property rml:strategy
, it informs the processor that the sets of RDF terms generated by each term map of the gather map are to be appended within the collection or container. The order is that in which the term maps are declared in the gather map. Example:
For the input document:
@@ -557,16 +548,16 @@ RML-CC: Collections and Containers in RML
rml:predicateObjectMap [
rml:predicate ex:with ;
rml:objectMap [
- rml:template "seq/{id}" ;
+ rml:template "seq{id}" ;
rml:gather ( [ rml:reference "values.*" ; ] ) ;
rml:gatherAs rdf:Seq ;
] ;
] ;
will yield the following output:
-:a ex:with :seq/a . :seq/a rdf:_1 "1" ; rdf:_2 "2" , rdf:_3 "3" .
-:b ex:with :seq/b . :seq/b rdf:_1 "4" ; rdf:_2 "5" , rdf:_3 "6" .
-:c ex:with :seq/c . :seq/c rdf:_1 "7" ; rdf:_2 "8" , rdf:_3 "9" .
+:a ex:with :seqa . :seqa rdf:_1 "1" ; rdf:_2 "2" , rdf:_3 "3" .
+:b ex:with :seqb . :seqb rdf:_1 "4" ; rdf:_2 "5" , rdf:_3 "6" .
+:c ex:with :seqc . :seqc rdf:_1 "7" ; rdf:_2 "8" , rdf:_3 "9" .
Let's consider the following input document:
@@ -638,7 +629,7 @@ RML-CC: Collections and Containers in RML
Now, when an rml:template
, rml:constant
or rml:reference
is provided, to avoid generating ill-formed lists that would share the same head node IRI, the processor must concatenate the lists.
If we add an rml:template
in the object map:
rml:objectMap [
- rml:template "list/{id}" ;
+ rml:template "list{id}" ;
rml:gather ( [ rml:reference "a.*" ] [ rml:reference "b.*" ]) ;
rml:gatherAs rdf:List ;
rml:strategy rml:cartesianProduct ;
@@ -668,7 +659,7 @@ RML-CC: Collections and Containers in RML
rml:predicateObjectMap [
rml:predicate ex:with ;
rml:objectMap [
- rml:template "list/{id}" ;
+ rml:template "list{id}" ;
rml:gather ( [ rml:reference "values1.*" ; ] [ rml:reference "values2.*" ; ] ) ;
rml:gatherAs rdf:List ;
] ;
@@ -677,14 +668,14 @@ RML-CC: Collections and Containers in RML
For each document, the values of values1
and values2
are appended in the same list, as per the default rml:append
strategy.
Furthermore, the lists generated for id "a"
must be concatenated since they share the same head node IRI, as explained in the multiple iterations case.
The expected output is:
-:a ex:with :list/a .
-:list/a rdf:first "1" ; rdf:rest ("a" "b" "5" "6" "e") .
-:b ex:with :list/b .
-:list/b rdf:first "3" ; rdf:rest ("4" "c" "d") .
+:a ex:with :lista .
+:lista rdf:first "1" ; rdf:rest ("a" "b" "5" "6" "e") .
+:b ex:with :listb .
+:listb rdf:first "3" ; rdf:rest ("4" "c" "d") .
Now let's change the default strategy to rml:cartesianProduct
:
rml:objectMap [
- rml:template "list/{id}" ;
+ rml:template "list{id}" ;
rml:gather ( [ rml:reference "values1.*" ; ] [ rml:reference "values2.*" ; ] ) ;
rml:gatherAs rdf:List ;
rml:strategy rml:cartesianProduct ;
@@ -696,10 +687,10 @@ RML-CC: Collections and Containers in RML
Similarly, for the documents with id "a"
, the result is: ("1" "a" "1" "b")
and ("5" "e" "6" "e")
.
But again, these lists must be concatenated since they share the same head node IRI, as explained in the multiple iterations case.
Therefore, the processor must now generate the following output:
-:a ex:with :list/a .
-:list/a rdf:first "1" ; rdf:rest ("a" "1" "b" "5" "e" "6" "e") .
-:b ex:with :list/b .
-:list/b rdf:first "3" ; rdf:rest ("c" "3" "d" "4" "c" "4" "d") .
+:a ex:with :lista .
+:lista rdf:first "1" ; rdf:rest ("a" "1" "b" "5" "e" "6" "e") .
+:b ex:with :listb .
+:listb rdf:first "3" ; rdf:rest ("c" "3" "d" "4" "c" "4" "d") .
+:seqc rdf:_1 "7" ; rdf:_2 "8" ; rdf:_3 "9" .
+:seqc prov:wasDerivedFrom <data.json> .
@@ -1130,4 +1124,4 @@ RML-CC: Collections and Containers in RML
panel.hidden = true;
panel.classList.remove("docked");
}
-})()
\ No newline at end of file
+})()