RMLio / rmlmapper-java

The RMLMapper executes RML rules to generate high quality Linked Data from multiple originally (semi-)structured data sources
http://rml.io
MIT License
157 stars 61 forks source link

Please provide working example #46

Closed aljoshakoecher closed 4 years ago

aljoshakoecher commented 4 years ago

Hi everyone,

it's currently really hard to get into RML. I tried with the examples found on https://rml.io/docs/rml/examples/ and on https://rml.io/specs/rml/. I also checked some issues where people asked for complete examles - unfortunately all without luck. It would be much appreciated if you could just provide a simple but working example.

Here is what I have right now. The .xml source I want to map looks like this: input.xml

<?xml version = "1.0"?>
<Events>
 <Exhibition id="398">
 <Venue>STAM</Venue>
  <Location>
   <lat>51.076891</lat>
   <long>3.717222</long>
  </Location>
 </Exhibition>
 <Exhibition id="428">
 <Venue>ABC</Venue>
  <Location>
   <lat>55.076891</lat>
   <long>35.717222</long>
  </Location>
 </Exhibition>
</Events>

My mapping defintions look like this: mapping.ttl

@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
@prefix crml:   <http://semweb.mmlab.be/ns/crml#>.
@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
@prefix ex: <http://ex.com/>.
@base <http://example.com/base>.

<#EventMapping>
 a rr:TriplesMap;
  rml:logicalSource [
    rml:source "./input.xml";
    rml:referenceFormulation ql:XPath;
    rml:iterator "/Events/Exhibition" ];

  rr:subjectMap [
    rr:template "http://ex.com/{@id}";
  ];

  rr:predicateObjectMap [
    rr:predicate ex:hasName;

    rr:objectMap [
        rml:reference "eventName";
        ]
  ].

I use the mapper like so: java -jar .\rmlmapper.jar -m ".\mapping.ttl" -o ".\output.ttl"

The mapper runs without errors. The output file is created but is empty. Any ideas why? Btw I'm using your latest release. Appreciate your help!

pheyvaer commented 4 years ago

Hi @aljoshakoecher

Thanks for you issue. No RDF is generated because there is no eventName tag in the Exhibition. I added it below

<?xml version = "1.0"?>
<Events>
 <Exhibition id="398">
 <eventName>Test</eventName>
 <Venue>STAM</Venue>
  <Location>
   <lat>51.076891</lat>
   <long>3.717222</long>
  </Location>
 </Exhibition>
 <Exhibition id="428">
 <eventName>Test 2</eventName>
 <Venue>ABC</Venue>
  <Location>
   <lat>55.076891</lat>
   <long>35.717222</long>
  </Location>
 </Exhibition>
</Events>

and then your RML rules work. Could you have a try on your side too?

aljoshakoecher commented 4 years ago

Thanks for your blazingly fast response. Sorry that was a stupid mistake on my side. Of course it couldn't work with missing <eventName>. Now it works. What I tried before was an even simpler mapping definition:

@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
@prefix crml:   <http://semweb.mmlab.be/ns/crml#>.
@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
@prefix ex: <http://ex.com/>.
@base <http://example.com/base>.

<#EventMapping>
 a rr:TriplesMap;
  rml:logicalSource [
    rml:source "./Beispiele/input.xml";
    rml:referenceFormulation ql:XPath;
    rml:iterator "/Events/Exhibition" ];

  rr:subjectMap [
    rr:template "http://ex.com/{@id}";
    rr:Class ex:SomeClass
  ].

I expected this rule to create just the individuals with an rdf:type of ex:SomeClass. Unfortunately, nothing gets created. Could you give me a hint why that is the case?

aljoshakoecher commented 4 years ago

Forget it, another simple mistake. It has to be rr:class instead of rr:Class 🤦‍♂

pheyvaer commented 4 years ago

Hi @aljoshakoecher

Based on your feedback we added a tutorial to our website https://rml.io/docs/rml/tutorials/xml/ :smiley:

aljoshakoecher commented 4 years ago

Hey @pheyvaer,

thanks a lot. I think that's very valuable to get a quick start! Without this tutorial, it was a bit tricky to get a working example and I had to go through a lot of trial and error to create a first mapping.

pheyvaer commented 4 years ago

You're welcome. If there is anything else just let us know! :smiley: