RMLio/yarrrml-parser

Bug constant-valued graph map

arenas-guerrero-julian opened this issue · 1 comments

prefixes:
  ex: http://example.com/
  schema: https://schema.org/

mappings:
  TestMapping:
    sources: 
      - [test.csv~csv]
    graph: ex:named_graph # this is the lines that breaks the workflow
    s: ex:$(id)
    po:
      - [schema:name, $(name)]
      - [schema:type, $(type)]

produces

@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix fnml: <http://semweb.mmlab.be/ns/fnml#>.
@prefix fno: <https://w3id.org/function/ontology#>.
@prefix d2rq: <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#>.
@prefix void: <http://rdfs.org/ns/void#>.
@prefix dc: <http://purl.org/dc/terms/>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
@prefix : <http://mapping.example.com/>.
@prefix ex: <http://example.com/>.
@prefix schema: <https://schema.org/>.

:rules_000 a void:Dataset;
    void:exampleResource :map_TestMapping_000.
:map_TestMapping_000 rml:logicalSource :source_000.
:source_000 a rml:LogicalSource;
    rml:source "test.csv";
    rml:referenceFormulation ql:CSV.
:map_TestMapping_000 a rr:TriplesMap;
    rdfs:label "TestMapping".
:s_000 a rr:SubjectMap.
:map_TestMapping_000 rr:subjectMap :s_000.
:s_000 rr:template "http://example.com/{id}";
    rr:graphMap :gm_000.
:gm_000 a rr:GraphMap;
    rr:constant "http://example.com/named_graph".
:pom_000 a rr:PredicateObjectMap.
:map_TestMapping_000 rr:predicateObjectMap :pom_000.
:pm_000 a rr:PredicateMap.
:pom_000 rr:predicateMap :pm_000.
:pm_000 rr:constant schema:name.
:pom_000 rr:objectMap :om_000.
:om_000 a rr:ObjectMap;
    rml:reference "name";
    rr:termType rr:Literal.
:pom_001 a rr:PredicateObjectMap.
:map_TestMapping_000 rr:predicateObjectMap :pom_001.
:pm_001 a rr:PredicateMap.
:pom_001 rr:predicateMap :pm_001.
:pm_001 rr:constant schema:type.
:pom_001 rr:objectMap :om_001.
:om_001 a rr:ObjectMap;
    rml:reference "type";
    rr:termType rr:Literal.

which is wrong since the line:

rr:constant "http://example.com/named_graph".

is not correct and it should be

rr:constant <http://example.com/named_graph>.

As specified by the R2RML specification:

Constant-valued term maps are not considered as having a term type, and specifying rr:termType on these term maps has no effect. The type of the generated RDF term is determined directly by the value of rr:constant: If it is an IRI, then an IRI will be generated; if it is a literal, a literal will be generated.

This issue comes from this issue

👍 ... I was just running into java.lang.ClassCastException: org.apache.commons.rdf.rdf4j.impl.LiteralImpl cannot be cast to org.apache.commons.rdf.api.IRI trying to execute the generated mapping including a graph rr:constant with ontop. resulting from the above described problem.