Skip to content

Commit

Permalink
fix #23
Browse files Browse the repository at this point in the history
  • Loading branch information
pheyvaer committed Sep 26, 2019
1 parent f56acd8 commit 2fd43b2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/abstract-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,13 +587,13 @@ class AbstractGenerator {
return str;
}

str = str.replace('\\:', '@@@@____@@@@');
str = str.replace(/\\:/g, '@@@@____@@@@');


const splits = str.split(':');

if (splits.length === 1) {
return str.replace('@@@@____@@@@', ':');
return str.replace(/@@@@____@@@@/g, ':');
}

if (splits[1].charAt(0) === ' ') {
Expand Down
4 changes: 4 additions & 0 deletions lib/rml-generator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ describe('YARRRML to RML', function () {
it('condition on single object', function (done) {
work('condition-on-single-object/mapping.yarrrml', 'condition-on-single-object/mapping.rml.ttl', done);
});

it('escape character', function (done) {
work('escape-character/mapping.yarrrml', 'escape-character/mapping.rml.ttl', done);
});
});

function work(path1, path2, cb) {
Expand Down
28 changes: 28 additions & 0 deletions test/escape-character/mapping.rml.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix fnml: <http://semweb.mmlab.be/ns/fnml#>.
@prefix fno: <http://w3id.org/function/ontology#>.
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
@prefix : <http://mapping.example.com/>.

:map_person_0 rml:logicalSource :source_0.
:source_0 a rml:LogicalSource;
rml:source "person.csv";
rml:referenceFormulation ql:CSV.
:map_person_0 a rr:TriplesMap;
rdfs:label "person".
:s_0 a rr:SubjectMap.
:map_person_0 rr:subjectMap :s_0.
:s_0 rr:template "{id}::number".
:pom_0 a rr:PredicateObjectMap.
:map_person_0 rr:predicateObjectMap :pom_0.
:pm_0 a rr:PredicateMap.
:pom_0 rr:predicateMap :pm_0.
:pm_0 rr:constant rdf:type.
:pom_0 rr:objectMap :om_0.
:om_0 a rr:ObjectMap;
rr:constant "http://schema.org/Person";
rr:termType rr:IRI.

7 changes: 7 additions & 0 deletions test/escape-character/mapping.yarrrml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mappings:
person:
sources:
- ["person.csv~csv"]
s: $(id)\:\:number
po:
- [a, schema:Person]

0 comments on commit 2fd43b2

Please sign in to comment.