Re: [PATCH] Add pretty-printed XML output option
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jim Jones <jim.jones@uni-muenster.de>
Cc: Peter Smith <smithpb2250@gmail.com>,
Peter Eisentraut <peter.eisentraut@enterprisedb.com>,
Nikolay Samokhvalov <samokhvalov@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Andrey Borodin <amborodin86@gmail.com>
Date: 2023-03-14T17:40:25Z
Lists: pgsql-hackers
Jim Jones <jim.jones@uni-muenster.de> writes: > [ v22-0001-Add-pretty-printed-XML-output-option.patch ] I poked at this for awhile and ran into a problem that I'm not sure how to solve: it misbehaves for input with embedded DOCTYPE. regression=# SELECT xmlserialize(DOCUMENT '<!DOCTYPE a><a/>' as text indent); xmlserialize -------------- <!DOCTYPE a>+ <a></a> + (1 row) regression=# SELECT xmlserialize(CONTENT '<!DOCTYPE a><a/>' as text indent); xmlserialize -------------- (1 row) The bad result for CONTENT is because xml_parse() decides to parse_as_document, but xmlserialize_indent has no idea that happened and tries to use the content_nodes list anyway. I don't especially care for the laissez faire "maybe we'll set *content_nodes and maybe we won't" API you adopted for xml_parse, which seems to be contributing to the mess. We could pass back more info so that xmlserialize_indent knows what really happened. However, that won't fix the bogus output for the DOCUMENT case. Are we perhaps passing incorrect flags to xmlSaveToBuffer? regards, tom lane
Commits
-
Fix memory leak in XMLSERIALIZE(... INDENT).
- f24605e2dc16 18.0 landed
- ee58de10084b 16.10 landed
- 20bae0690322 17.6 landed
-
doc: Move documentation of md5_password_warnings to a better place
- f3622b64762b 18.0 cited
-
Support [NO] INDENT option in XMLSERIALIZE().
- 483bdb2afec9 16.0 landed
-
Add an expected-file to match behavior of latest libxml2.
- 085423e3e326 9.6.0 cited