Skip to content

Commit

Permalink
spec: replace rml:query with rml:iterator
Browse files Browse the repository at this point in the history
Fixes #28
  • Loading branch information
DylanVanAssche committed Sep 18, 2023
1 parent 20365d9 commit f4d3a0a
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 93 deletions.
24 changes: 5 additions & 19 deletions shapes/io.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
""" ;
sh:message """
RML Logical Source requires one rml:source and depending on the source
type: one rml:query, one rml:referenceFormulation and/or
one rml:iterator.
type: one rml:referenceFormulation and/or one rml:iterator.
""" ;
sh:name "RML Logical Source" ;
sh:property [ sh:description """
Expand Down Expand Up @@ -118,8 +117,8 @@
such descriptions.
""" ;
sh:message """
RML Source accepts one or multiple rml:null, one rml:query,
one rml:compression, and one rml:encoding. All of them are optional.
RML Source accepts one or multiple rml:null, one rml:compression,
and one rml:encoding. All of them are optional.
""" ;
sh:name "RML Source" ;
sh:property [ sh:datatype xsd:string ;
Expand All @@ -134,26 +133,13 @@
sh:name "rml:null" ;
sh:nodeKind sh:Literal ;
sh:path rml:null ],
[ sh:datatype xsd:string ;
sh:description """
rml:query specifies the query to execute on a data source if that data
source suports it.
""" ;
sh:maxCount 1 ;
sh:message """
rml:query must be provided as a string Literal.
""" ;
sh:minCount 0 ;
sh:name "rml:query" ;
sh:nodeKind sh:Literal ;
sh:path rml:query ],
[ sh:description """
rml:compression specifies the compression algorithm to use when
accessing the data source. By default, no compression is applied.
""" ;
sh:maxCount 1 ;
sh:message """
rml:query must be provided as an IRI.
rml:compression must be provided as an IRI.
""" ;
sh:minCount 0 ;
sh:name "rml:compression" ;
Expand Down Expand Up @@ -203,7 +189,7 @@
""" ;
sh:maxCount 1 ;
sh:message """
rml:query must be provided as an IRI.
rml:compression must be provided as an IRI.
""" ;
sh:minCount 0 ;
sh:name "rml:compression" ;
Expand Down
3 changes: 1 addition & 2 deletions shapes/logical_source.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
""" ;
sh:message """
RML Logical Source requires one rml:source and depending on the source
type: one rml:query, one rml:referenceFormulation and/or
one rml:iterator.
type: one rml:referenceFormulation and/or one rml:iterator.
""" ;

# rml:source
Expand Down
23 changes: 3 additions & 20 deletions shapes/source.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
such descriptions.
""" ;
sh:message """
RML Source accepts one or multiple rml:null, one rml:query,
one rml:compression, and one rml:encoding. All of them are optional.
RML Source accepts one or multiple rml:null, one rml:compression,
and one rml:encoding. All of them are optional.
""" ;

# rml:null
Expand All @@ -40,23 +40,6 @@
sh:datatype xsd:string ;
] ;

# rml:query
sh:property [
sh:path rml:query ;
sh:name "rml:query" ;
sh:description """
rml:query specifies the query to execute on a data source if that data
source suports it.
""" ;
sh:message """
rml:query must be provided as a string Literal.
""" ;
sh:minCount 0 ;
sh:maxCount 1 ;
sh:nodeKind sh:Literal;
sh:datatype xsd:string ;
] ;

