Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mTu3J-00051s-U1 for pgsql-general@arkaria.postgresql.org; Fri, 24 Sep 2021 22:52:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mTu3I-00061y-RU for pgsql-general@arkaria.postgresql.org; Fri, 24 Sep 2021 22:52:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mTu3I-00061q-Bn for pgsql-general@lists.postgresql.org; Fri, 24 Sep 2021 22:52:20 +0000 Received: from mail-il1-x134.google.com ([2607:f8b0:4864:20::134]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mTu3E-0004d8-Qf for pgsql-general@postgresql.org; Fri, 24 Sep 2021 22:52:19 +0000 Received: by mail-il1-x134.google.com with SMTP id b15so12077586ils.10 for ; Fri, 24 Sep 2021 15:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=tifC4AERYcwCtdd+La7v4xb6X79G8PLQ/y4YinTqGg8=; b=g177uZXT0jmJpC3WajKoczMxjYgt01cmlrfAa7JKI7EtnFpBKezS7WSre8uW7/dZuv EZB3kme9+CJvlhlqKxo8ifE8CzTAY4NzLVl7new7VAM7iRSUVHRZvM8kjOPGgESO7uG7 6GUK1I5rkupCoDRCQmiXuls2E964hyTpQqtCl7mBRZrlTXb11r3UFiAbeCXjFQY+I7iH W420+GSBf+o22NGSWIkKvxT47+9ewuEAZJ9mZcWDC5skzG267zQKVqUTZC+AToEeAC0V F3TGeZeHUnZwdtAMvHVGCoFM/F9Zh7QuxJm5mp5CyjcR6scU2BR8imVsGkpv7Z9jALGv 9OdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=tifC4AERYcwCtdd+La7v4xb6X79G8PLQ/y4YinTqGg8=; b=PNBH4pL5osNkIxxUWSK9Pro9HKEEb97PSoOdhC+tTq7qURCm6tZeAu63FC2M5jNP9P nZNpSZ1LsvuGU6RRcLIomNKpQ5/yrC8IXhNDYQhe0U1umPTJadeGoKEhX5Zu8PgjyEQM +E7vnC2jyBhPBgFQQJmyGSGH1h1OXJ+gemX+gibAktl3BISSFqqQpVSc0ihDw3qpVDh/ dgSh9e4wlwrqwMKXa0TnQ7O4yUeID9slg98owLwQM2sSEhEMWeC008qoYrHFFt3W2Tc/ PLYX41ry/OzcdFaflHpHlVzO7kgHBHYeupbJY6aSZ6m7pSdzMDu21tF8ZM8jt3tW52Ll YtWQ== X-Gm-Message-State: AOAM533qEH4I1ZK3FpTjJmjkuDpM8GID/WZN5ud4XDq/O0w7JKZufcul XEImY4+7g8431ZVt7vgPzmjosqaawSg= X-Google-Smtp-Source: ABdhPJyiiu6cg46PgKEDsrBYo/l1f8+TOSU/r4zhRUfpBMo+zkLAU1kMrCLgvl9s50KcMo5PMmLcCQ== X-Received: by 2002:a05:6e02:1523:: with SMTP id i3mr10268814ilu.252.1632523935869; Fri, 24 Sep 2021 15:52:15 -0700 (PDT) Received: from smtpclient.apple (c-24-11-95-247.hsd1.ut.comcast.net. [24.11.95.247]) by smtp.gmail.com with ESMTPSA id v9sm4925487ilc.16.2021.09.24.15.52.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Sep 2021 15:52:15 -0700 (PDT) Content-Type: multipart/alternative; boundary=Apple-Mail-D2E922FC-3566-4970-904E-D3790896F558 Content-Transfer-Encoding: 7bit From: Rob Sargent Mime-Version: 1.0 (1.0) Subject: Re: Using XMLNAMESPACES with XMLEMENT Date: Fri, 24 Sep 2021 16:52:14 -0600 Message-Id: <15F25C40-2929-442D-92D3-4812DDFCEBE1@gmail.com> References: <64818D06-4BD8-4D81-9C23-6BD392B85E20@lzlabs.com> Cc: pgsql-general@postgresql.org In-Reply-To: <64818D06-4BD8-4D81-9C23-6BD392B85E20@lzlabs.com> To: Garfield Lewis X-Mailer: iPhone Mail (18G82) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail-D2E922FC-3566-4970-904E-D3790896F558 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > On Sep 24, 2021, at 3:44 PM, Garfield Lewis wr= ote: >=20 > =EF=BB=BF > Hi All, > =20 > I am attempting to port the following statement from DB2z to Postgres: > =20 > 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 =3D 12; > =20 > The NAMESPACES function is not supported by Postgres in the XMLELEMENT fun= ction. Is there any way to get this to work? I=E2=80=99ve looked at the WITH= syntax but it doesn=E2=80=99t look like that will be helpful here. > =20 Which Postgres version? Have you tried path function? > Regards, > Garfield --Apple-Mail-D2E922FC-3566-4970-904E-D3790896F558 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Sep 24, 2021, at 3:44 PM, Garfield Lewis &= lt;garfield.lewis@lzlabs.com> wrote:

=EF=BB=BF

Hi Al= l,

=  

I am a= ttempting to port the following statement from DB2z to Postgres:<= /span>

=  

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

          XMLELEMENT ( NAME "foo:Emp",

  &= nbsp;         XMLNAMESPACES('http://www.foo.com' AS <= /span>"fo= o")<= /span>,

            XMLATTRIBUTES(e= .empno as "serial"),

                    &= nbsp;     e.firstnme,

                    &= nbsp;     e.lastname ) AS "Result"

       FROM EMP e

       WHERE e.edlevel =3D 12;

=  

The N= AMESPACES function is not supported by Postgres in the XMLELEMENT function. I= s there any way to get this to work? I=E2=80=99ve looked at the WITH syntax b= ut it doesn=E2=80=99t look like that will be helpful here.

=  


Which Postgre= s version?  Have you tried path function?

Regar= ds,

Garfi= eld

= --Apple-Mail-D2E922FC-3566-4970-904E-D3790896F558--