Here's the code I use (similar to everyone else's) - but I've catalogued
it globally as a user conversion subroutine - this allows it to be used
with ICONV & OCONV:

Eg. CONV.XML = OCONV(ORIG.XML,"U2XML")

Note: I've included conversion for three mark characters, just in case
they manage to sneak through!

To catalog the routine - use this: "CATALOG BP $2XML U2XML"

      FUNCTION U2XML(STATUS.CODE, DATA.FIELD, INTERNAL)
*
************************************************************************
*
*
* Arguments:
*
*  STATUS.CODE     (I/O) Input : The conversion code
*                        Output: The value to return to set STATUS()
*  DATA.FIELD      (I)   The data to be converted
*  INTERNAL        (I)   @TRUE = ICONV; @FALSE = OCONV
*
*  returns : The converted DATA.FIELD
*
************************************************************************
*
*
      STATUS.CODE = 0
*
      IF INTERNAL
      THEN
         RESULT = CHANGE(DATA.FIELD, "&", "&")
         RESULT = CHANGE(RESULT, "<", "&lt;")
         RESULT = CHANGE(RESULT, ">", "&gt;")
         RESULT = CHANGE(RESULT, "'", "&apos;")
         RESULT = CHANGE(RESULT, '"', "&quot;")
         RESULT = CHANGE(RESULT, @VM, "&#253;")
         RESULT = CHANGE(RESULT, @FM, "&#254;")
         RESULT = CHANGE(RESULT, @SM, "&#252;")
      END
      ELSE
         IF INDEX(DATA.FIELD,"&",1)
         THEN
            RESULT = CHANGE(DATA.FIELD, "&amp;", "&")
            RESULT = CHANGE(RESULT, "&lt;", "<")
            RESULT = CHANGE(RESULT, "&gt;", ">")
            RESULT = CHANGE(RESULT, "&apos;", "'")
            RESULT = CHANGE(RESULT, "&quot;", '"')
            RESULT = CHANGE(RESULT, "&#253;", @VM)
            RESULT = CHANGE(RESULT, "&#254;", @FM)
            RESULT = CHANGE(RESULT, "&#252;", @SM)
         END
         ELSE
            RESULT = DATA.FIELD
         END
      END
*
      RETURN (RESULT)
*
************************************************************************
*
*
   END 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Ben Souther
Sent: Thursday, 26 February 2009 5:13 AM
To: [email protected]
Subject: [U2] XML Escape function

Years ago, I thought I saw an XML escape function in Unibasic but I
can't seem to find it now.  I thought it was mentioned in the Unidata
Extensions PDF but I'm not able to find it.

Does anyone know if such a function exists?

Thanks,
-Ben
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/


DISCLAIMER:
Disclaimer.  This e-mail is private and confidential. If you are not the 
intended recipient, please advise us by return e-mail immediately, and delete 
the e-mail and any attachments without using or disclosing the contents in any 
way. The views expressed in this e-mail are those of the author, and do not 
represent those of this company unless this is clearly indicated. You should 
scan this e-mail and any attachments for viruses. This company accepts no 
liability for any direct or indirect damage or loss resulting from the use of 
any attachments to this e-mail.
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to