Page 1 of 1

Replacing & character

Posted: Thu Mar 30, 2006 8:06 am
by Diya
Hi all,

My Job generate xml files from csv files.
As xml file will not recognize '&' char ,I need to repalce it with '&'

Now I am using change Function which is there in Basic Transformer.

But this is causing lot of troubles while running .The processs are getting locked very frequently.

Is there any function in Normal Transformer to replace this '&' character.

Thanks.

Posted: Thu Mar 30, 2006 8:23 am
by DSguru2B
What function are you using?
Try using EREPLACE or just replace it using an " IF THEN" statement.

Posted: Thu Mar 30, 2006 9:19 am
by Diya
I am using the CHANGE function now.Could you please tell me the syntax for EReplace in this case to replce an '&' character

Posted: Thu Mar 30, 2006 9:37 am
by ArndW
The Change and Ereplace functions are the same (except when
evaluating an emptyr string).

You might write a normal Server job to read you source file, parse it and write it back out to another sequential file, which your PX job then reads. It will make maintenance and debugging easier and might even make it faster if your XML files are small (due to the overhead involved in starting PX jobs).

Posted: Thu Mar 30, 2006 9:53 am
by Diya
I have to use a parallel job as I have to generate multiple xml files in a single job which includes Joiners also..
I just want to know the Function which a Normal Transformer supports this Replacing instead of Using a Basic Transformer to implement this replacement

Posted: Thu Mar 30, 2006 10:07 am
by ArndW
Diya, there is no equivalent to the server ereplace function in a PX transform stage. You can find an occurrence with INDEX or replace one character with one other character using CONVERT but for more than that you would need to write your own short c++ routine.

Posted: Thu Mar 30, 2006 10:08 am
by anntaylor
I use the below to replace a CR in a comment field. You can do something similar

Convert(char(10), ". ",AOStyleComment.RemarkType)

Posted: Thu Mar 30, 2006 10:10 am
by ArndW
Anna,

no, the CONVERT function is useless in this case since the poster wants to convert one character into a sequence of 4 characters.

CONVERT('&','&',In.Column) will not do any changes at all to the value, It will replace "&" with "&" and the rest of the resulting to-conversion string won't even be used.

Posted: Thu Mar 30, 2006 11:18 am
by DSguru2B
Why not just simple add an if then statement as i meantioned.

If Link.Column='&' then '&AMP' else.... whatever you want to do.

Posted: Thu Mar 30, 2006 1:51 pm
by ray.wurlod
The original statement of the problem specified that a BASIC Transformer stage was being used, where both Change() and Ereplace() might legally be used. This is not the problem.

The problem is that something, somewhere, is locking.

Can you please explain exactly what you mean by "the processes are getting locked" and what symptom that you observe leads to this particular diagnosis?

The Change() function can not cause any kind of locking.

However, the interface between a parallel job and a BASIC Transformer stage may - I repeat, may - be the culprit. We need to eliminate all other possibilities before we can be any more certain than that.