简体   繁体   English

不使用Oracle 11g编码的XML

[英]Xml without encoding on Oracle 11g

I'm working on a stored procedure used to generate a xml file. 我正在研究用于生成xml文件的存储过程。 My problem is that the generated xml file does not contains the encoding tag. 我的问题是,生成的xml文件不包含encoding标签。 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 : 当我在11g数据库上执行它时,结果是:

<?xml version="1.0"?>

The code above is used to generate a xml file using : 上面的代码用于使用以下命令生成xml文件:

DBMS_XMLDOM.writeToFile

So the encoding tag is missing and I don't know why. 所以编码标签丢失了,我也不知道为什么。 Any idea ? 任何想法 ?

Thanks alot. 非常感谢。

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) 根据Metalink:Xmldom.SetCharSet不能与WriteToClob或WriteToBuffer一起使用(文档ID 1506543.1)

SETCHARSET procedure is used for writeToFile only. SETCHARSET过程仅用于writeToFile。 SETCHARSET is ignored in writeToClob and writeToBuffer. SETCHARSET在writeToClob和writeToBuffer中被忽略。 This is by design. 这是设计使然。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM