2 -- first, define the functions. Turn off echoing so that expected file
3 -- does not depend on contents of pgxml.sql.
5 SET client_min_messages = warning;
9 RESET client_min_messages;
11 select query_to_xml('select 1 as x',true,false,'');
13 select xslt_process( query_to_xml('select x from generate_series(1,5) as
14 x',true,false,'')::text,
15 $$<xsl:stylesheet version="1.0"
16 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
17 <xsl:output method="xml" indent="yes" />
18 <xsl:template match="*">
20 <xsl:copy-of select="@*" />
21 <xsl:apply-templates />
24 <xsl:template match="comment()|processing-instruction()">
30 CREATE TABLE xpath_test (id integer NOT NULL, t xml);
31 INSERT INTO xpath_test VALUES (1, '<doc><int>1</int></doc>');
32 SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
34 SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
35 as t(id int4, doc int4);
37 DROP TABLE xpath_test;
38 CREATE TABLE xpath_test (id integer NOT NULL, t text);
39 INSERT INTO xpath_test VALUES (1, '<doc><int>1</int></doc>');
40 SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
42 SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
43 as t(id int4, doc int4);
45 create table articles (article_id integer, article_xml xml, date_entered date);
46 insert into articles (article_id, article_xml, date_entered)
47 values (2, '<article><author>test</author><pages>37</pages></article>', now());
49 xpath_table('article_id',
52 '/article/author|/article/pages|/article/title',
53 'date_entered > ''2003-01-01'' ')
54 AS t(article_id integer, author text, page_count integer, title text);
56 -- this used to fail when invoked a second time
57 select xslt_process('<aaa/>',$$<xsl:stylesheet version="1.0"
58 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
59 <xsl:template match="@*|node()">
61 <xsl:apply-templates select="@*|node()"/>
64 </xsl:stylesheet>$$)::xml;
66 select xslt_process('<aaa/>',$$<xsl:stylesheet version="1.0"
67 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
68 <xsl:template match="@*|node()">
70 <xsl:apply-templates select="@*|node()"/>
73 </xsl:stylesheet>$$)::xml;
75 create table t1 (id integer, xml_data xml);
76 insert into t1 (id, xml_data)
78 (1, '<attributes><attribute name="attr_1">Some
79 Value</attribute></attributes>');
81 create index idx_xpath on t1 ( xpath_string
82 ('/attributes/attribute[@name="attr_1"]/text()', xml_data::text));