Handling XML special characters

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Handling XML special characters

Post by pradkumar »

Hi Everyone,

Iam using DB2 API stage to read the data from DB2 Mainframe and creating xml files using xml output stage. I have a requirement to handle XML special characters in our data. There are few special characters that need to be escaped in the XML files.

Character Escaped Value
& -- &
< -- &lt'
" -- "

The above are the standard XML character entities that will produce invalid XML if the characters are directly present in any data values. we have to make this as a standard and do it any xml output.But the chances of getting these characters in the data are rare.

I have searched the forum and trying to implement using the Convert function. Could any one let me know what would be the best approach and the soultion .

Thanks in Advance
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It's all automatic, you shouldn't have to do anything to get that to happen. Are you having an issue or just asking before you get started?
-craig

"You can never have too many knives" -- Logan Nine Fingers
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

Hi,

Thanks for your response.

But,I couldnt get what you meant "It will happen automatically".

Here is my scenario.

Character Escaped Value
& ---------- &
< ----------- <
> ----------- >
" ----------- "

The requirement is.. if the source data contains the character values mentioned above,it should be replaced with the escaped value.

Iam trying to replace these characters using the convert function. but it is taking only the first value as a replacement character but not the whole string (&).

eg: Convert(\&<>'"\,\&<>&aphos;"input column)

Is there any other ways to do this..?

Thanks.
ArjunK
Participant
Posts: 30
Joined: Sun Apr 30, 2006 6:32 pm

Post by ArjunK »

As chulett mentioned you don't have to do anything. The XML Output stage will automatically convert the XML reserved characters.
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

Hi,

Thanks for the inputs.. It worked fine.

Iam marking this thread as resolved.
Post Reply