Skip to content

Commit

Permalink
added function to replace spaces in aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
redfarg committed Mar 31, 2014
1 parent d5b2aed commit a4e8bfa
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/translator/translatorXchangeURIs.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function translateAll (json) {
var translated = [];
var SPARQL = "";

json = replaceAliasSpaces(json);

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


/*
* little helper function to replace spaces in aliases with an underscore
*/
function replaceAliasSpaces(json) {

var patt = new RegExp("[^A-Za-z0-9_]","g");


for(var i = 0; i < json.SUBJECTS.length; i++) {

json.SUBJECTS[i].alias = json.SUBJECTS[i].alias.replace(patt, "_");

for(var j = 0; j < json.SUBJECTS[i].properties.length; j++) {

json.SUBJECTS[i].properties[j].alias = json.SUBJECTS[i].properties[j].alias.replace(patt, "_");
}
}

return json;
}



/*
* little helper function to check, if an object obj is present in an array arr
*/
Expand Down

0 comments on commit a4e8bfa

Please sign in to comment.