1

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.

1 Answer 1

1

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.

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

1 Comment

Ok, I will use this solution, I knew it but I was looking for something more clean.

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.