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

multiple classes with rr:class doesn't work #141

Closed Yocote0111 closed 2 years ago

Yocote0111 commented 2 years ago
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
@base <http://example#>.

<#PersonMapping> a rr:TripleMap;
    rml:logicalSource [
        rml:source "./resources/data/json/example.json";
        rml:referenceFormulation ql:JSONPath;
        rml:iterator "$.persons[*]";
    ];
    rr:subjectMap [
        rr:template "http://example/{id}";
        rr:termType rr:IRI;
        rr:class <#Person>, <#Thing>;  # mutiple classes with rr:class
    ];
    .

and

{
    "persons": [
        {
            "id": 1
        }
    ]
}

expects

<http://example/1> a <#Person>, <#Thing>

but it returns an error as below

TypeError: Cannot read property 'predicateObjectMap' of undefined ..
Yocote0111 commented 2 years ago

Instead of rr:class, it works with rr:predicateObjectMap [ rr:predicate rdf:type .. ]

<#PersonMapping> a rr:TripleMap;
    # ..
    rr:predicateObjectMap [
        rr:predicate rdf:type ;
        rr:termType rr:IRI;
        rr:objectMap [
            rr:constant ex:Person, ex:Thing; # multiple classes
        ]
    ]

When I try with the following,

<#PersonMapping> a rr:TripleMap;
    rr:subjectMap [
        rr:template "http://example/{id}";
        rr:termType rr:IRI;
        rr:class ex:Person;
    ];
    rr:predicateObjectMap [
        rr:predicate rdf:type ;
        rr:termType rr:IRI;
        rr:objectMap [
            rr:constant ex:Thing;
        ]
    ]
   .

it returns only ex:Thing and ignore ex:Person

<http://example/1> a ex:Thing.
DylanVanAssche commented 2 years ago

Hi @Yocote0111 !

Sorry for the late reply, but it seems you have a typo in your mapping rules. You need to use a rr:TriplesMap; instead of a rr:TripleMap;.

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
@base <http://example#>.

<#PersonMapping> a rr:TriplesMap;
    rml:logicalSource [
        rml:source "./resources/data/json/example.json";
        rml:referenceFormulation ql:JSONPath;
        rml:iterator "$.persons[*]";
    ];
    rr:subjectMap [
        rr:template "http://example/{id}";
        rr:termType rr:IRI;
        rr:class <#Person>, <#Thing>;  # mutiple classes with rr:class
    ];
    .

I tested these rules on the current RMLMapper and they output what you expect:

[dylan@dell-laptop rmlmapper-java-6]$ java -jar target/rmlmapper-4.13.0-r360-all.jar -m mapping.rml.ttl 
<http://example/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example#Person>.
<http://example/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example#Thing>.

Let us know if you still have any question :)

no-response[bot] commented 2 years ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.