diff options
author | Michael Paquier | 2024-11-14 04:10:36 +0000 |
---|---|---|
committer | Michael Paquier | 2024-11-14 04:10:36 +0000 |
commit | 93f9b4a93fef5dad585531692f53e42d6e9f7caf (patch) | |
tree | fa97806117ba769432a0297fec03b0d3f77b9755 /contrib/xml2/sql | |
parent | 3ef038fc4f763f8f6a77c5b3406ab7d837c51c4d (diff) |
xml2: Add tests for functions xpath_nodeset() and xpath_list()
These two functions with their different argument lists have never been
tested in this module, so let's add something.
Author: Ronan Dunklau
Discussion: https://postgr.es/m/ZzMSJkiNZhimjXWx@paquier.xyz
Diffstat (limited to 'contrib/xml2/sql')
-rw-r--r-- | contrib/xml2/sql/xml2.sql | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/contrib/xml2/sql/xml2.sql b/contrib/xml2/sql/xml2.sql index ac49cfa7c52..ef99d164f27 100644 --- a/contrib/xml2/sql/xml2.sql +++ b/contrib/xml2/sql/xml2.sql @@ -123,6 +123,22 @@ SELECT xslt_process('<employee><name>cim</name><age>30</age><pay>400</pay></empl </xsl:template> </xsl:stylesheet>$$::text, 'n1="v1",n2="v2",n3="v3",n4="v4",n5="v5",n6="v6",n7="v7",n8="v8",n9="v9",n10="v10",n11="v11",n12="v12"'::text); +-- xpath_nodeset() +SELECT xpath_nodeset(article_xml::text, '/article/author|/article/pages') + FROM articles; +SELECT xpath_nodeset(article_xml::text, '/article/author|/article/pages', + 'item_without_toptag') + FROM articles; +SELECT xpath_nodeset(article_xml::text, '/article/author|/article/pages', + 'result', 'item') + FROM articles; + +-- xpath_list() +SELECT xpath_list(article_xml::text, '/article/author|/article/pages') + FROM articles; +SELECT xpath_list(article_xml::text, '/article/author|/article/pages', '|') + FROM articles; + -- possible security exploit SELECT xslt_process('<xml><foo>Hello from XML</foo></xml>', $$<xsl:stylesheet version="1.0" |