RMLio / yarrrml-parser

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

Predicate cannot be referenced from data #186

Open Melchyore opened 1 year ago

Melchyore commented 1 year ago

Issue type: :bug: Bug

Description

Hi, i want to reference a predicate from the data, but it causes the following error: Cannot read properties of undefined (reading '@id'). I think the predicate needs to be explicitly set but there isn't a way to reference it from the data?

Steps

Yarrrml (not working version)

prefixes:
    odrl: http://www.w3.org/ns/odrl/2/
    xsd: http://www.w3.org/2001/XMLSchema#
    rdfs: http://www.w3.org/2000/01/rdf-schema#
    rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#

mappings:
  policy:
    sources:
      - [input~csv]
    s: $(uid)
    po:
      - [a, $(type)~iri]
      - [$(rule), ex:test~iri]

Yarrrml (working version)

prefixes:
    odrl: http://www.w3.org/ns/odrl/2/
    xsd: http://www.w3.org/2001/XMLSchema#
    rdfs: http://www.w3.org/2000/01/rdf-schema#
    rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#

mappings:
  policy:
    sources:
      - [input~csv]
    s: $(uid)
    po:
      - [a, $(type)~iri]
      - [odrl:permission, ex:test~iri]

Data

type,uid,rule
http://www.w3.org/ns/odrl/2/Agreement,https://example.com/agreement_01,http://www.w3.org/ns/odrl/2/permission

Environment

Windows 10 Latest version of this package

Thank you!

bjdmeest commented 1 year ago

Hmmm, weird, when trying it on Matey (yarrrml-parser v1.3.3), your example works. I don't see a reason why v1.4.0 would give an error, but we'll have a look. In the meantime, could you maybe check on your side whether v1.3.3 does work for you? If so, we found a new test case! :D

Melchyore commented 1 year ago

I tried with v1.3.3 and had the same problem. I'm using this lib to create RML rules that are then used by RocketRML to generate RDF. The problem comes from RocketRML's lib and I've already opened the same issue in their repo 2 weeks ago then after some investigation, I tought that the bug is caused by yarrrml-parser (yesterday), but I was wrong! I apologize for the inconvenience. This is the exact issue: https://github.com/comake/rmlmapper-js/issues/6#issuecomment-1419973923

Do you know any other alternatives (in JS/TS, without using any JAR) to generate RDF from YARRRML templates (that support referenced predicates values), please?

bjdmeest commented 1 year ago

I don't know about any other alternatives except for RocketRML and RMLMapper-JS, but you could ask at https://github.com/kg-construct/rml-questions/discussions to ask the wider community! :)