Skip to content

Possibility to treat the returned value of a custom function as IRI and not as string #48

@FabianCretton

Description

@FabianCretton

Hi,
Thank you for that nice tool.

I am trying out the custom function feature as described in the README.
My current problem is that even if the function returns a url, as:

    functions: {
            'http://example.com/grel.ttl#getSexUrl': function (data) {
			if (data[0] == 1) {
				return `http://publications.europa.eu/resource/authority/human-sex/MALE`;
			} else {
				return `http://publications.europa.eu/resource/authority/human-sex/FEMALE`;
			}
                }
            },

But the generated RDF is:
<http://example.com/9791234567890> <http://data.europa.eu/m8g/sex> "http://publications.europa.eu/resource/authority/human-sex/FEMALE" .

What I want is a URL (and not a string) as object, for instance:
<http://example.com/9791234567890> <http://data.europa.eu/m8g/sex> <http://publications.europa.eu/resource/authority/human-sex/FEMALE> .

I am using the mapping as proposed in the README,

<#FunctionMap>
	fnml:functionValue [
		rml:logicalSource <#LOGICALSOURCE> ;
		rr:predicateObjectMap [
			rr:predicate fno:executes ;
			rr:objectMap [ 
				rr:constant grel:getSexUrl;
                                rr:termType rr:IRI
				]
		 ] ;
		rr:predicateObjectMap [
			rr:predicate grel:inputString ;
			rr:objectMap [ rml:reference "sex" ]
		 ];
	 ] .

I did also add a rr:termType rr:IR in the rr:objectMap (see here above), but same result.

I am no RML expert, and tried out quite a few things with no good result (even worse with the "help" of chatGPT)
Thank you for any pointer.
Fabian

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions