0

I need to add the namespace details in the xml document.

already I have namespace

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

and xml data in the

l_xmltype :=dbms_xmldom.getXmlType(l_domdoc);

dbms_xmldom.freeDocument(l_domdoc); dbms_output.put_line(l_xmltype.getClobVal);

This l_xmltype is purely XML without namespace. how to concatinate the namespace with this l_xmltype. please help

F0cus
  • 585
  • 3
  • 18
  • 52

1 Answers1

1

If it was just

<?xml version="1.0" stadalone="yes"?>

then you would've used the function XMLROOT.

XMLROOT however doesn't support the encoding tag. You could "hack" your way by using XMLROOT with the parameter value of "version" as '1.0" encoding="utf-8' instead of '1.0' as answered here. That is however not recommended.

If you have access to oracle support, read the document Doc ID 1449682.1. Oracle suggests you to do this instead -

SELECT 
   XMLTYPE(
       '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' 
       || l_xmlvariable_or_column
       )
FROM MY_TABLE;

Keep in mind that encoding="xxxx" in the above statement is changed automatically to the characterset requested by the client. To set it to utf-8, set the NLS_LANG parameter to AL32UTF8.

Community
  • 1
  • 1
ruudvan
  • 1,361
  • 6
  • 16