If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Escaping XML characters in DB2 data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-17-10, 17:13
ek1975 ek1975 is offline
Registered User
 
Join Date: Sep 2003
Posts: 44
Escaping XML characters in DB2 data

Hello list,

Recently we have had numerous applications wanting to create XML. Sometimes the data comes from DB2 and in other cases, it comes from other sources (or a combination of the above). So people are writing code in their individual programs to escape the 5 characters that need to be escaped for XML (' " & < >)

I was wondering if IBM had a DB2 function to do this conversion. If not I thought I would write a UDF (called ESCAPE4XML), so people could use a common function like ESCAPE4XML(col1). But I don't it's going to be simple because column names could vary in size from anywhere between 35 CHAR to 120 and then there is VARCHAR going up to the 1000's. Would one size fit all methodology cost us on application performance?

I am just thinking out loud looking for ideas/best practices. I would appreciate any input you could provide... Thanks for your time.

Environment: DB2 v8 for z/OS
Reply With Quote
  #2 (permalink)  
Old 03-19-10, 08:24
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Why do you want to escape those characters? Just store the document in the DB2 database as-is. Or do you want to break down/piece together an XML document from strings without the DB2 XML functionality? (I don't know if that was available in DB2 z/OS V8.)
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 03-19-10, 09:05
ek1975 ek1975 is offline
Registered User
 
Join Date: Sep 2003
Posts: 44
We don't escape characters while storing it in DB2. We have applications that expect XML strings/documents as input. I am trying to escape those characters after retreiving data from DB2 while contructing (piece together) the XML document for this 'XML expecting' application.

We have not looked at the DB2 XML functionality so far (we just got on v8 4 days ago). I'll look at it and see if it does that.
Reply With Quote
Reply

Tags
escape, xml

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On