--
-- first, define the functions. Turn off echoing so that expected file
-- does not depend on contents of pgxml.sql.
--
SET client_min_messages = warning;
\set ECHO none
RESET client_min_messages;
select xslt_process(
'
'::text,
$$
$$::text);
xslt_process
---------------------------------------------------------------
(1 row)
CREATE TABLE xpath_test (id integer NOT NULL, t text);
INSERT INTO xpath_test VALUES (1, '1');
SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
as t(id int4);
id
----
(0 rows)
SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
as t(id int4, doc int4);
id | doc
----+-----
1 | 1
(1 row)
create table articles (article_id integer, article_xml text, date_entered date);
insert into articles (article_id, article_xml, date_entered)
values (2, 'test37', now());
SELECT * FROM
xpath_table('article_id',
'article_xml',
'articles',
'/article/author|/article/pages|/article/title',
'date_entered > ''2003-01-01'' ')
AS t(article_id integer, author text, page_count integer, title text);
article_id | author | page_count | title
------------+--------+------------+-------
2 | test | 37 |
(1 row)
-- this used to fail when invoked a second time
select xslt_process('',$$
$$);
xslt_process
-----------------------
(1 row)
select xslt_process('',$$
$$);
xslt_process
-----------------------
(1 row)
create table t1 (id integer, xml_data text);
insert into t1 (id, xml_data)
values
(1, 'Some
Value');
create index idx_xpath on t1 ( xpath_string
('/attributes/attribute[@name="attr_1"]/text()', xml_data));