Skip to content

Commit a4e8bfa

Browse files
committed
added function to replace spaces in aliases
1 parent d5b2aed commit a4e8bfa

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

app/translator/translatorXchangeURIs.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ function translateAll (json) {
113113
var translated = [];
114114
var SPARQL = "";
115115

116+
json = replaceAliasSpaces(json);
116117

117118
for(var i = 0; i < json.SUBJECTS.length; i++)
118119
{
@@ -321,6 +322,29 @@ function translateDatatypeProperty (itsSubject, eigenschaft, shownValues, transl
321322
}
322323

323324

325+
/*
326+
* little helper function to replace spaces in aliases with an underscore
327+
*/
328+
function replaceAliasSpaces(json) {
329+
330+
var patt = new RegExp("[^A-Za-z0-9_]","g");
331+
332+
333+
for(var i = 0; i < json.SUBJECTS.length; i++) {
334+
335+
json.SUBJECTS[i].alias = json.SUBJECTS[i].alias.replace(patt, "_");
336+
337+
for(var j = 0; j < json.SUBJECTS[i].properties.length; j++) {
338+
339+
json.SUBJECTS[i].properties[j].alias = json.SUBJECTS[i].properties[j].alias.replace(patt, "_");
340+
}
341+
}
342+
343+
return json;
344+
}
345+
346+
347+
324348
/*
325349
* little helper function to check, if an object obj is present in an array arr
326350
*/

0 commit comments

Comments
 (0)