Open tduval-unifylogic opened 2 years ago
When you can change your input to XML, you can use XPath (which I think is very powerful) with RML version 6.
Here is the XML data:
<?xml version="1.0" encoding="UTF-8"?>
<A1 name="H# M# T.-_ M."/>
Here is the mapping:
@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
@prefix ex: <http://example.com/ns#>.
@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
@base <http://example.com/data/>.
<#A1> a rr:TriplesMap;
rml:logicalSource [
rml:source "./test.xml" ;
rml:iterator "/A1";
rml:referenceFormulation ql:XPath;
];
rr:subjectMap [
rr:template "http://example.com/data/{replace(@name, '[^a-zA-Z0-9_.]+', '-')}";
rr:class ex:A1
].
'+' is problematic as it would be encoded. You might have to post process that. I have not found a way around that.
I'm hoping you can provide me some guidance on using a regular expression as a parameter to a function to replace (more like substitute) the value of a literal object using a regular expression.
Particularly "Name" in:
I need to slug the "Name" value so the string is URI safe according to our standards. e.g., if value of Name was "Hey Mister Tally M#n" we need the string to be slug'd to "Hey-Mister-Tally-M-n" (we have the regexp that does the conversion properly)
To start, I updated the Name value in student.csv file to "Hey Mister Tally M#n" and attempted to use
grel:string_replace
the object of foaf:Name with no success. Any help is greatly appreciated. It would also appreciate guidance on how would I apply the function to {Name} in rr:subjectMap [ rr:template ]The result I get from the rule/function:
Here is what I have for a mapping.ttl: