~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to contrib/xml2/expected/xml2_1.out

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
CREATE EXTENSION xml2;
 
2
select query_to_xml('select 1 as x',true,false,'');
 
3
                         query_to_xml                          
 
4
---------------------------------------------------------------
 
5
 <table xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
 
6
                                                              +
 
7
 <row>                                                        +
 
8
   <x>1</x>                                                   +
 
9
 </row>                                                       +
 
10
                                                              +
 
11
 </table>                                                     +
 
12
 
 
13
(1 row)
 
14
 
 
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="*">
 
21
  <xsl:copy>
 
22
     <xsl:copy-of select="@*" />
 
23
     <xsl:apply-templates />
 
24
  </xsl:copy>
 
25
</xsl:template>
 
26
<xsl:template match="comment()|processing-instruction()">
 
27
  <xsl:copy />
 
28
</xsl:template>
 
29
</xsl:stylesheet>
 
30
$$::text);
 
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')
 
35
as t(id int4);
 
36
 id 
 
37
----
 
38
(0 rows)
 
39
 
 
40
SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
 
41
as t(id int4, doc int4);
 
42
 id | doc 
 
43
----+-----
 
44
  1 |   1
 
45
(1 row)
 
46
 
 
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')
 
51
as t(id int4);
 
52
 id 
 
53
----
 
54
(0 rows)
 
55
 
 
56
SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true')
 
57
as t(id int4, doc int4);
 
58
 id | doc 
 
59
----+-----
 
60
  1 |   1
 
61
(1 row)
 
62
 
 
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());
 
66
SELECT * FROM
 
67
xpath_table('article_id',
 
68
            'article_xml',
 
69
            'articles',
 
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
------------+--------+------------+-------
 
75
          2 | test   |         37 | 
 
76
(1 row)
 
77
 
 
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()">
 
82
      <xsl:copy>
 
83
         <xsl:apply-templates select="@*|node()"/>
 
84
      </xsl:copy>
 
85
   </xsl:template>
 
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()">
 
91
      <xsl:copy>
 
92
         <xsl:apply-templates select="@*|node()"/>
 
93
      </xsl:copy>
 
94
   </xsl:template>
 
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)
 
99
values
 
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"/>
 
116
      </xsl:element>
 
117
      <xsl:element name="sample">
 
118
        <xsl:value-of select="$n2"/>
 
119
      </xsl:element>
 
120
      <xsl:element name="sample">
 
121
        <xsl:value-of select="$n3"/>
 
122
      </xsl:element>
 
123
      <xsl:element name="sample">
 
124
        <xsl:value-of select="$n4"/>
 
125
      </xsl:element>
 
126
      <xsl:element name="sample">
 
127
        <xsl:value-of select="$n5"/>
 
128
      </xsl:element>
 
129
      <xsl:element name="sample">
 
130
        <xsl:value-of select="$n6"/>
 
131
      </xsl:element>
 
132
      <xsl:element name="sample">
 
133
        <xsl:value-of select="$n7"/>
 
134
      </xsl:element>
 
135
      <xsl:element name="sample">
 
136
        <xsl:value-of select="$n8"/>
 
137
      </xsl:element>
 
138
      <xsl:element name="sample">
 
139
        <xsl:value-of select="$n9"/>
 
140
      </xsl:element>
 
141
      <xsl:element name="sample">
 
142
        <xsl:value-of select="$n10"/>
 
143
      </xsl:element>
 
144
      <xsl:element name="sample">
 
145
        <xsl:value-of select="$n11"/>
 
146
      </xsl:element>
 
147
      <xsl:element name="sample">
 
148
        <xsl:value-of select="$n12"/>
 
149
      </xsl:element>
 
150
    </xsl:element>
 
151
  </xsl:template>
 
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