Replacing ' with '

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
ankita
Participant
Posts: 57
Joined: Sun Nov 13, 2005 11:17 pm

Replacing ' with '

Post by ankita »

Hi,

We have a requirement to generate xml o/p and replace special chars as below,
& with &
\ with "
' with '
> with >
< with <
" with "

I have used a Basic transformer and Ereplace() function . But not able to handle apostrophe/single quote replacement through this.
Ereplace(Input_Str,''','&apos;',0) or Ereplace(Input_Str,'\'','&apos;',0) is not accepted. How can I replace this special char ?

Please suggest!

Thanks,
Ankita
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

DataStage BASIC expressions recognize three quote characters. If you need to quote a single-quote character surround it with either of the others. Therefore you can represent a single quote as "'" or as \'\. Hence, for example,

Code: Select all

Ereplace(Input_Str, "'", "&apos;", -1, 0)
or

Code: Select all

Ereplace(Input_Str, \'\, \&apos;\, -1, 0)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ankita
Participant
Posts: 57
Joined: Sun Nov 13, 2005 11:17 pm

Post by ankita »

Thanks Ray ! I have tried, it's working !
Ankita
WoMaWil
Participant
Posts: 482
Joined: Thu Mar 13, 2003 7:17 am
Location: Amsterdam

Post by WoMaWil »

Anika,

and don't forget to change also all Charactes with Ascii-Value above 159 with
  = ASCII(160) => & # 1 6 0 ;
¡ = ASCII(161) => & # 1 6 1 ;
¢ = ASCII(162) => & # 1 6 2 ;
£ = ASCII(163) => & # 1 6 3 ;
¤ = ASCII(164) => & # 1 6 4 ;
¥ = ASCII(165) => & # 1 6 5 ;
¦ = ASCII(166) => & # 1 6 6 ;
§ = ASCII(167) => & # 1 6 7 ;
¨ = ASCII(168) => & # 1 6 8 ;
© = ASCII(169) => & # 1 6 9 ;
ª = ASCII(170) => & # 1 7 0 ;
« = ASCII(171) => & # 1 7 1 ;
¬ = ASCII(172) => & # 1 7 2 ;
and so on.............
Ignore the blanks I have made, but if I would not have done you would see it not correct here in the forum.
Wolfgang Hürter
Amsterdam
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So you are doing all of the XML manually? The XML Output stage will automatically do all of those replacements.
-craig

"You can never have too many knives" -- Logan Nine Fingers
WoMaWil
Participant
Posts: 482
Joined: Thu Mar 13, 2003 7:17 am
Location: Amsterdam

Post by WoMaWil »

Do you realy trust in DataStage XML, Craig?

I havn't done any XML-Output so far, but with XML-Input I had a lot of problems concerning such kind of conversion, that I had to write tricky routines.
Wolfgang Hürter
Amsterdam
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So far, yes... as long as there's no 'extended ascii' to worry about that is. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Wolfgang, the USA can be a pretty sheltered, packaged, environment sometimes!
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Fine... be that way. Still, my point stands. The XML Output stage will do all of the conversions the OP asked for automatically. Well, except for "\ with "" which I assumed was a typo. :?

Perhaps they are doing all of their XML work manually for speed, that I could understand.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply