pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Garfield Lewis <garfield.lewis@lzlabs.com>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Using XMLNAMESPACES with XMLEMENT
Date: Sun, 26 Sep 2021 19:48:37 +0000
Message-ID: <D8FDDCCF-92A1-4D7F-8335-DA812ECC35F2@lzlabs.com> (raw)
In-Reply-To: <CAFj8pRCpee-UzFQ-YEZDo0mG4tXEjJxfW4_Ci2kQ0aFWBOb_6g@mail.gmail.com>
References: <64818D06-4BD8-4D81-9C23-6BD392B85E20@lzlabs.com>
	<CAFj8pRCpee-UzFQ-YEZDo0mG4tXEjJxfW4_Ci2kQ0aFWBOb_6g@mail.gmail.com>

Thx @Pavel Stehule<mailto:pavel.stehule@gmail.com>, I’ll see if I can figure this out…  ☺

Regards,
Garfield

From: Pavel Stehule <pavel.stehule@gmail.com>
Date: Friday, September 24, 2021 at 11:33 PM
To: Garfield Lewis <garfield.lewis@lzlabs.com>
Cc: "pgsql-general@postgresql.org" <pgsql-general@postgresql.org>
Subject: Re: Using XMLNAMESPACES with XMLEMENT

Hi

pá 24. 9. 2021 v 23:44 odesílatel Garfield Lewis <garfield.lewis@lzlabs.com<mailto:garfield.lewis@lzlabs.com>> napsal:
Hi All,

I am attempting to port the following statement from DB2z to Postgres:


SELECT e.empno, e.firstnme, e.lastname,

          XMLELEMENT ( NAME "foo:Emp",

            XMLNAMESPACES('http://www.foo.com'; AS "foo"),

            XMLATTRIBUTES(e.empno as "serial"),

                          e.firstnme,

                          e.lastname ) AS "Result"

       FROM EMP e

       WHERE e.edlevel = 12;

The NAMESPACES function is not supported by Postgres in the XMLELEMENT function. Is there any way to get this to work? I’ve looked at the WITH syntax but it doesn’t look like that will be helpful here.

I am afraid this is not supported in Postgres. The XMLNAMESPACE clause can be used only in XMLTABLE function. You need to make XML and in the next step you need to modify it as string with string operation.

It can be an interesting feature, and if it is supported by libxml2, then it can be easily implemented. But at this moment it is unsupported, and you have to use string operations - it should not be hard to use regexp.

Regards

Pavel




Regards,
Garfield


view thread (7+ messages)  latest in thread

Message-ID: <D8FDDCCF-92A1-4D7F-8335-DA812ECC35F2@lzlabs.com>
Permalink:  ../D8FDDCCF-92A1-4D7F-8335-DA812ECC35F2@lzlabs.com/
Also on:    postgresql.org/message-id/D8FDDCCF-92A1-4D7F-8335-DA812ECC35F2@lzlabs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: garfield.lewis@lzlabs.com, pavel.stehule@gmail.com
  Subject: Re: Using XMLNAMESPACES with XMLEMENT
  In-Reply-To: <D8FDDCCF-92A1-4D7F-8335-DA812ECC35F2@lzlabs.com>
  References: <64818D06-4BD8-4D81-9C23-6BD392B85E20@lzlabs.com> <CAFj8pRCpee-UzFQ-YEZDo0mG4tXEjJxfW4_Ci2kQ0aFWBOb_6g@mail.gmail.com> <D8FDDCCF-92A1-4D7F-8335-DA812ECC35F2@lzlabs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox