Output of query_to_xml

Started by P. Broennimannalmost 14 years ago3 messagesgeneral
Jump to latest
#1P. Broennimann
peter.broennimann@gmail.com

Hi there

In my stored function I use:

select query_to_xml('select * from table12', true, true, '') into ...

The result is OK but there is always an empty line:

<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
*<-- Empty line here*
<vanoao>FG8976SDFRETG</vanoao>
<country_code>NL</country_code>
<build_date>2011-02-28</build_date>
<tcode>MFT</tcode>
<exterior_color_code>GAB</exterior_color_code>
<interior_color_code>TAFP</interior_color_code>
</row>

Is this supposed to be or is this a cosmetic bug?

Thanks,
P.

#2Dickson S. Guedes
listas@guedesoft.net
In reply to: P. Broennimann (#1)
Re: Output of query_to_xml

2012/6/21 P. Broennimann <peter.broennimann@gmail.com>:

Hi there

In my stored function I use:

select query_to_xml('select * from table12', true, true, '') into ...

The result is OK but there is always an empty line:

<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
                                <-- Empty line here
 <vanoao>FG8976SDFRETG</vanoao>
 <country_code>NL</country_code>
 <build_date>2011-02-28</build_date>
 <tcode>MFT</tcode>
 <exterior_color_code>GAB</exterior_color_code>
 <interior_color_code>TAFP</interior_color_code>
</row>

Is this supposed to be or is this a cosmetic bug?

In fact this is in code [1]http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/adt/xml.c;h=44d327d7606df620c01b6e6532e53a9ee7a21f23;hb=HEAD#l2386, obviously, but if it should be there I don't know.

That extra line only is printed when 'tableforest' is set to true, so
if you use:

select query_to_xml('select * from table12', true, false, '')

the extra line and the 'xmlns:xsi=' for <row> tag goes always.

[1]: http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/adt/xml.c;h=44d327d7606df620c01b6e6532e53a9ee7a21f23;hb=HEAD#l2386

regards
--
Dickson S. Guedes
mail/xmpp: guedes@guedesoft.net - skype: guediz
http://guedesoft.net - http://www.postgresql.org.br

#3Peter Eisentraut
peter_e@gmx.net
In reply to: P. Broennimann (#1)
Re: Output of query_to_xml

On tor, 2012-06-21 at 07:49 +0200, P. Broennimann wrote:

select query_to_xml('select * from table12', true, true, '') into ...

The result is OK but there is always an empty line:

<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
*<-- Empty line here*
<vanoao>FG8976SDFRETG</vanoao>
<country_code>NL</country_code>
<build_date>2011-02-28</build_date>
<tcode>MFT</tcode>
<exterior_color_code>GAB</exterior_color_code>
<interior_color_code>TAFP</interior_color_code>
</row>

Is this supposed to be or is this a cosmetic bug?

No reason. I think it just came out this way because there are so many
modes to handle, and you want some legible output in all of them.

I've removed outputting the extra newline in 9.3devel.