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

2
  • <?xml?> is not a namespace but an optional preamable. Commented Mar 23, 2015 at 10:47
  • Hi Preamable,<DeriveCoverageRequest xmlns ="urn:XYZ:ccw:config:common:data" xmlns:ns1="urn:XYZ:ccw:config:msa:data" > is the namespace. need to concantenate with the l_xmltype Commented Mar 23, 2015 at 10:49

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Ruudvan for your help .. this is very help ful :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.