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, "<", "<")
RESULT = CHANGE(RESULT, ">", ">")
RESULT = CHANGE(RESULT, "'", "'")
RESULT = CHANGE(RESULT, '"', """)
RESULT = CHANGE(RESULT, @VM, "ý")
RESULT = CHANGE(RESULT, @FM, "þ")
RESULT = CHANGE(RESULT, @SM, "ü")
END
ELSE
IF INDEX(DATA.FIELD,"&",1)
THEN
RESULT = CHANGE(DATA.FIELD, "&", "&")
RESULT = CHANGE(RESULT, "<", "<")
RESULT = CHANGE(RESULT, ">", ">")
RESULT = CHANGE(RESULT, "'", "'")
RESULT = CHANGE(RESULT, """, '"')
RESULT = CHANGE(RESULT, "ý", @VM)
RESULT = CHANGE(RESULT, "þ", @FM)
RESULT = CHANGE(RESULT, "ü", @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/