Problem using Convert in Transformer
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 175
- Joined: Tue Oct 14, 2008 1:48 pm
Problem using Convert in Transformer
HI,
I have a job which looks like
seqfile -----> transformer ---------> seqfile
The requirement is if the data is "]]CDATA]" then they have to change it to
"![CDATA[". when I tried to use convert I am getting "!!CDATA!". can anybody help me out.
Thanks,
**Note - Subject changed to be more descriptive - Content Editor**
I have a job which looks like
seqfile -----> transformer ---------> seqfile
The requirement is if the data is "]]CDATA]" then they have to change it to
"![CDATA[". when I tried to use convert I am getting "!!CDATA!". can anybody help me out.
Thanks,
**Note - Subject changed to be more descriptive - Content Editor**
Rajesh Kumar
-
- Participant
- Posts: 152
- Joined: Tue Jan 13, 2009 8:59 am
Re: Transformer
convert function does not work the way you are understanding...
it does not look for a string and replace it with the string you give...
but looks for the character by character
meaning for ex:
if you say convert('ab','cd',link.col)..
it replaces 'a' with 'c' and 'b' with 'd'...
it does not look for a string and replace it with the string you give...
but looks for the character by character
meaning for ex:
if you say convert('ab','cd',link.col)..
it replaces 'a' with 'c' and 'b' with 'd'...
-
- Premium Member
- Posts: 175
- Joined: Tue Oct 14, 2008 1:48 pm
Re: Transformer
[quote="betterthanever"]convert function does not work the way you are understanding...
Can you tell me how can I achive my target data?
Can you tell me how can I achive my target data?
Rajesh Kumar
-
- Participant
- Posts: 152
- Joined: Tue Jan 13, 2009 8:59 am
Re: Transformer
search the forum...you will get lot of info on this
-
- Premium Member
- Posts: 175
- Joined: Tue Oct 14, 2008 1:48 pm
Re: Transformer
I searched the form by replace a string, but I did not get the right one.betterthanever wrote:search the forum...you will get lot of info on this
Rajesh Kumar
-
- Participant
- Posts: 152
- Joined: Tue Jan 13, 2009 8:59 am
Re: Transformer
[quote="kittu.raja"][quote="betterthanever"]search the forum...you will get lot of info on this[/quote]
I searched the form by replace a string, but I did not get the right one.[/quote]
check this
http://dsxchange.com/viewtopic.php?t=10 ... f69dc268a1
I searched the form by replace a string, but I did not get the right one.[/quote]
check this
http://dsxchange.com/viewtopic.php?t=10 ... f69dc268a1
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You need something more complex, though a Convert() function is certainly involved. First you need a conditional expression, because the data won't always be "]]CDATA]". Then, assuming that this is the entire contents (rather than partial), you need to replace the first character with "!" and convert the remaining "]" characters to "[".
Hence
Hence
Code: Select all
If InLink.TheField = "]]CDATA]" Then "!" : Convert("]", "[", InLink.TheField[2, Len(InLink.TheField) - 1] Else InLink.TheField
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Can you give more details about your requirements ?
Is everytime data is coming like '"]]CDATA]"' and you have to convert it to the "![CDATA[" ?
Or it is only the first occurance of the ] needs to be converted to the !.
Then you can just use convert on the rest of the string using convert and use concatanation for the first charater....
Is everytime data is coming like '"]]CDATA]"' and you have to convert it to the "![CDATA[" ?
Or it is only the first occurance of the ] needs to be converted to the !.
Then you can just use convert on the rest of the string using convert and use concatanation for the first charater....
-----------------------------------
Regards
MK
What would you attempt to do if you knew you could not fail?
-----------------------------------
Regards
MK
What would you attempt to do if you knew you could not fail?
-----------------------------------
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Premium Member
- Posts: 175
- Joined: Tue Oct 14, 2008 1:48 pm
-
- Premium Member
- Posts: 175
- Joined: Tue Oct 14, 2008 1:48 pm
Everytime I have to convert it and convert is not working on string replacemk_ds09 wrote:Can you give more details about your requirements ?
Is everytime data is coming like '"]]CDATA]"' and you have to convert it to the "![CDATA[" ?
Or it is only the first occurance of the ] needs to be converted to the !.
Then you can just use convert on the rest of the string using convert and use concatanation for the first charater....
Rajesh Kumar
-
- Premium Member
- Posts: 175
- Joined: Tue Oct 14, 2008 1:48 pm
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Premium Member
- Posts: 175
- Joined: Tue Oct 14, 2008 1:48 pm
-
- Premium Member
- Posts: 175
- Joined: Tue Oct 14, 2008 1:48 pm
the data is not just "] CDATA". it contains a big staement in which CDATA is part of it. So I cannot use If then Else.ray.wurlod wrote:You need something more complex, though a Convert() function is certainly involved. First you need a conditional expression, because the data won't always be "]]CDATA]". Then, assuming that this is ...
Rajesh Kumar