开发者

When serializing a XML type to text, PostgreSQL does not include the the XML declaration, should it not?

SELECT xmlserialize (DOCUMENT (
  SELECT xmlroot(
    xmlelement(name root, 
      xmlelement(name value, 'test')
    ), version '1.0')
  ) AS text);

returns:

<root><value>test</value></root>

I want (and expected):

<?xml version='1.0'?><root><value>test</value></root>

Of course I could go:

SELECT '<?x开发者_如何学Cml version="1.0"?> ' || xmlserialize (CONTENT (...

but then what is the point of including xmlroot?


(I experimented with v8.3.7, v8.4.4 & v9.0.0 on Windows XP)

It includes the xml declaration if the standalone option of xmlroot is used with a value of yes or no:

SELECT xmlserialize (DOCUMENT (
  SELECT xmlroot(
    xmlelement(name root, 
      xmlelement(name value, 'test')
    ), version '1.0', standalone yes)
  ) AS text);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