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 add version and encoding to XML

MarwimSep 6 2012 — edited Sep 14 2012
Hello,

I generate an XML using code like
SELECT  XMLELEMENT(
             "Document"
            ,XMLAttributes(
                 'urn:iso:std:iso:20022:tech:xsd:pain.001.002.99' AS "xmlns"
                ,'http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi"
                ,'urn:iso:std:iso:20022:tech:xsd:pain.001.002.99 pain.001.002.99.xsd' AS "xsi:schemaLocation"
                )
        )
FROM    dual;
The result ist
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.002.99"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.002.99 pain.001.002.99.xsd">
</Document>
But I need
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.002.99"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.002.99 pain.001.002.99.xsd">
</Document>
Can I add the header within my select?

The XMLTYPE is inserted into a table and from there transfered via webutil to a client location.
I found that I can convert the XMLTYPE to a DOM document and then use dbms_XMLDom.setCharset, but how can I convert it back to a XMLTYPE. The only way I found is to convert it to a CLOB and then into a XMLTYPE.

Regards
Marcus

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
This post has been answered by AlexAnd on Sep 7 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 12 2012
Added on Sep 6 2012
6 comments
6,681 views