2 select query_to_xml('select 1 as x',true,false,'');
4 ---------------------------------------------------------------
5 <table xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
15 select xslt_process( query_to_xml('select x from generate_series(1,5) as
16 x',true,false,'')::text,
17 $$<xsl:stylesheet version="1.0"
18 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
19 <xsl:output method="xml" indent="yes" />
20 <xsl:template match="*">
22 <xsl:copy-of select="@*" />
23 <xsl:apply-templates />
26 <xsl:template match="comment()|processing-instruction()">
31 ERROR: xslt_process() is not available without libxslt
32 CREATE TABLE xpath_test (id integer NOT NULL, t xml);
33 INSERT INTO xpath_test VALUES (1, '<doc><int>1</int></doc>');
34 SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
40 SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
41 as t(id int4, doc int4);
47 DROP TABLE xpath_test;
48 CREATE TABLE xpath_test (id integer NOT NULL, t text);
49 INSERT INTO xpath_test VALUES (1, '<doc><int>1</int></doc>');
50 SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
56 SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
57 as t(id int4, doc int4);
63 create table articles (article_id integer, article_xml xml, date_entered date);
64 insert into articles (article_id, article_xml, date_entered)
65 values (2, '<article><author>test</author><pages>37</pages></article>', now());
67 xpath_table('article_id',
70 '/article/author|/article/pages|/article/title',
71 'date_entered > ''2003-01-01'' ')
72 AS t(article_id integer, author text, page_count integer, title text);
73 article_id | author | page_count | title
74 ------------+--------+------------+-------
78 -- this used to fail when invoked a second time
79 select xslt_process('<aaa/>',$$<xsl:stylesheet version="1.0"
80 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
81 <xsl:template match="@*|node()">
83 <xsl:apply-templates select="@*|node()"/>
86 </xsl:stylesheet>$$)::xml;
87 ERROR: xslt_process() is not available without libxslt
88 select xslt_process('<aaa/>',$$<xsl:stylesheet version="1.0"
89 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
90 <xsl:template match="@*|node()">
92 <xsl:apply-templates select="@*|node()"/>
95 </xsl:stylesheet>$$)::xml;
96 ERROR: xslt_process() is not available without libxslt
97 create table t1 (id integer, xml_data xml);
98 insert into t1 (id, xml_data)
100 (1, '<attributes><attribute name="attr_1">Some
101 Value</attribute></attributes>');
102 create index idx_xpath on t1 ( xpath_string
103 ('/attributes/attribute[@name="attr_1"]/text()', xml_data::text));
104 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">
105 <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
106 <xsl:strip-space elements="*"/>
107 <xsl:param name="n1"/>
108 <xsl:param name="n2"/>
109 <xsl:param name="n3"/>
110 <xsl:param name="n4"/>
111 <xsl:param name="n5" select="'me'"/>
112 <xsl:template match="*">
113 <xsl:element name="samples">
114 <xsl:element name="sample">
115 <xsl:value-of select="$n1"/>
117 <xsl:element name="sample">
118 <xsl:value-of select="$n2"/>
120 <xsl:element name="sample">
121 <xsl:value-of select="$n3"/>
123 <xsl:element name="sample">
124 <xsl:value-of select="$n4"/>
126 <xsl:element name="sample">
127 <xsl:value-of select="$n5"/>
129 <xsl:element name="sample">
130 <xsl:value-of select="$n6"/>
132 <xsl:element name="sample">
133 <xsl:value-of select="$n7"/>
135 <xsl:element name="sample">
136 <xsl:value-of select="$n8"/>
138 <xsl:element name="sample">
139 <xsl:value-of select="$n9"/>
141 <xsl:element name="sample">
142 <xsl:value-of select="$n10"/>
144 <xsl:element name="sample">
145 <xsl:value-of select="$n11"/>
147 <xsl:element name="sample">
148 <xsl:value-of select="$n12"/>
152 </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);
153 ERROR: xslt_process() is not available without libxslt
154 -- possible security exploit
155 SELECT xslt_process('<xml><foo>Hello from XML</foo></xml>',
156 $$<xsl:stylesheet version="1.0"
157 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
158 xmlns:sax="http://icl.com/saxon"
159 extension-element-prefixes="sax">
161 <xsl:template match="//foo">
162 <sax:output href="0wn3d.txt" method="text">
163 <xsl:value-of select="'0wn3d via xml2 extension and libxslt'"/>
164 <xsl:apply-templates/>
167 </xsl:stylesheet>$$);
168 ERROR: xslt_process() is not available without libxslt