pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #16332: The xmltable function returns 'comment()' as unusable xml appended together and having no xml tags
2+ messages / 2 participants
[nested] [flat]

* BUG #16332: The xmltable function returns 'comment()' as unusable xml appended together and having no xml tags
@ 2020-04-01 15:20  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2020-04-01 15:20 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: david_sisson@dell.com

The following bug has been logged on the website:

Bug reference:      16332
Logged by:          David Sisson
Email address:      david_sisson@dell.com
PostgreSQL version: 11.6
Operating system:   Windows 10
Description:        

We are trying to use the new faster "xmltable" feature in PostgreSQL to read
XML files.
We have to be able to read and parse commented out sections of the xml
files.
Without being able to read and parse XML comments we won't be able to use
this.

(full sample below)

When using this:  comments xml path 'comment()'

We are getting this:  
&lt;Attribute Name="Test Comment 001"&gt;Testing comment
001&lt;/Attribute&gt;  &lt;Attribute Name="Test Comment 002"&gt;Testing
comment 002&lt;/Attribute&gt;  &lt;Attribute Name="Test Comment
002"&gt;Testing comment 003&lt;/Attribute&gt;"


As with everything else I would have expected to get the result as readable
xml.


It works for elements just not for comments.
For example this:    attribute_xml xml path 'Attribute/self::node()',

Returns this which we can use.
"<Attribute Name="TestAttribute001">attribute element value
001</Attribute><Attribute Name="TestAttribute002">attribute element value
002</Attribute><Attribute Name="TestAttribute003">attribute element value
003</Attribute>"


with 
_xml(raw_xml) as
(
	select
	'
	<SystemConfiguration Model="Test01">
	
	<Component Name="Test 001">
	 <Attribute Name="TestAttribute001">attribute element value
001</Attribute>
	 <Attribute Name="TestAttribute002">attribute element value
002</Attribute>
	 <!--  <Attribute Name="Test Comment 001">Testing comment
001</Attribute>-->	 
	 <!--  <Attribute Name="Test Comment 002">Testing comment
002</Attribute>-->
	 <!--  <Attribute Name="Test Comment 002">Testing comment
003</Attribute>-->
	 <Attribute Name="TestAttribute003">attribute element value
003</Attribute>
	</Component>
	</SystemConfiguration>
	'::xml
),
_components(name, attribute_xml, comment_xml) as
(
	select 
		root_components.fqdd,
		root_components.attribute_xml,
		root_components.comments
	from
		_xml,			
		xmltable
		(
			'//SystemConfiguration/Component'
			passing raw_xml
			columns
				fqdd text path '@Name',
				attribute_xml xml path 'Attribute/self::node()',
				comments xml path 'comment()'
		) as root_components
	
	
)
select * from _components



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #16332: The xmltable function returns 'comment()' as unusable xml appended together and having no xml tags
@ 2020-04-01 16:12  Pavel Stehule <pavel.stehule@gmail.com>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Pavel Stehule @ 2020-04-01 16:12 UTC (permalink / raw)
  To: david_sisson@dell.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

st 1. 4. 2020 v 18:07 odesílatel PG Bug reporting form <
noreply@postgresql.org> napsal:

> The following bug has been logged on the website:
>
> Bug reference:      16332
> Logged by:          David Sisson
> Email address:      david_sisson@dell.com
> PostgreSQL version: 11.6
> Operating system:   Windows 10
> Description:
>

please, check Postgres 12. This issue is fixed there

Regards

Pavel


> We are trying to use the new faster "xmltable" feature in PostgreSQL to
> read
> XML files.
> We have to be able to read and parse commented out sections of the xml
> files.
> Without being able to read and parse XML comments we won't be able to use
> this.
>
> (full sample below)
>
> When using this:  comments xml path 'comment()'
>
> We are getting this:
> &lt;Attribute Name="Test Comment 001"&gt;Testing comment
> 001&lt;/Attribute&gt;  &lt;Attribute Name="Test Comment 002"&gt;Testing
> comment 002&lt;/Attribute&gt;  &lt;Attribute Name="Test Comment
> 002"&gt;Testing comment 003&lt;/Attribute&gt;"
>
>
> As with everything else I would have expected to get the result as readable
> xml.
>
>
> It works for elements just not for comments.
> For example this:    attribute_xml xml path 'Attribute/self::node()',
>
> Returns this which we can use.
> "<Attribute Name="TestAttribute001">attribute element value
> 001</Attribute><Attribute Name="TestAttribute002">attribute element value
> 002</Attribute><Attribute Name="TestAttribute003">attribute element value
> 003</Attribute>"
>
>
> with
> _xml(raw_xml) as
> (
>         select
>         '
>         <SystemConfiguration Model="Test01">
>
>         <Component Name="Test 001">
>          <Attribute Name="TestAttribute001">attribute element value
> 001</Attribute>
>          <Attribute Name="TestAttribute002">attribute element value
> 002</Attribute>
>          <!--  <Attribute Name="Test Comment 001">Testing comment
> 001</Attribute>-->
>          <!--  <Attribute Name="Test Comment 002">Testing comment
> 002</Attribute>-->
>          <!--  <Attribute Name="Test Comment 002">Testing comment
> 003</Attribute>-->
>          <Attribute Name="TestAttribute003">attribute element value
> 003</Attribute>
>         </Component>
>         </SystemConfiguration>
>         '::xml
> ),
> _components(name, attribute_xml, comment_xml) as
> (
>         select
>                 root_components.fqdd,
>                 root_components.attribute_xml,
>                 root_components.comments
>         from
>                 _xml,
>                 xmltable
>                 (
>                         '//SystemConfiguration/Component'
>                         passing raw_xml
>                         columns
>                                 fqdd text path '@Name',
>                                 attribute_xml xml path
> 'Attribute/self::node()',
>                                 comments xml path 'comment()'
>                 ) as root_components
>
>
> )
> select * from _components
>
>

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2020-04-01 16:12 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01 15:20 BUG #16332: The xmltable function returns 'comment()' as unusable xml appended together and having no xml tags PG Bug reporting form <noreply@postgresql.org>
2020-04-01 16:12 ` Pavel Stehule <pavel.stehule@gmail.com>

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