Re: XML/XPath issues: text/CDATA in XMLTABLE, XPath evaluated withwrong context - Mailing list pgsql-hackers
From | Ramanarayana |
---|---|
Subject | Re: XML/XPath issues: text/CDATA in XMLTABLE, XPath evaluated withwrong context |
Date | |
Msg-id | CAKm4Xs7v6RiLLbOO-gu3Av5z4R1dDKTJvZKgUa-Sn-5Gu08y4w@mail.gmail.com Whole thread Raw |
In response to | Re: XML/XPath issues: text/CDATA in XMLTABLE, XPath evaluated withwrong context (Pavel Stehule <pavel.stehule@gmail.com>) |
Responses |
Re: XML/XPath issues: text/CDATA in XMLTABLE, XPath evaluated withwrong context
|
List | pgsql-hackers |
Hi,
The below statement needs to be executed before running the query to replicate the issue
update xmldata set data = regexp_replace(data::text, '791', '<!--ah-->7<!--oh-->9<!--uh-->1')::xml;
On Thu, 28 Feb 2019 at 17:55, Pavel Stehule <pavel.stehule@gmail.com> wrote:
čt 28. 2. 2019 v 10:31 odesílatel Pavel Stehule <pavel.stehule@gmail.com> napsal:čt 28. 2. 2019 v 9:58 odesílatel Ramanarayana <raam.soft@gmail.com> napsal:The other two issues are resolved by this patch.Hi,I have tested the three issues fixed in patch 001. Array Indexes issue is still there.Running the following query returns ERROR: more than one value returned by column XPath expressionSELECT xmltable.*
FROM (SELECT data FROM xmldata) x,
LATERAL XMLTABLE('/ROWS/ROW'
PASSING data
COLUMNS
country_name text PATH 'COUNTRY_NAME/text()' NOT NULL,
size_text float PATH 'SIZE/text()',
size_text_1 float PATH 'SIZE/text()[1]',
size_text_2 float PATH 'SIZE/text()[2]',
"SIZE" float, size_xml xml PATH 'SIZE')I tested xmltable-xpath-result-processing-bugfix-6.patchand it is workingpostgres=# SELECT xmltable.*
postgres-# FROM (SELECT data FROM xmldata) x,
postgres-# LATERAL XMLTABLE('/ROWS/ROW'
postgres(# PASSING data
postgres(# COLUMNS
postgres(# country_name text PATH 'COUNTRY_NAME/text()' NOT NULL,
postgres(# size_text float PATH 'SIZE/text()',
postgres(# size_text_1 float PATH 'SIZE/text()[1]',
postgres(# size_text_2 float PATH 'SIZE/text()[2]',
postgres(# "SIZE" float, size_xml xml PATH 'SIZE') ;
┌──────────────┬───────────┬─────────────┬─────────────┬──────┬────────────────────────────┐
│ country_name │ size_text │ size_text_1 │ size_text_2 │ SIZE │ size_xml │
╞══════════════╪═══════════╪═════════════╪═════════════╪══════╪════════════════════════════╡
│ Australia │ ∅ │ ∅ │ ∅ │ ∅ │ ∅ │
│ China │ ∅ │ ∅ │ ∅ │ ∅ │ ∅ │
│ HongKong │ ∅ │ ∅ │ ∅ │ ∅ │ ∅ │
│ India │ ∅ │ ∅ │ ∅ │ ∅ │ ∅ │
│ Japan │ ∅ │ ∅ │ ∅ │ ∅ │ ∅ │
│ Singapore │ 791 │ 791 │ ∅ │ 791 │ <SIZE unit="km">791</SIZE> │
└──────────────┴───────────┴─────────────┴─────────────┴──────┴────────────────────────────┘
(6 rows)RegardsPavelwhat patches you are used?RegardsPavel--Cheers
Ram 4.0
Cheers
Ram 4.0
Ram 4.0
pgsql-hackers by date: