Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003

    Unanswered: 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

  2. #2
    Join Date
    Jan 2007
    Jena, Germany
    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

  3. #3
    Join Date
    Sep 2003
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts