Skip to content

Commit 90ab040

Browse files
authored
Merge pull request #49 from kg-construct/rmlStrategy
Included RML Strategy, fixed some mistakes, and updated sources to respect RML-IO
2 parents 4a3be2f + 70f3932 commit 90ab040

File tree

7 files changed

+152
-150
lines changed

7 files changed

+152
-150
lines changed

ontology/rml-cc.owl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ foaf:name rdf:type owl:AnnotationProperty .
110110
:strategy rdf:type owl:ObjectProperty ;
111111
rdfs:domain :GatherMap ;
112112
rdfs:range :Strategy ;
113-
rdfs:comment "A Strategy element to indicate how to perform an action (e.g. gather for collections and containers, join)."@en ;
113+
rdfs:comment "A Strategy element to indicate how to perform an action."@en ;
114114
rdfs:isDefinedBy <http://w3id.org/rml/cc/> ;
115115
rdfs:label "strategy" .
116116

@@ -142,7 +142,7 @@ foaf:name rdf:type owl:AnnotationProperty .
142142

143143
### http://w3id.org/rml/Strategy
144144
:Strategy rdf:type owl:Class ;
145-
rdfs:comment "Denotes a strategy to perform a action (e.g. gather for collections and containers, joins)."@en ;
145+
rdfs:comment "Denotes a strategy to perform an action or process."@en ;
146146
rdfs:isDefinedBy <http://w3id.org/rml/cc/> ;
147147
rdfs:label "Strategy" .
148148

spec/rendered.html

Lines changed: 90 additions & 96 deletions
Large diffs are not rendered by default.

