xpath insert unexpected newlines

From: "Voillequin, Jean-Marc" <Jean-Marc(dot)Voillequin(at)moodys(dot)com>
To: "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: xpath insert unexpected newlines
Date: 2019-04-19 13:04:37
Message-ID: 1EC8157EB499BF459A516ADCF135ADCE3A23A9CA@LON-WGMSX712.ad.moodys.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-sql

Hello guys,

It seems that xpath function add unexpected newlines in the xml elements it returns as array:

postgres=> select version();
version
------------------------------------------------------------
PostgreSQL 10.3, compiled by Visual C++ build 1800, 64-bit
(1 row)

postgres=> select ((xpath('/*',xml('<root><a/><b/><c/></root>')))[1])::text;
xpath
---------
<root> +
<a/> +
<b/> +
<c/> +
</root>
(1 row)

A workaround is to have at least one element with a value:

postgres=> select ((xpath('/*',xml('<root><a/><b/><c/>one value</root>')))[1])::text;
xpath
------------------------------------
<root><a/><b/><c/>one value</root>
(1 row)

Best regards.

-----------------------------------------

Moody's monitors email communications through its networks for regulatory compliance purposes and to protect its customers, employees and business and where allowed to do so by applicable law. The information contained in this e-mail message, and any attachment thereto, is confidential and may not be disclosed without our express permission. If you are not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution or copying of this message, or any attachment thereto, in whole or in part, is strictly prohibited. If you have received this message in error, please immediately notify us by telephone, fax or e-mail and delete the message and all of its attachments. Every effort is made to keep our network free from viruses. You should, however, review this e-mail message, as well as any attachment thereto, for viruses. We take no responsibility and have no liability for any computer virus which may be transferred via this e-mail message.

This email was sent to you by Moody’s Investors Service EMEA Limited
Registered office address:
One Canada Square
Canary Wharf
London, E14 5FA
Registered in England and Wales No: 8922701

-----------------------------------------

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2019-04-19 13:29:30 BUG #15773: Cannot Open a sql file directly - have to go to pgadmin, query tool and then choose open
Previous Message Sandeep Thakkar 2019-04-19 12:45:57 Re: Re: BUG #15769: The database cluster intialisation failed.

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2019-04-19 14:21:23 Re: xpath insert unexpected newlines
Previous Message Alexandre Lessard 2019-04-11 14:05:13 Partitioning table on tztsrange