SDM-TIB / SDM-RDFizer

An Efficient RML-Compliant Engine for Knowledge Graph Construction
https://doi.org/10.5281/zenodo.3872103
Apache License 2.0
107 stars 25 forks source link

Support for XPATH expressions #75

Closed jo-fra closed 2 years ago

jo-fra commented 2 years ago

Describe the bug In my RML mapping I am using XPATH expressions in the iterator for the source like e.g.

  ...
  rml:logicalSource [
      rml:source "source.xml";
      rml:referenceFormulation ql:XPath;
      rml:iterator "//SupportedRoleClass[@RefRoleClassPath='AutomationProjectConfigurationRoleClassLib/AutomationProject']"
  ];
  ...

However, with this mapping RDFizer generates no triples at all. With RMLMapper the triples are generated as expected.

Expected behavior Should handle XPATH expressions in rml:iterator definition

Desktop (please complete the following information):

dachafra commented 2 years ago

@jo-fra would be possible to share a piece of the data for doing the proper testing after fixing the bug?

jo-fra commented 2 years ago

@dachafra an example piece of data would be: source.xml

<?xml version="1.0" encoding="utf-8"?>
<InstanceHierarchy Name="APC Sample Instance Hierarchy">
  <InternalElement ID="9088524c-0041-47bd-af69-93d3e745f364" Name="Demo">
    <SupportedRoleClass RefRoleClassPath="AutomationProjectConfigurationRoleClassLib/AutomationProject" />
  </InternalElement>
</InstanceHierarchy>

The mapping file: mapping.ttl

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

@prefix exont: <http://example.com/ontology#> .
@base <http://example.com/instance/> .

<AutomationProjectMapping> a rr:TriplesMap;
  rml:logicalSource [
    rml:source "source.xml";
    rml:referenceFormulation ql:XPath;
    rml:iterator "//SupportedRoleClass[@RefRoleClassPath='AutomationProjectConfigurationRoleClassLib/AutomationProject']"
  ];
  rr:subjectMap [
    rr:template "http://example.com/instance/{../@ID}";
    rr:class exont:AutomationProject;
  ];
  rr:predicateObjectMap [
    rr:predicate rdfs:label;
    rr:objectMap [ 
      rml:reference "../@Name" 
    ]
  ].

The expected output generated by RML mapper: output.ttl

@prefix exont: <http://example.com/ontology#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<http://example.com/instance/9088524c-0041-47bd-af69-93d3e745f364> a exont:AutomationProject;
  rdfs:label "Demo" .
eiglesias34 commented 2 years ago

Hello @jo-fra,

First of all, thank you for your interest in the SDM-RDFizer. I was able to find the problem and fix it. Please test it out. Please note that I updated the code, not the library. After receiving the confirmation that the problem has been solved I will update the library and close the issue.

Thank you again, Enrique Iglesias

eiglesias34 commented 2 years ago

Thank you again for your interest in the SDM-RDFizer. I going to close this issue now. All the changes have been updated in the library.