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

inconsistent IRI behavior #86

Open Sealdolphin opened 3 years ago

Sealdolphin commented 3 years ago

Hello,

I recently noticed, that IRI-s behave differently if I use them in an objectMap as if I use them in a predicateMap. I am trying to create Linked data from a structured JSON file in a way, that I use the JSON to sort of build the predicate IRI-s as well. When I use this method in a predicateMap this works fine, however if I use it in an objectMap it calls out, that the IRI I want to build is not a valid IRI.

My example json:

{
  "triple" : {
    "subject" : {
      "address" : "http://subject.com",
      "name" : "mySubject"
    },
    "predicate" : {
      "address" : "http://predicate.com",
      "name" : "type"
    },
    "object" : {
      "address" : "http://object.com",
      "name" : "myType"
    }
  }
}

My mapping

@base <http://example.com> .
@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .

<#rootMap> a rr:TriplesMap;

    rml:logicalSource [
        rml:source "..\transformed\example.json";
        rml:referenceFormulation ql:JSONPath;
        rml:iterator "$.triple";
    ];

    rr:subjectMap [ 
        rr:template "/{.subject.name}";
    ];

    rr:predicateObjectMap [
        rr:predicateMap [
            rr:template "{.predicate.address}#{.predicate.name}";
        ];
        rr:objectMap [
            rr:termType rr:Literal;
            rr:template "<{.object.address}#{.object.name}>";
        ];
    ].

The output:

<http://example.com/mySubject> <http://predicate.com#type> "<http://object.com#myType>" .

Notice the object is in quotation marks (because I marked the termType Literal I guess), however the predicate work as I expected.

If I don't mark the termType explicitly, or I mark as rr:IRI the RMLMapper says that:

Not a valid (absolute) IRI: http%3A%2F%2Fobject.com#myType

I belive this is because he tries to convert my IRI to an IRI-safe string and therefore it does not count. I want to create the triple above without the quotes. Is it possible?

justin2004 commented 3 years ago

@Sealdolphin

i don't think you can do this

rr:template "/{.subject.name}";

try

rr:template "http://something.com/{.subject.name}";

EDIT: maybe i am wrong. checking now...

justin2004 commented 3 years ago

nevermind my note above. i see what you are trying to get now.

If the term type is rr:IRI, then replace the pair of curly braces with an IRI-safe version of value; otherwise, replace the pair of curly braces with value.

that rule in the spec seems to be preventing you from doing it. interesting case though...

justin2004 commented 3 years ago

@Sealdolphin did you see this https://stackoverflow.com/questions/65900785/is-there-any-way-in-rml-r2rml-to-take-a-value-as-an-iri/66060476#66060476

Sealdolphin commented 3 years ago

Wow, I certainly check that out. Nice catch @justin2004 ! However, I think RML should work without this.

tduval-unifylogic commented 1 year ago

Greetings!

@justin2004 @DylanVanAssche

Has there been any progress on this? We are generating a ton of rdfs:range predicates whose objects need to be uris from the w3c xsd datatypes standard, e.g., xsd:string, xsd:boolean....etc...

RMLMapper version: rmlmapper-6.0.0-r363-all

Output is...

Output we need...

Preferred output with declared prefix in mapping file...

I have tried all suggestions and nothing seems to get the desired result.

Please advise. Thanks!