RMLio / yarrrml-parser

A YARRRML parser library and CLI in Javascript
MIT License
41 stars 17 forks source link

Termtype rr:IRI not taken into account when rr:Constant is used #201

Closed marcelomachado closed 11 months ago

marcelomachado commented 11 months ago

Issue type: :bug: Bug

Description

I am using Ontop as a R2RML processor. This issue explain the problem. The termType for a rr:constant is incorrectly set to string instead of IRI when the R2RML mapping file uses a rr:Constant.

Section 7.1 of the R2RML specification (https://www.w3.org/TR/r2rml/#constant) says that "If the constant-valued term map is an object map, then its constant value must be an IRI or literal." So, if you specify rr:termType rr:IRI, then the value of rr:constant should be enclosed in < > to make it an IRI, otherwise, the value in quotation marks is treated as a literal of type xsd:string

Steps

mappings:
  test:
    sources: test_s
    s: ex:some_subject_iri
    po:
      - [ex:my_predicate, ex:my_object_iri~iri]

Environment

NodeJS: v14.19 @rmlio/yarrrml-parser: v1.5.4

Actual behavior: [What actually happens]

The parser to R2RML returns:

...
:om_000 a rr:ObjectMap;
    rr:constant "ex:my_object_iri";
    rr:termType rr:IRI.
...

That is processed like: Output triple:

<ex:some_subject_iri> <ex:my_predicate> "ex:my_object_iri" .

Expected behavior:

The parser to R2RML should return:

...
:om_000 a rr:ObjectMap;
    rr:constant <ex:my_object_iri>;
    rr:termType rr:IRI.
...

That is would be processed like: Output triple:

<ex:some_subject_iri> <ex:my_predicate> <ex:my_object_iri> .
marcelomachado commented 11 months ago

@bjdmeest Could you take a look on this issue and in the related PR?

bjdmeest commented 11 months ago

Merged! Also released under 1.6.0 : https://www.npmjs.com/package/@rmlio/yarrrml-parser