RMLio / yarrrml-parser

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

yarrrml-parser generates faulty mapping when using xpath functions #174

Closed johndoe888 closed 2 years ago

johndoe888 commented 2 years ago

When parsing

prefixes:
  test: http://www.test.test/

mappings:
  Project:
    sources:
      - [test.xml~xpath, "/"]
    s: test:$(lower-case(test))
    po:
      - [a, test:Test]

with the yarrrml-parser version 1.3.5 I get

@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 test: <http://www.test.test/>.

:rules_000 a void:Dataset;
    void:exampleResource :map_Project_000.
:map_Project_000 rml:logicalSource :source_000.
:source_000 a rml:LogicalSource;
    rml:source "test.xml";
    rml:iterator "/";
    rml:referenceFormulation ql:XPath.
:map_Project_000 a rr:TriplesMap;
    rdfs:label "Project".
:s_000 a rr:SubjectMap.
:map_Project_000 rr:subjectMap :s_000.
:s_000 rr:template "http://www.test.test/{lower-case(test})".
:pom_000 a rr:PredicateObjectMap.
:map_Project_000 rr:predicateObjectMap :pom_000.
:pm_000 a rr:PredicateMap.
:pom_000 rr:predicateMap :pm_000.
:pm_000 rr:constant rdf:type.
:pom_000 rr:objectMap :om_000.
:om_000 a rr:ObjectMap;
    rr:constant "http://www.test.test/Test";
    rr:termType rr:IRI.

The brackets at the end of the line with "{lower-case(test})" are swapped ("})" instead of ")}").

kgutwin commented 2 years ago

This looks to be a duplicate of #164. The suggested fix is to add a backslash to escape the closing parenthesis:

    s: test:$(lower-case(test\))
johndoe888 commented 2 years ago

Okay. Closing this.