One Star

replaceSpecialCharForXML Replacing & on escape characters

I have a job that takes in an MySQL input, performs a tmap then produces an xml output file via the advanced xml output plugin (I have selected UTF8 format). I use the replaceSpecialCharForXML function to replace any characters like apostrophe, ampersand, etc into the correct xml format.
My issue is that this replaceSpecialCharForXML function is replacing the apostrophe and then also replacing the ampersand with another xml escape character.
Sample data: Mr Jone's
Expected xml output using replaceSpecialCharForXML: Mr Jone's
What is occuring: Mr Jone's
Surely this function is not supposed to replace the & that is the apostrophe escape character?
Any help or advice would be appreciated.
Community Manager

Re: replaceSpecialCharForXML Replacing & on escape characters

This function works well,
I can see the correct result on the console
Mr Jone's
the problem occurs on tAdvancedFileOutputXML component
If I open the xml file in editor, it displays Mr Jone's, if I open the xml file directly in browser, it displays Mr Jone's.
Talend | Data Agility for Modern Business
One Star

Re: replaceSpecialCharForXML Replacing & on escape characters

I don't understand why you escape these special characters, using a tFile(advanced or not)OutputXML should produce a valid XML file and escape them for you.
It seems to me you're doing twice the job and that's why it ends up like this. Furthermore you're using UTF-8 so you shouldn't have the problem I encountered here :