semantifyit / RocketRML

https://semantify.it
Creative Commons Attribution Share Alike 4.0 International
25 stars 12 forks source link

SubjectMap generation as object in join conditions #5

Closed dachafra closed 4 years ago

dachafra commented 4 years ago

When there is a join between two TriplesMap (rr:parentTriplesMap does not contain any POM):

mapping-data-join.zip

ThibaultGerrier commented 4 years ago

Hi, thanks for your bug report.

I assume you are using the toRDF:true option for getting n3/ttl output. Inernally we work with JSONLD and then convert it to ttl. It seems to me that something weird/unexpected is happening during the conversion of jsonld to ttl. We use the package jsonld to do this for us.

I used your example mapping and csv files:

Case 0:

2nd Tripplemap with subjectMap rr:template "http://{value}" (with starting http://) In JSON-LD:

[
  {
    "@id": "http://hello"
  },
  {
    "@id": "http://ex.com/1",
    "http://ex.com#example": {
      "@id": "http://hello"
    }
  }
]

In N3/Turtle:

<http://ex.com/1> <http://ex.com#example> <http://hello> .

Everything is fine.

Case 1:

2nd Tripplemap with subjectMap rr:template "{value}" (without starting http://) In JSON-LD:

[
  {
    "@id": "hello"
  },
  {
    "@id": "http://ex.com/1",
    "http://ex.com#example": {
      "@id": "hello"
    }
  }
]

In N3/Turtle:

# no turtle generated

The jsonld package doesn't allow relative iris, so the tripple is ommited (see https://w3c.github.io/json-ld-api/#dfn-well-formed and https://github.com/digitalbazaar/jsonld.js/blob/7cf2f7155f7d9af6b1c60404cbeeb87788694883/lib/toRdf.js#L275).

Case 2:

2nd Tripplemap with subjectMap rml:reference "value" and no predicateObjectMap in first TrippleMap In JSON-LD:

[
  {
    "@id": "_:hello"
  },
  {
    "@id": "http://ex.com/1"
  }
]

In N3/Turtle:

# no turtle generated

The jsonld doesnt contain any tripples (no subject predicate object) so no tripples are generated.

Case 3:

2nd Tripplemap with subjectMap rml:reference "value" and a predicateObjectMap in first TrippleMap In JSON-LD:

[
  {
    "@id": "_:hello"
  },
  {
    "@id": "http://ex.com/1",
    "http://ex.com#example": {
      "@id": "_:hello"
    }
  }
]

In N3/Turtle:

<http://ex.com/1> <http://ex.com#example> _:b0 .

The jsonld package makes new blank node ids when transforming to rdf. So _:hello becomes :_b0. They are semantically equivalent. (also described in https://w3c.github.io/json-ld-api/#deserialize-json-ld-to-rdf-algorithm)

TL;DR Error/Unexpected happens when converting from JSON-LD to turtle/RDF. I don't think there is anything we can do about that. You could try to output JSON-LD and use another JSONLD->RDF converter.