Problem description:
When outputting XML files out of PL/SQL, You need to convert the five predefined entities of XML:
Below are five predefined entities in the XML document:
& Lt; |
< |
Yu no. |
& Gt; |
> |
Yu no. |
& Amp; |
& |
And |
& Apos; |
' |
Single quotes |
& Quot; |
" |
Double quotation marks |
Solution:
A procedure is usually used in PL/SQL for conversion:
-- The five objects predefined in XML are in the XML output file, the following characters must use the Escape Character of XML <br/>/* = ==============================< br/> * function/procedure <br/> * transform_xml_entity <br/> * description: <br/> * convert the predefined XML entity in the output character to the Escape Character of XML. <br/> * argument: <br/> * p_value: output XML content <br/> * return: <br/> * N/A <br/> * history: <br/> * 1.00 17/07/2010 cxy <br/> * ================ =====================================*/<br/> function transform_xml_entity (p_value in varchar2) return varchar2 is <br/> l_value varchar2 (2000); <br/> begin <br/> l_value: = p_value; <br/> l_value: = Replace (l_value, '<', CHR (38) | 'lt;'); <br/> l_value: = Replace (l_value, '>', CHR (38) | 'gt; '); <br/> l_value: = Replace (l_value,' & ', CHR (38) |' amp; '); <br/> l_value: = Replace (l_value, ''', CHR (38) | 'apos; '); <br/> l_value: = Replace (l_value ,'"', CHR (38) | 'quot; '); </P> <p> return l_value; <br/> end transform_xml_entity;