Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Replace strange symbols
[ATL] Replace strange symbols [message #660731] Mon, 21 March 2011 12:33 Go to next message
Miguel Llàcer San Fernando is currently offline Miguel Llàcer San FernandoFriend
Messages: 63
Registered: July 2009
Member
Hi, I have a string property to which I want to replace some strange symbols like (ñ, ç) or accents but I have used replaceAll() method and it doesn't work fine.

that is my code:

element.name <- element.name.replaceAll('ñ', 'ny');
element.name <- element.name.replaceAll('ç', 'c');
element.name <- element.name.replaceAll('ó', 'o');

I transform elements with this symbols ('año', 'dirección'...) but the result is the same.

I have try to compare, for each character if it is a strange symbol but comparison returns false. That is:

for (c in element.name.toSequence()) {
if (c = 'ñ') {
... this code is never reached
}
}

Any idea ?¿?
Re: [ATL] Replace strange symbols [message #660744 is a reply to message #660731] Mon, 21 March 2011 12:58 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
try regexReplaceAll
Re: [ATL] Replace strange symbols [message #660748 is a reply to message #660744] Mon, 21 March 2011 13:09 Go to previous messageGo to next message
Miguel Llàcer San Fernando is currently offline Miguel Llàcer San FernandoFriend
Messages: 63
Registered: July 2009
Member
I have tried but it doesn't work... Sad
Re: [ATL] Replace strange symbols [message #660753 is a reply to message #660731] Mon, 21 March 2011 13:32 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
Are you sure that the transformation still compiles with those characters ?
Try to delete the .asm file and see if it comes back after a build.
Re: [ATL] Replace strange symbols [message #660776 is a reply to message #660753] Mon, 21 March 2011 14:50 Go to previous messageGo to next message
Miguel Llàcer San Fernando is currently offline Miguel Llàcer San FernandoFriend
Messages: 63
Registered: July 2009
Member
Yes, I have removed the .asm and it has been re-build without errors and the transformation is executed with the same results.
Re: [ATL] Replace strange symbols [message #660794 is a reply to message #660731] Mon, 21 March 2011 16:07 Go to previous message
Sebastian is currently offline SebastianFriend
Messages: 11
Registered: February 2011
Junior Member
Hi Miguel,
it could be an encoding problem. If what you expect to be a 'ñ' internally is represented by something like '#$%&' your replace/comparison wont work.

Miguel Ll wrote on Mon, 21 March 2011 08:33
for (c in element.name.toSequence()) {
if (c = 'ñ') {
... this code is never reached
}
}

You could look in the debugger BEFORE you compare c = 'ñ' what values c takes. Maybe you have to check the encoding setting for your import. Do you use XMI? The first line of the XML should specify an encoding.

Regards,
Sebastian
Previous Topic:[QVTo] Removing an element
Next Topic:[QVTo] Weird thing about Stereotypes application
Goto Forum:
  


Current Time: Mon Mar 01 13:19:01 GMT 2021

Powered by FUDForum. Page generated in 0.04417 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top