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
151 stars 61 forks source link

Serialization format http://www.w3.org/ns/formats/TriG not implemented! #225

Closed alexander-mart closed 1 month ago

alexander-mart commented 11 months ago

Error: Serialization format http://www.w3.org/ns/formats/TriG not implemented!

yarrrml-parser -i "./input.yarrrml.yaml" -o "./output.rml.ttl"
java -jar ./rmlmapper-6.2.2-r371-all.jar -m "./output.rml.ttl"

data.json:

{
 "characters": [
   {
     "id": "0",
     "firstname": "Ash",
     "lastname": "Ketchum",
     "hair": "black"
   },
   {
     "id": "1",
     "firstname": "Misty",
     "hair": "orange"
   }
 ]
}

input.yarrrml.yaml:

prefixes:
  ex: http://example.com/

targets:
  person-target:
    access: ./output.rdf.trig
    type: void
    serialization: trig

mappings:
  person:
    sources:
      - ['data.json~jsonpath', '$.characters[*]']
    s:
      - value: 'ex:$(firstname)'
        targets: person-target
    po:
      - [a, foaf:Person]
      - [ex:name, $(firstname)]
      - [ex:hair, ex:$(hair)]

output.rml.ttl:

@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix fnml: <http://semweb.mmlab.be/ns/fnml#>.
@prefix fno: <https://w3id.org/function/ontology#>.
@prefix d2rq: <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#>.
@prefix void: <http://rdfs.org/ns/void#>.
@prefix dc: <http://purl.org/dc/terms/>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
@prefix : <http://mapping.example.com/>.
@prefix ex: <http://example.com/>.
@prefix rmlt: <http://semweb.mmlab.be/ns/rml-target#>.
@prefix formats: <http://www.w3.org/ns/formats/>.

:rules_000 a void:Dataset.
:target_000 a rmlt:LogicalTarget;
    rdfs:label "person-target";
    rmlt:serialization formats:TriG;
    rmlt:target :void_000.
:void_000 a void:Dataset;
    void:dataDump <file://./output.rdf.trig>.
:rules_000 void:exampleResource :map_person_000.
:map_person_000 rml:logicalSource :source_000.
:source_000 a rml:LogicalSource;
    rml:source "data.json";
    rml:iterator "$.characters[*]";
    rml:referenceFormulation ql:JSONPath.
:map_person_000 a rr:TriplesMap;
    rdfs:label "person".
:s_000 a rr:SubjectMap.
:map_person_000 rr:subjectMap :s_000.
:s_000 rr:template "http://example.com/{firstname}";
    rml:logicalTarget :target_000.
:pom_000 a rr:PredicateObjectMap.
:map_person_000 rr:predicateObjectMap :pom_000.
:pm_000 a rr:PredicateMap.
:pom_000 rr:predicateMap :pm_000.
:pm_000 rr:constant rdf:type.
:pom_000 rr:objectMap :om_000.
:om_000 a rr:ObjectMap;
    rr:constant foaf:Person;
    rr:termType rr:IRI.
:pom_001 a rr:PredicateObjectMap.
:map_person_000 rr:predicateObjectMap :pom_001.
:pm_001 a rr:PredicateMap.
:pom_001 rr:predicateMap :pm_001.
:pm_001 rr:constant ex:name.
:pom_001 rr:objectMap :om_001.
:om_001 a rr:ObjectMap;
    rml:reference "firstname";
    rr:termType rr:Literal.
:pom_002 a rr:PredicateObjectMap.
:map_person_000 rr:predicateObjectMap :pom_002.
:pm_002 a rr:PredicateMap.
:pom_002 rr:predicateMap :pm_002.
:pm_002 rr:constant ex:hair.
:pom_002 rr:objectMap :om_002.
:om_002 a rr:ObjectMap;
    rr:template "http://example.com/{hair}";
    rr:termType rr:Literal.
DylanVanAssche commented 6 months ago

TriG is not implemented yet for Logical Targets, could be a good feature :) If you want to dig into this yourself, feel free to make patches and send a pull request. Thanks!

DylanVanAssche commented 4 months ago

On the development branch, I added support for TriG in Logical Targets. Let me know if this works for you :)

Commit: fd59a3e1ae51a375f7734d7474d31c40367097d4

DylanVanAssche commented 2 weeks ago

Fixed in v7.1.0