# rml:compression
sh:property [
sh:path rml:compression ;
Expand All @@ -66,7 +49,7 @@
accessing the data source. By default, no compression is applied.
""" ;
sh:message """
rml:query must be provided as an IRI.
rml:compression must be provided as an IRI.
""" ;
sh:minCount 0 ;
sh:maxCount 1 ;
Expand Down
2 changes: 1 addition & 1 deletion shapes/target.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
accessing the data target. By default, no compression is applied.
""" ;
sh:message """
rml:query must be provided as an IRI.
rml:compression must be provided as an IRI.
""" ;
sh:minCount 0 ;
sh:maxCount 1 ;
Expand Down
11 changes: 6 additions & 5 deletions spec/section/overriding-targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ http://dbpedia.org/resource/Melissa_Rauch,Melissa Rauch
<#SDSourceAccess> a rml:Source, sd:Service;
sd:endpoint <http://dbpedia.org/sparql/>;
sd:supportedLanguage sd:SPARQL11Query;
sd:resultFormat formats:SPARQL_Results_CSV;
.
</pre>

<pre class="ex-mapping">
&lt;#TriplesMap1&gt; a rml:TriplesMap;
rml:logicalSource [ a rml:LogicalSource;
rml:source &lt;#SDSourceAccess&gt;;
rml:query """
rml:referenceFormulation formats:SPARQL_Results_CSV;
rml:iterator """
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
Expand Down Expand Up @@ -71,7 +71,8 @@ http://dbpedia.org/resource/Melissa_Rauch,Melissa Rauch
&lt;#TriplesMap2&gt; a rml:TriplesMap;
rml:logicalSource [ a rml:LogicalSource;
rml:source &lt;#SDSourceAccess&gt;;
rml:query """
rml:referenceFormulation formats:SPARQL_Results_CSV;
rml:iterator """
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
Expand Down Expand Up @@ -177,15 +178,15 @@ http://dbpedia.org/resource/Melissa_Rauch,Melissa Rauch
&lt;#SDSourceAccess&gt; a rml:Source, sd:Service;
sd:endpoint <http://dbpedia.org/sparql/>;
sd:supportedLanguage sd:SPARQL11Query;
sd:resultFormat formats:SPARQL_Results_CSV;
.
</pre>

<pre class="ex-mapping">
&lt;#TriplesMap&gt; a rml:TriplesMap;
rml:logicalSource [ a rml:LogicalSource;
rml:source &lt;#SDSourceAccess&gt;;
rml:query """
rml:referenceFormulation formats:SPARQL_Results_CSV;
rml:iterator """
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
Expand Down
39 changes: 18 additions & 21 deletions spec/section/source-vocabulary.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,22 @@ with default parameters
- `rml:XPathReferenceFormulation`: XML documents with optionally
the definition of XML namespaces used in references.
By default, no namespaces are defined.
- `rml:SQL2008Query`: SQL query for a relational database.
- `rml:SQL2008Table`: Shortcut to select all columns from a SQL table.

`rml:XPathReferenceFormulation` may specify zero or more
`rml:namespace` properties with a `rml:Namespace`.
A `rml:Namespace` contains the following required properties:
- `rml:namespacePrefix`: A Literal with the prefix used for the XML namespace.
- `rml:namespaceURL`: A Literal with the URL identifying the XML namespace.

SPARQL queries iterations can be specified by using the W3C Formats namespace:

- `formats:SPARQL_Results_CSV`: SPARQL results as CSV.
- `formats:SPARQL_Results_TSV`: SPARQL results as TSV.
- `formats:SPARQL_Results_JSON`: SPARQL results as JSON.
- `formats:SPARQL_Results_XML`: SPARQL results as XML.

<pre class="ex-source">
&lt;#XMLNamespace&gt; a rml:LogicalSource;
rml:source [ a rml:Source, dcat:Distribution;
Expand Down Expand Up @@ -122,12 +131,6 @@ However, JSON has a NULL character specified: `null`,
this one is used together with the ones specified through `rml:null`.
- **rml:compression** specifies if the source is compressed
and the used compression algorithm. Defaults to no compression.
- **rml:query** defines which query should be applied on the source
during access. Example: SPARQL query for a SPARQL endpoint or a SQL query
for a relational database. Defaults to an empty string.
This property is a broader version of `rml:sqlQuery`.
A whole table or view of a relational database can be specified
through a `SELECT * FROM {table}` query (`rml:tableName` compatibility).

<pre class="ex-source">
&lt;#JSON&gt; a rml:LogicalSource;
Expand All @@ -146,8 +149,7 @@ through a `SELECT * FROM {table}` query (`rml:tableName` compatibility).
| --------------------------- | -------------------- | ------------------------- |
| `rml:encoding` | `rml:Source` | `rml:Encoding` |
| `rml:null` | `rml:Source` | `Literal` |
| `rml:compression` | `rml:Source` | `rml:Compression` |
| `rml:query` | `rml:Source` | `Literal` |
| `rml:compression` | `rml:Source` | `rml:Compression` |

#### NULL values

Expand All @@ -159,14 +161,6 @@ For example, in relational databases `NULL` is always considered as a NULL
value while also an empty column can be considered as a NULL value by
specifying it through `rml:null` in a Source.

#### Query

Each Source MAY specify a query to apply when accessing the source
with `rml:query`.

This property is under review in
[Issue 28](https://github.com/kg-construct/rml-io/issues/28).

#### Compression formats

Each Source MAY specify the compression with `rml:compression`
Expand Down Expand Up @@ -226,13 +220,15 @@ the `student` table. The database username and password are provided as well.
d2rq:jdbcDriver "com.mysql.jdbc.Driver";
d2rq:username "user";
d2rq:password "password";
rml:query "SELECT * FROM student;";
rml:referenceFormulation rml:SQL2008;
];
rml:iterator "SELECT * FROM student;";
rml:referenceFormulation rml:SQL2008Query;
.
</pre>

Note that there is no `rml:iterator` present because its default is row.
A shortcut is available to select all columns from a table,
such as in the example above, by using the `rml:SQL2008Table`
as `rml:referenceFormulation`.

The following example shows a Source of a
XML file with no compression.
Expand Down Expand Up @@ -262,15 +258,16 @@ The following example is GZip compressed JSON file as Source:

Sources can also describe access to SPARQL endpoints with the
W3C Service Description ontology. SPARQL endpoints need a SPARQL query,
specified by `rml:query`.
to iterate over.

<pre class="ex-source">
&lt;#SPARQLEndpoint&gt; a rml:LogicalSource;
rml:source [ a rml:Source, sd:Service;
sd:endpoint &lt;http://example.com/sparql&gt;;
sd:supportedLanguage sd:SPARQL11Query;
rml:query "CONSTRUCT WHERE { ?s ?p ?o. } LIMIT 100";
];
rml:iterator "CONSTRUCT WHERE { ?s ?p ?o. } LIMIT 100";
rml:referenceFormulation formats:SPARQL_Results_CSV;
.
</pre>

Expand Down
18 changes: 10 additions & 8 deletions test-cases/RMLSTC0003/mapping.ttl
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
@prefix rml: <http://w3id.org/rml/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix void: <http://rdfs.org/ns/void#> .
@prefix formats: <https://www.w3.org/ns/formats/> .
@base <http://example.com/rules/> .

<#VoIDSourceAccess> a rml:Source, void:Dataset;
void:dataDump <file://./Friends.nt>;
rml:query """
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?age WHERE {
?person foaf:name ?name .
?person foaf:age ?age .
}
""";
.

<#TriplesMap> a rml:TriplesMap;
rml:logicalSource [ a rml:LogicalSource;
rml:source <#VoIDSourceAccess>;
rml:iterator """
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?age WHERE {
?person foaf:name ?name .
?person foaf:age ?age .
}
""";
rml:referenceFormulation formats:SPARQL_Results_CSV;
];
rml:subjectMap [ a rml:SubjectMap;
rml:template "http://example.org/{id}";
Expand Down
18 changes: 10 additions & 8 deletions test-cases/RMLSTC0006b/mapping.ttl
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
@prefix rml: <http://w3id.org/rml/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix void: <http://rdfs.org/ns/void#> .
@prefix formats: <https://www.w3.org/ns/formats/> .
@base <http://example.com/rules/> .

<#VoIDSourceAccess> a rml:Source, void:Dataset;
void:dataDump <file://./Friends.nt>;
rml:query """
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?age WHERE {
?person foaf:name ?name .
?person foaf:age ?age .
}
""";
.

<#TriplesMap> a rml:TriplesMap;
rml:logicalSource [ a rml:LogicalSource;
rml:source <#VoIDSourceAccess>;
rml:iterator """
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?age WHERE {
?person foaf:name ?name .
?person foaf:age ?age .
}
""";
rml:referenceFormulation formats:SPARQL_Results_CSV;
];
rml:subjectMap [ a rml:SubjectMap;
rml:template "http://example.org/{id}";
Expand Down
18 changes: 9 additions & 9 deletions test-cases/RMLSTC0006c/mapping.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
<#SDSourceAccess> a rml:Source, sd:Service;
sd:endpoint <http://example.com/sparql/>;
sd:supportedLanguage sd:SPARQL11Query;
sd:resultFormat formats:SPARQL_Results_CSV;
rml:query """
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?age WHERE {
?person foaf:name ?name .
?person foaf:age ?age .
}
""";
.

<#TriplesMap> a rml:TriplesMap;
rml:logicalSource [ a rml:LogicalSource;
rml:source <#SDSourceAccess>;
rml:iterator """
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?age WHERE {
?person foaf:name ?name .
?person foaf:age ?age .
}
""";
rml:referenceFormulation formats:SPARQL_Results_CSV;
];
rml:subjectMap [ a rml:SubjectMap;
rml:template "http://example.org/{id}";
Expand Down

0 comments on commit f4d3a0a

Please sign in to comment.