spec/section/considerations.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The following mapping:
2525
rml:predicateObjectMap [
2626
rml:predicate ex:with ;
2727
rml:objectMap [
28-
rml:template "seq/{id}" ;
28+
rml:template "seq{id}" ;
2929
rml:gather ( [ rml:reference "values.*" ; ] ) ;
3030
rml:gatherAs rdf:Seq ;
3131
] ;
@@ -35,9 +35,9 @@ The following mapping:
3535
will yield the following output:
3636

3737
<pre class="ex-output">
38-
:a ex:with :seq/a . :seq/a rdf:_1 "1" ; rdf:_2 "2" , rdf:_3 "3" .
39-
:b ex:with :seq/b . :seq/b rdf:_1 "4" ; rdf:_2 "5" , rdf:_3 "6" .
40-
:c ex:with :seq/c . :seq/c rdf:_1 "7" ; rdf:_2 "8" , rdf:_3 "9" .
38+
:a ex:with :seqa . :seqa rdf:_1 "1" ; rdf:_2 "2" , rdf:_3 "3" .
39+
:b ex:with :seqb . :seqb rdf:_1 "4" ; rdf:_2 "5" , rdf:_3 "6" .
40+
:c ex:with :seqc . :seqc rdf:_1 "7" ; rdf:_2 "8" , rdf:_3 "9" .
4141
</pre>
4242

4343

@@ -91,7 +91,7 @@ With the following predicate mapping:
9191
rml:predicateObjectMap [
9292
rml:predicate ex:with ;
9393
rml:objectMap [
94-
rml:template "list/{id}" ;
94+
rml:template "list{id}" ;
9595
rml:gather ( [ rml:reference "values.*" ; ] ) ;
9696
rml:gatherAs rdf:List ;
9797
] ;
@@ -101,8 +101,8 @@ With the following predicate mapping:
101101
The processor must generate the following output:
102102

103103
<pre class="ex-output">
104-
:a ex:with :list/a . :list/a rdf:first "1" ; rdf:rest ("2" "3" "7" "8" "9") .
105-
:b ex:with :list/b . :list/b rdf:first "4" ; rdf:rest ("5" "6") .
104+
:a ex:with :lista . :lista rdf:first "1" ; rdf:rest ("2" "3" "7" "8" "9") .
105+
:b ex:with :listb . :listb rdf:first "4" ; rdf:rest ("5" "6") .
106106
</pre>
107107

108108
It is assumed that a processor will concatenate the collections or containers while respecting the order of the iterations as provided by the logical source.
@@ -147,7 +147,7 @@ Now, when an `rml:template`, `rml:constant` or `rml:reference` is provided, to a
147147
If we add an `rml:template` in the object map:
148148
<pre class="ex-mapping">
149149
rml:objectMap [
150-
rml:template "list/{id}" ;
150+
rml:template "list{id}" ;
151151
rml:gather ( [ rml:reference "a.*" ] [ rml:reference "b.*" ]) ;
152152
rml:gatherAs rdf:List ;
153153
rml:strategy rml:cartesianProduct ;
@@ -187,7 +187,7 @@ Let's consider the following document and mapping:
187187
rml:predicateObjectMap [
188188
rml:predicate ex:with ;
189189
rml:objectMap [
190-
rml:template "list/{id}" ;
190+
rml:template "list{id}" ;
191191
rml:gather ( [ rml:reference "values1.*" ; ] [ rml:reference "values2.*" ; ] ) ;
192192
rml:gatherAs rdf:List ;
193193
] ;
@@ -199,17 +199,17 @@ Furthermore, the lists generated for id `"a"` must be concatenated since they sh
199199
The expected output is:
200200

201201
<pre class="ex-output">
202-
:a ex:with :list/a .
203-
:list/a rdf:first "1" ; rdf:rest ("a" "b" "5" "6" "e") .
204-
:b ex:with :list/b .
205-
:list/b rdf:first "3" ; rdf:rest ("4" "c" "d") .
202+
:a ex:with :lista .
203+
:lista rdf:first "1" ; rdf:rest ("a" "b" "5" "6" "e") .
204+
:b ex:with :listb .
205+
:listb rdf:first "3" ; rdf:rest ("4" "c" "d") .
206206
</pre>
207207

208208
Now let's change the default strategy to `rml:cartesianProduct`:
209209

210210
<pre class="ex-mapping">
211211
rml:objectMap [
212-
rml:template "list/{id}" ;
212+
rml:template "list{id}" ;
213213
rml:gather ( [ rml:reference "values1.*" ; ] [ rml:reference "values2.*" ; ] ) ;
214214
rml:gatherAs rdf:List ;
215215
rml:strategy rml:cartesianProduct ;
@@ -227,8 +227,8 @@ But again, these lists must be concatenated since they share the same head node
227227
Therefore, the processor must now generate the following output:
228228

229229
<pre class="ex-output">
230-
:a ex:with :list/a .
231-
:list/a rdf:first "1" ; rdf:rest ("a" "1" "b" "5" "e" "6" "e") .
232-
:b ex:with :list/b .
233-
:list/b rdf:first "3" ; rdf:rest ("c" "3" "d" "4" "c" "4" "d") .
230+
:a ex:with :lista .
231+
:lista rdf:first "1" ; rdf:rest ("a" "1" "b" "5" "e" "6" "e") .
232+
:b ex:with :listb .
233+
:listb rdf:first "3" ; rdf:rest ("c" "3" "d" "4" "c" "4" "d") .
234234
</pre>

spec/section/examples.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ In other words, when the following predicate object map is used:
4646
rml:predicateObjectMap [
4747
rml:predicate ex:with ;
4848
rml:objectMap [
49-
rml:template "list/{id}" ;
49+
rml:template "list{id}" ;
5050
rml:allowEmptyListAndContainer true ;
5151
rml:gather ( [ rml:reference "values.*" ; ] ) ;
5252
rml:gatherAs rdf:List ;
@@ -58,12 +58,12 @@ then the document with `"id": "d"` entails an empty list, that is a list whose h
5858
We expect the following output where
5959

6060
<pre class="ex-output">
61-
:a ex:with :list/a .
62-
:list/a rdf:first "1" ; rdf:rest ("2" "3") .
63-
:b ex:with :list/b .
64-
:list/b rdf:first "4" ; rdf:rest ("5" "6") .
65-
:c ex:with :list/c .
66-
:list/c rdf:first "7" ; rdf:rest ("8" "9") .
61+
:a ex:with :lista .
62+
:lista rdf:first "1" ; rdf:rest ("2" "3") .
63+
:b ex:with :listb .
64+
:listb rdf:first "4" ; rdf:rest ("5" "6") .
65+
:c ex:with :listc .
66+
:listc rdf:first "7" ; rdf:rest ("8" "9") .
6767
:d ex:with () .
6868
</pre>
6969

@@ -94,7 +94,7 @@ The following mapping will relate instances of authors to names. The names of au
9494
<pre class="ex-mapping">
9595
<#AuthorTM>
9696
rml:logicalTable [ rml:tableName "AUTHOR" ; ] ;
97-
rml:subjectMap [ rml:template "/person/{ID}" ; ] ;
97+
rml:subjectMap [ rml:template "/person{ID}" ; ] ;
9898
rml:predicateObjectMap [
9999
rml:predicate ex:name ;
100100
rml:objectMap [
@@ -111,9 +111,9 @@ The following mapping will relate instances of authors to names. The names of au
111111
In this example we generate, for each row in table `AUTHOR`, an blank node of type `rdf:Bag`. Each such bag "gathers" values from different term maps. The execution of this mapping will produce the following result:
112112

113113
<pre class="ex-output">
114-
:person/1 ex:name [ a rdf:Bag; rdf:_1 "Mary"; rdf:_2 "Shelley" ] .
115-
:person/2 ex:name [ a rdf:Bag; rdf:_1 "Sir"; rdf:_2 "Terry"; rdf:_3 "Pratchett" ] .
116-
:person/3 ex:name [ a rdf:Bag; rdf:_1 "Stephen"; rdf:_2 "Baxter" ] .
114+
:person1 ex:name [ a rdf:Bag; rdf:_1 "Mary"; rdf:_2 "Shelley" ] .
115+
:person2 ex:name [ a rdf:Bag; rdf:_1 "Sir"; rdf:_2 "Terry"; rdf:_3 "Pratchett" ] .
116+
:person3 ex:name [ a rdf:Bag; rdf:_1 "Stephen"; rdf:_2 "Baxter" ] .
117117
</pre>
118118

119119
While not shown in this example, different term maps allow to collect terms of different types: resources, literals, typed or language-tagged literals, etc. The fourth record in the table did not generate a bag, since each term map in the gather map did not yield a value.
@@ -127,7 +127,7 @@ Continuing with the [relational data example](#relationalexample), here we relat
127127
<pre class="ex-mapping">
128128
<#BookTM>
129129
rml:logicalTable [ rml:tableName "BOOK" ; ] ;
130-
rml:subjectMap [ rml:template "/book/{ID}" ; ] ;
130+
rml:subjectMap [ rml:template "/book{ID}" ; ] ;
131131
rml:predicateObjectMap [
132132
rml:predicate ex:writtenBy ;
133133
rml:objectMap [
@@ -147,8 +147,8 @@ Continuing with the [relational data example](#relationalexample), here we relat
147147
Intuitively, we will join each record (or iteration) with data from the parent triples map. The join may yield one or more results, which are then gathered into a list. The execution of this mapping will produce the following RDF:
148148

149149
<pre class="ex-output">
150-
:book/1 ex:writtenby ( :person/1 ) .
151-
:book/2 ex:writtenby ( :person/2 :person/3 ) .
150+
:book1 ex:writtenby ( :person1 ) .
151+
:book2 ex:writtenby ( :person2 :person3 ) .
152152
</pre>
153153

154154
In RML, it is assumed that each term map is multi-valued. That this, each term map may return one or more values. The default behavior is to append the values in the order of the term maps appearing in the gather map.
@@ -161,13 +161,16 @@ Here we exemplify the use of a term map in a subject map. Continuing with the JS
161161
<pre class="ex-mapping">
162162
<#TM> a rml:TriplesMap;
163163
rml:logicalSource [
164-
rml:source "data.json" ;
165-
rml:referenceFormulation ql:JSONPath ;
164+
rml:source [
165+
a rml:RelativePathSource;
166+
rml:root rml:MappingDirectory;
167+
rml:path "data.json"
168+
] ;
166169
rml:iterator "$.*" ;
167170
];
168171

169172
rml:subjectMap [
170-
rml:template "seq/{id}" ;
173+
rml:template "seq{id}" ;
171174
rml:gather ( [ rml:reference "values.*" ; ] ) ;
172175
rml:gatherAs rdf:Seq ;
173176
] ;
@@ -181,12 +184,12 @@ Here we exemplify the use of a term map in a subject map. Continuing with the JS
181184
The expected result is:
182185

183186
<pre class="ex-output">
184-
:seq/a rdf:_1 "1" ; rdf:_2 "2" ; rdf:_3 "3" .
185-
:seq/a prov:wasDerivedFrom &lt;data.json&gt; .
187+
:seqa rdf:_1 "1" ; rdf:_2 "2" ; rdf:_3 "3" .
188+
:seqa prov:wasDerivedFrom &lt;data.json&gt; .
186189

187-
:seq/b rdf:_1 "4" ; rdf:_2 "5" ; rdf:_3 "6" .
188-
:seq/b prov:wasDerivedFrom &lt;data.json&gt; .
190+
:seqb rdf:_1 "4" ; rdf:_2 "5" ; rdf:_3 "6" .
191+
:seqb prov:wasDerivedFrom &lt;data.json&gt; .
189192

190-
:seq/c rdf:_1 "7" ; rdf:_2 "8" ; rdf:_3 "9" .
191-
:seq/c prov:wasDerivedFrom &lt;data.json&gt; .
193+
:seqc rdf:_1 "7" ; rdf:_2 "8" ; rdf:_3 "9" .
194+
:seqc prov:wasDerivedFrom &lt;data.json&gt; .
192195
</pre>

spec/section/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ and only when, they appear in all capitals, as shown here.
1919
### Document conventions {#conventions}
2020
We assume readers have basic familiarity with RDF and RML.
2121

22-
In this document, examples assume
22+
In this document, examples assume `http://example.org/` as the base IRI provided to the RML engine and
2323
the following namespace prefix bindings unless otherwise stated:
2424

2525
| Prefix | Namespace |

spec/section/presentation.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ The associated RML mapping starts as follows:
3333

3434
<pre class="ex-mapping">
3535
@prefix rml: &lt;http://w3id.org/rml/&gt;.
36-
@prefix ql: &lt;http://semweb.mmlab.be/ns/ql#&gt;.
3736
@prefix ex: &lt;http://example.com/ns&gt;.
38-
@base &lt;http://example.com/ns&gt;.
3937

4038
<#TM> a rml:TriplesMap;
4139
rml:logicalSource [
42-
rml:source "data.json" ;
43-
rml:referenceFormulation ql:JSONPath ;
40+
rml:referenceFormulation rml:JSONPath;
41+
rml:source [
42+
a rml:RelativePathSource;
43+
rml:root rml:MappingDirectory;
44+
rml:path "data.json"
45+
] ;
4446
rml:iterator "$.*" ;
4547
];
4648

@@ -93,7 +95,7 @@ The following mapping:
9395
rml:predicateObjectMap [
9496
rml:predicate ex:with ;
9597
rml:objectMap [
96-
rml:template "list/{id}" ;
98+
rml:template "list{id}" ;
9799
rml:gather ( [ rml:reference "values.*" ; ] ) ;
98100
rml:gatherAs rdf:List ;
99101
] ;
@@ -103,9 +105,9 @@ The following mapping:
103105
will yield the following output:
104106

105107
<pre class="ex-output">
106-
:a ex:with :list/a . :list/a rdf:first "1" ; rdf:rest ("2" "3") .
107-
:b ex:with :list/b . :list/b rdf:first "4" ; rdf:rest ("5" "6") .
108-
:c ex:with :list/c . :list/c rdf:first "7" ; rdf:rest ("8" "9") .
108+
:a ex:with :lista . :lista rdf:first "1" ; rdf:rest ("2" "3") .
109+
:b ex:with :listb . :listb rdf:first "4" ; rdf:rest ("5" "6") .
110+
:c ex:with :listc . :listc rdf:first "7" ; rdf:rest ("8" "9") .
109111
</pre>
110112

111-
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`.
113+
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`.

spec/section/vocabulary.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Gather maps are term maps that use [`rml:gather`](#rml-gather) and [`rml:gatherA
1212
* A `rml:GatherMap` MUST have exactly one [`rml:gatherAs`](#rml-gatheras) property.
1313
* A `rml:GatherMap` MAY have zero or exactly one [`rml:strategy`](#rml-strategy) property.
1414

15+
#### `rml:Strategy` {#strategyclass}
16+
17+
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**](#constants) for examples.
1518

1619
### Properties
1720

@@ -55,7 +58,7 @@ When false, the gather map will not generate a collection or container.
5558

5659
Property `rml:allowEmptyListAndContainer` is optional, it takes the value **false** by default.
5760

58-
### Constants
61+
### Constants {#constants}
5962

6063
#### `rml:append`
6164

0 commit comments

Comments
 (0)