Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to define namespace when concatenating XmlType from various functions?

happybuddhaDec 6 2018 — edited Dec 7 2018

I am generating an xml file from a procedure on Oracle 11. This procedure calls multiple functions to get various parts of the xml. Then finally, all of these little fragments are clubbed together and the final xml is spit out. It looks something like this :

select

      xmlserialize(DOCUMENT

xmlelement("def:SomeReport",

xmlattributes('http://bbc.uk.au/comn/service.service'   as "xmlns:def", 

      'http://www.w3.org/2005/05/xmlmime'   as "xmlns:xmime",

      'http://www.w3.org/2001/XMLSchema-instance' as "xmlns:xsi",

      'http://www.who.is.me/blah' as "xmlns:abc")

,

xmlelement("StdMsg,

xmlconcat(

v_frag1_xml,

v_frag2_xml)

)

  ) as CLOB VERSION '1.0" encoding="UTF-8' INDENT SIZE = 2

)

into final_xml  --   final_xml out CLOB

from dual;

So everything was working well till it was decided the fragments of xml should be namespaced with `abc`

Now, when I run this procedure, where it generates v_frag1_xml (which in turn calls about 10 other functions to get smaller fragments, I get a

Error occurred in XML processing LPX-00234: namespace prefix "abc" is not declared Error at line 1 ORA-06512:

The functions returning one of the fragments looks like so

select xmlconcat(v_business_1_xml,

xmlelement("BlahId",

xmlelement("BlahNumber",v_index),

xmlelement("BlahText",

xmlelement("abc:CursedTag",xmlconcat(

v_another_xml,

v_furtherAnother_xml

)

)

into frag1_xml

from dual

;

How do I go about generating smaller fragments of XML from the procedures without running into the

Error occurred in XML processing LPX-00234: namespace prefix "abc" is not declared Error at line 1 ORA-06512:

Cheers

Message was edited by: happybuddha. Updated oracle version

Comments
Post Details
Added on Dec 6 2018
2 comments
3,594 views