Skip to content

RMLMapper: URI Encoding Issue with Colon (:) in RDF Subjects #243

@Yunheng-Tian

Description

@Yunheng-Tian

Hello,

I am experiencing an issue with RMLMapper where colons (:) in the id field of my JSON data are getting encoded into %3A in the resulting RDF knowledge graph. Below are the details of my input files and mapping.

JSON Input

[
    {
        "id": "HotelRoom:room_101",
        "type": "HotelRoom",
        "hasLocation": {
            "type": "Text",
            "value": "Floor:1",
            "metadata": {}
        },
        "name": {
            "type": "Text",
            "value": "room_101",
            "metadata": {}
        }
    }
]

RML Mapping File

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix brick: <https://brickschema.org/schema/1.4/Brick#> .
@prefix ex: <http://example.com#> .
@prefix rec: <https://w3id.org/rec/core#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

ex:MappingHotelRoom
    a rr:TriplesMap ;
    rml:logicalSource [
        rml:source "entities_example.json" ;
        rml:referenceFormulation ql:JSONPath ;
        rml:iterator "$[?(@.type == 'HotelRoom')]" ;
    ] ;
    rr:subjectMap [
        rr:template "http://example.com/hotel/{id}" ;
        rr:class rec:Room ;
    ] ;
    rr:predicateObjectMap [
        rr:predicate brick:hasLocation ;
        rr:objectMap [
            rml:reference "hasLocation.value" ;
        ] ;
    ] ;
    rr:predicateObjectMap [
        rr:predicate rdfs:label ;
        rr:objectMap [
            rml:reference "name.value" ;
        ] ;
    ] .

Output RDF

<http://example.com/hotel/HotelRoom%3Aroom_101> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/rec/core#Room> .
<http://example.com/hotel/HotelRoom%3Aroom_101> <http://www.w3.org/2000/01/rdf-schema#label> "room_101" .
<http://example.com/hotel/HotelRoom%3Aroom_101> <https://brickschema.org/schema/1.4/Brick#hasLocation> "Floor:1" .

Issue

As seen in the RDF output, the colon (:) in the id field (HotelRoom:room_101) has been URL-encoded as %3A. I would like to prevent this encoding and preserve the original id value in the URI, i.e., I want it to appear as http://example.com/hotel/HotelRoom:room_101 instead of http://example.com/hotel/HotelRoom%3Aroom_101.

Question

Is there any option in RMLMapper to disable or customize the URI encoding for the id values, especially for characters like the colon (:)? Alternatively, is there a specific configuration I should use in the RML mapping file to achieve this?

Any guidance or suggestions would be greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions