CC.
CC.

Reputation: 2928

Xml without encoding on Oracle 11g

I'm working on a stored procedure used to generate a xml file. My problem is that the generated xml file does not contains the encoding tag. Here is a small example:

declare
doc DBMS_XMLDOM.DOMDocument;
l_output_clob CLOB ;

begin

          l_output_clob := ' ';
          doc := DBMS_XMLDOM.newDOMDocument;
          DBMS_XMLDOM.setVersion(doc, '1.0');
          DBMS_XMLDOM.setCharset(doc, 'ISO-8859-15');
          dbms_xmldom.writeToClob(doc,l_output_clob) ;
          dbms_output.put_line(l_output_clob);

end;

When I execute it on a 11g database the result is :

<?xml version="1.0"?>

The code above is used to generate a xml file using :

DBMS_XMLDOM.writeToFile

So the encoding tag is missing and I don't know why. Any idea ?

Thanks alot.

Upvotes: 1

Views: 532

Answers (1)

Andris Krauze
Andris Krauze

Reputation: 2142

This might be a workaround, but you can have an encoding attribute as follows:

DECLARE
  doc           dbms_xmldom.domdocument;
  l_output_clob CLOB;
BEGIN

  l_output_clob := ' ';
  doc           := dbms_xmldom.newdomdocument;
  dbms_xmldom.setversion(doc, '1.0" encoding="ISO-8859-15');
  dbms_xmldom.writetoclob(doc, l_output_clob);
  dbms_output.put_line(l_output_clob);
END;

As per Metalink: Xmldom.SetCharSet Not Working With WriteToClob Nor WriteToBuffer (Doc ID 1506543.1)

SETCHARSET procedure is used for writeToFile only. SETCHARSET is ignored in writeToClob and writeToBuffer. This is by design.

Upvotes: 1

Related Questions