Closed psiotwo closed 2 weeks ago
That's expected, a rr:template
will encode any referenced values if the term type is IRI as defined by the R2RML specification: https://www.w3.org/TR/r2rml/
If you want to just join strings together without using the rr:template processing, you can use the grel:array_join function, you can see an example at https://github.com/RMLio/rmlmapper-java/blob/master/src/test/resources/rml-fno-test-cases/RMLFNOTCF008/mapping.rml.ttl#L80
@bjdmeest thanks for hints! Works well. But I am now getting empty values in case USER_EMAIL is not present (before the triple was not generated at all). Can this be avoided?
You could solve this by composing multiple functions: a combination of contains
and array_join
Thanks @DylanVanAssche. I have come up with this solution, but I guess (and hope very much) there must be a simpler way to do it, right?
,[ rr:predicate vcard:hasEmail ; rr:objectMap [ fnml:functionValue [
rr:predicateObjectMap [ rr:predicate fno:executes; rr:objectMap [ rr:constant idlab:trueCondition ]; ];
rr:predicateObjectMap [ rr:predicate idlab:str; rr:objectMap [ fnml:functionValue [ rr:predicateObjectMap [ rr:predicate fno:executes; rr:objectMap [ rr:constant grel:array_join ]; ];
rr:predicateObjectMap [ rr:predicate grel:p_array_a; rr:objectMap [ rr:constant "mailto:" ]; ];
rr:predicateObjectMap [ rr:predicate grel:p_array_a; rr:objectMap [ rml:reference "USER_EMAIL" ]; ]; ]; ]; ];
rr:predicateObjectMap [ rr:predicate idlab:strBoolean; rr:objectMap [ fnml:functionValue [ rr:predicateObjectMap [ rr:predicate fno:executes; rr:objectMap [ rr:constant grel:boolean_not ]; ];
rr:predicateObjectMap [ rr:predicate grel:bool_b; rr:objectMap [ fnml:functionValue [ rr:predicateObjectMap [ rr:predicate fno:executes; rr:objectMap [ rr:constant idlab:isNull ]; ];
rr:predicateObjectMap [ rr:predicate idlab:str; rr:objectMap [ rml:reference "USER_EMAIL" ]; ]; ]; ]; ]; ]; ]; ]; ];
rr:termType rr:IRI ] ]
there must be a simpler way to do it, right?
This is the solution if you have this in as an IRI because a template encodes the values you pass to it when the term type is an IRI. Otherwise you can never guarantee that the generated RDF has valid IRIs. The only way to circumvent this behavior is by using FnO functions as you did, but you risk to produce invalid IRIs if the parameters contains unsafe IRI characters.
This issue has a solution, I will close it now.
When transforming
napoleon.bonaparte@emperor.fr
through
rr:template "mailto:{USER_EMAIL}" ; rr:termType rr:IRI
I get
@
URL-encoded.<mailto:napoleon.bonaparte%40emperor.fr>