xml2: add test for coverage
Hi, hackers
I made a small patch for xml2 to improve test coverage.
However, there was a problem using the functions below.
- xpath_number
- xpath_bool
- xpath_nodeset
- xpath_list
Do you have any advice on how to use this function correctly?
It would also be good to add an example of using the function to the document.
---
Regards,
DongWook Lee.
Attachments:
v1_add_test_xml2.patchapplication/octet-stream; name=v1_add_test_xml2.patchDownload
From e286783c61d24e4eb9bde056da6a76a21aab6afa Mon Sep 17 00:00:00 2001
From: Lee Dong Wook <sh95119@gmail.com>
Date: Mon, 22 Aug 2022 22:42:38 +0900
Subject: [PATCH] xml2: add test for coverage
---
contrib/xml2/expected/xml2.out | 36 ++++++++++++++++++++++++++++++++++
contrib/xml2/sql/xml2.sql | 8 ++++++++
2 files changed, 44 insertions(+)
diff --git a/contrib/xml2/expected/xml2.out b/contrib/xml2/expected/xml2.out
index eba6ae603649..dd88e1747e30 100644
--- a/contrib/xml2/expected/xml2.out
+++ b/contrib/xml2/expected/xml2.out
@@ -88,6 +88,18 @@ as t(id int4, doc int4);
1 | 1
(1 row)
+select * from xml_valid('xpath_test');
+ xml_valid
+-----------
+ t
+(1 row)
+
+select xml_encode_special_chars('<doc><int>1</int></doc>');
+ xml_encode_special_chars
+-------------------------------------------------
+ <doc><int>1</int></doc>
+(1 row)
+
create table articles (article_id integer, article_xml xml, date_entered date);
insert into articles (article_id, article_xml, date_entered)
values (2, '<article><author>test</author><pages>37</pages></article>', now());
@@ -139,6 +151,30 @@ values
Value</attribute></attributes>');
create index idx_xpath on t1 ( xpath_string
('/attributes/attribute[@name="attr_1"]/text()', xml_data::text));
+select xpath_number('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+ xpath_number
+--------------
+
+(1 row)
+
+select xpath_bool('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+ xpath_bool
+------------
+ f
+(1 row)
+
+select xpath_nodeset('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+ xpath_nodeset
+---------------
+
+(1 row)
+
+select xpath_list('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+ xpath_list
+------------
+
+(1 row)
+
SELECT xslt_process('<employee><name>cim</name><age>30</age><pay>400</pay></employee>'::text, $$<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
diff --git a/contrib/xml2/sql/xml2.sql b/contrib/xml2/sql/xml2.sql
index ac49cfa7c523..2f1c2614f231 100644
--- a/contrib/xml2/sql/xml2.sql
+++ b/contrib/xml2/sql/xml2.sql
@@ -34,6 +34,9 @@ as t(id int4);
SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
as t(id int4, doc int4);
+select * from xml_valid('xpath_test');
+select xml_encode_special_chars('<doc><int>1</int></doc>');
+
create table articles (article_id integer, article_xml xml, date_entered date);
insert into articles (article_id, article_xml, date_entered)
values (2, '<article><author>test</author><pages>37</pages></article>', now());
@@ -73,6 +76,11 @@ Value</attribute></attributes>');
create index idx_xpath on t1 ( xpath_string
('/attributes/attribute[@name="attr_1"]/text()', xml_data::text));
+select xpath_number('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+select xpath_bool('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+select xpath_nodeset('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+select xpath_list('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1;
+
SELECT xslt_process('<employee><name>cim</name><age>30</age><pay>400</pay></employee>'::text, $$<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
On 23.08.22 03:38, Dong Wook Lee wrote:
I made a small patch for xml2 to improve test coverage.
However, there was a problem using the functions below.- xpath_number
- xpath_bool
- xpath_nodeset
- xpath_listDo you have any advice on how to use this function correctly?
It would also be good to add an example of using the function to the document.
I can confirm that these functions could use more tests and more
documentation and examples. But given that you registered a patch in
the commit fest, it should be you who provides a patch to solve those
issues. Are you still working on this, or were you just looking for
help on how to solve this?
On Fri, 25 Nov 2022 at 18:08, Peter Eisentraut
<peter.eisentraut@enterprisedb.com> wrote:
On 23.08.22 03:38, Dong Wook Lee wrote:
I made a small patch for xml2 to improve test coverage.
However, there was a problem using the functions below.- xpath_number
- xpath_bool
- xpath_nodeset
- xpath_listDo you have any advice on how to use this function correctly?
It would also be good to add an example of using the function to the document.I can confirm that these functions could use more tests and more
documentation and examples. But given that you registered a patch in
the commit fest, it should be you who provides a patch to solve those
issues. Are you still working on this, or were you just looking for
help on how to solve this?
Hi DongWook Lee,
Are you planning to work on this and provide an updated patch, if you
are not planning to work on it, we can update the commitfest entry
accordingly.
Regards,
Vignesh
On Tue, 17 Jan 2023 at 17:06, vignesh C <vignesh21@gmail.com> wrote:
On Fri, 25 Nov 2022 at 18:08, Peter Eisentraut
<peter.eisentraut@enterprisedb.com> wrote:On 23.08.22 03:38, Dong Wook Lee wrote:
I made a small patch for xml2 to improve test coverage.
However, there was a problem using the functions below.- xpath_number
- xpath_bool
- xpath_nodeset
- xpath_listDo you have any advice on how to use this function correctly?
It would also be good to add an example of using the function to the document.I can confirm that these functions could use more tests and more
documentation and examples. But given that you registered a patch in
the commit fest, it should be you who provides a patch to solve those
issues. Are you still working on this, or were you just looking for
help on how to solve this?Hi DongWook Lee,
Are you planning to work on this and provide an updated patch, if you
are not planning to work on it, we can update the commitfest entry
accordingly.
There has been no updates on this thread for some time, so this has
been switched as Returned with Feedback. Feel free to open it in the
next commitfest if you plan to continue on this.
Regards,
Vignesh