RMLio / yarrrml-parser

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

Grel "if"function #141

Closed ritamargherita closed 2 years ago

ritamargherita commented 2 years ago

Issue type: :question: Question

I would like to know if it is possible to use a grel function that does:

More specifically, I have for example the following xml files:

XML1 <document> <hello ex:ex="true">

XML2 <document> <hello>world</hello>

I would like to return the triple ex:document ex:hello "world" only when the XML contains something. At the moment if I do a normal mapping with YARRRML such as - [ex:hello, $(hello)] I get the following triples:

for XML1 --> ex:document ex:hello "" for XML2 --> ex:document ex:hello "world"

I would like to create the triple only in the second instance but not in the first one. Is there a function I can use to do that? If yes which one and how could I implement it?

Thanks!

bjdmeest commented 2 years ago

A condition on the subject should work, something like https://github.com/RMLio/yarrrml-parser/blob/development/test/condition-on-mapping-subject-function/mapping.yarrrml , does that help?

ritamargherita commented 2 years ago

Yes that works thanks. Is there an option to add the language tag also? Right now I am trying to add as below, but it doesn't work. Do you have any suggestions?

mappings:
  cbs:
    sources:
      - ['data.xml~xpath', '/Dataontwerpversies/Versie/Dataontwerp']
    s: cbs:$(Id)
    po:
      - predicates: cbs:methodology
        objects:
            - value: $(GebruikteMethodologie)
              datatype: nl~lang
        condition:
          function: idlab-fn:notEqual
          parameters:
            - [grel:valueParameter, $(GebruikteMethodologie)]
            - [grel:valueParameter2, ""]
bjdmeest commented 2 years ago

Check https://rml.io/yarrrml/spec/#languages , it should be language: nl instead of datatype: nl~lang. If that doesn't work, please create a new issue! :D