RMLio / yarrrml-parser

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

Problem with results of function "decide" #111

Closed ritamargherita closed 3 years ago

ritamargherita commented 3 years ago

Issue type: :bug: Bug

Description

I am using the function "idlab-fn:decide". The function works properly, but the result is not exactly what expected.

Steps

xml example:

<?xml version="1.0" encoding="UTF-8"?> <resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4.1/metadata.xsd">

10.17026/dans-zk5-883b info:eu-repo/semantics/restrictedAccess DANS License

YARRRML example:

prefixes: doi: http://doi.org/ opl: http://www.w3id.org/odissei/ns/terms_of_use_representation/ idlab-fn: http://example.com/idlab/function/

mappings: test: sources:

results RDF:

http://doi.org/10.17026%2Fdans-zk5-883b opl:hasAccess "http://www.w3id.org/odissei/ns/terms_of_use_representation/Restricted".

Ideally we would want: http://doi.org/10.17026%2Fdans-zk5-883b opl:hasAccess opl:Restricted.

When producing RDF, YARRRML replace the opl: in the function with the actual prefix, and it considers it as a string

Environment

OS

bjdmeest commented 3 years ago

Hi @ritamargherita,

Matey expands the prefix because the Termtype of an objectMap is Literal by default. If you add type: iri in the object description (see, e.g., example 46 at https://rml.io/yarrrml/spec/#predicates-and-objects), I receive the results you want :)

prefixes:
  doi: http://doi.org/
  opl: http://www.w3id.org/odissei/ns/terms_of_use_representation/
  idlab-fn: http://example.com/idlab/function/

mappings:
  test:
    sources:
       - ['example.xml~xpath', 'resource']
    s: doi:$(identifier)
    po:
      - predicates: opl:hasAccess
        objects:
          - function: idlab-fn:decide
            parameters:
              - [idlab-fn:str, "$(rightsList/rights[1])"]
              - [idlab-fn:expectedStr, "info:eu-repo/semantics/restrictedAccess"]
              - [idlab-fn:result, opl:Restricted]
            type: iri

(the last line is important ;) )

Let me know if this solves your problem, if so, feel free to close this issue! :)

ritamargherita commented 3 years ago

Hi @bjdmeest, thank you so much for your help. This actually solves the issue, so many thanks for your quick and effective response!

ritamargherita commented 3 years ago

Hi Ben,

I do have another question about YARRML, and I think there is already an issue on the Github (https://github.com/RMLio/yarrrml-parser/issues/100).

I would like to create something like this in ttl:

ex:subject ex:predicate [ ex:predicate2 ex:object ] .

As I think this issue has been raised already, I wanted to ask you if you can direct me to where is was resolved? Or maybe is a functionality that YARRRML doesn’t support yet?

Best, Margherita

On 24 Mar 2021, at 10:09, Ben De Meester @.**@.>> wrote:

Hi @ritamargheritahttps://github.com/ritamargherita,

Matey expands the prefix because the Termtype of an objectMap is Literal by default. If you add type: iri in the object description, I receive the results you want :)

prefixes: doi: http://doi.org/ opl: http://www.w3id.org/odissei/ns/terms_of_use_representation/ idlab-fn: http://example.com/idlab/function/

mappings: test: sources:

(the last line is important ;) )

Let me know if this solves your problem, if so, feel free to close this issue! :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/RMLio/yarrrml-parser/issues/111#issuecomment-805629677, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASZY3PO67EPQ2EDS6CGE5KTTFGT3ZANCNFSM4ZVIMNIA.