1
+ (:
2
+ : eXist-db Open Source Native XML Database
3
+ : Copyright (C) 2001 The eXist-db Authors
4
+ :
5
+
6
+ : http://www.exist-db.org
7
+ :
8
+ : This library is free software; you can redistribute it and/or
9
+ : modify it under the terms of the GNU Lesser General Public
10
+ : License as published by the Free Software Foundation; either
11
+ : version 2.1 of the License, or (at your option) any later version.
12
+ :
13
+ : This library is distributed in the hope that it will be useful,
14
+ : but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ : Lesser General Public License for more details.
17
+ :
18
+ : You should have received a copy of the GNU Lesser General Public
19
+ : License along with this library; if not, write to the Free Software
20
+ : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
+ :)
22
+ xquery version "3.1" ;
23
+
24
+ module namespace rt = "http://exist-db.org/xquery/test/fn-root" ;
25
+
26
+ declare namespace test = "http://exist-db.org/xquery/xqsuite" ;
27
+
28
+ declare
29
+ %test:assertEquals("true" , "false" , "false" )
30
+ function rt:memtree-document () {
31
+ let $x := document {()}
32
+ return
33
+ (
34
+ $x/root () instance of document-node (),
35
+ $x/ancestor::node () instance of document-node (),
36
+ $x/parent::node () instance of document-node ()
37
+ )
38
+ };
39
+
40
+ declare
41
+ %test:assertEquals("false" , "true" , "false" , "false" , "false" , "false" )
42
+ function rt:memtree-element () {
43
+ let $x := element e1{}
44
+ return
45
+ (
46
+ $x/root () instance of document-node (),
47
+ $x/root () instance of element (),
48
+ $x/ancestor::node () instance of document-node (),
49
+ $x/ancestor::node () instance of element (),
50
+ $x/parent::node () instance of document-node (),
51
+ $x/parent::node () instance of element ()
52
+ )
53
+ };
54
+
55
+ declare
56
+ %test:assertEquals("false" , "true" , "false" , "false" , "false" , "false" )
57
+ function rt:memtree-attribute () {
58
+ let $x := attribute a1{ "a1" }
59
+ return
60
+ (
61
+ $x/root () instance of document-node (),
62
+ $x/root () instance of attribute (),
63
+ $x/ancestor::node () instance of document-node (),
64
+ $x/ancestor::node () instance of attribute (),
65
+ $x/parent::node () instance of document-node (),
66
+ $x/parent::node () instance of attribute ()
67
+ )
68
+ };
69
+
70
+ declare
71
+ %test:assertEquals("false" , "true" , "false" , "false" , "false" , "false" )
72
+ function rt:memtree-comment () {
73
+ let $x := comment { "c1" }
74
+ return
75
+ (
76
+ $x/root () instance of document-node (),
77
+ $x/root () instance of comment (),
78
+ $x/ancestor::node () instance of document-node (),
79
+ $x/ancestor::node () instance of comment (),
80
+ $x/parent::node () instance of document-node (),
81
+ $x/parent::node () instance of comment ()
82
+ )
83
+ };
84
+
85
+ declare
86
+ %test:assertEquals("false" , "true" , "false" , "false" , "false" , "false" )
87
+ function rt:memtree-processing-instruction () {
88
+ let $x := processing-instruction p1 { "p1" }
89
+ return
90
+ (
91
+ $x/root () instance of document-node (),
92
+ $x/root () instance of processing-instruction (),
93
+ $x/ancestor::node () instance of document-node (),
94
+ $x/ancestor::node () instance of processing-instruction (),
95
+ $x/parent::node () instance of document-node (),
96
+ $x/parent::node () instance of processing-instruction ()
97
+ )
98
+ };
99
+
100
+ declare
101
+ %test:assertEquals("false" , "true" , "false" , "false" , "false" , "false" )
102
+ function rt:memtree-text () {
103
+ let $x := text { "t1" }
104
+ return
105
+ (
106
+ $x/root () instance of document-node (),
107
+ $x/root () instance of text (),
108
+ $x/ancestor::node () instance of document-node (),
109
+ $x/ancestor::node () instance of text (),
110
+ $x/parent::node () instance of document-node (),
111
+ $x/parent::node () instance of text ()
112
+ )
113
+ };
114
+
115
+ declare
116
+ %test:assertEquals("false" , "true" , "false" , "true" , "false" , "true" )
117
+ function rt:memtree-element-in-element () {
118
+ let $x := element e1 {
119
+ element e2{}
120
+ }
121
+ return
122
+ (
123
+ root ($x/e2) instance of document-node (),
124
+ root ($x/e2) instance of element (),
125
+ $x/e2/ancestor::node () instance of document-node (),
126
+ $x/e2/ancestor::node () instance of element (),
127
+ $x/e2/parent::node () instance of document-node (),
128
+ $x/e2/parent::node () instance of element ()
129
+ )
130
+ };
131
+
132
+ declare
133
+ %test:assertEquals("false" , "true" , "false" , "false" , "true" , "false" , "false" , "true" , "false" )
134
+ function rt:memtree-attribute-in-element () {
135
+ let $x := element e1 {
136
+ attribute lang { "en" }
137
+ }
138
+ return
139
+ (
140
+ root ($x/@lang) instance of document-node (),
141
+ root ($x/@lang) instance of element (),
142
+ root ($x/@lang) instance of attribute (),
143
+ $x/@lang/ancestor::node () instance of document-node (),
144
+ $x/@lang/ancestor::node () instance of element (),
145
+ $x/@lang/ancestor::node () instance of attribute (),
146
+ $x/@lang/parent::node () instance of document-node (),
147
+ $x/@lang/parent::node () instance of element (),
148
+ $x/@lang/parent::node () instance of attribute ()
149
+ )
150
+ };
151
+
152
+ declare
153
+ %test:assertEquals("false" , "true" , "false" , "false" , "true" , "false" , "false" , "true" , "false" )
154
+ function rt:memtree-comment-in-element () {
155
+ let $x := element e1 {
156
+ comment { "c1" }
157
+ }
158
+ return
159
+ (
160
+ root ($x/comment ()) instance of document-node (),
161
+ root ($x/comment ()) instance of element (),
162
+ root ($x/comment ()) instance of comment (),
163
+ $x/comment ()/ancestor::node () instance of document-node (),
164
+ $x/comment ()/ancestor::node () instance of element (),
165
+ $x/comment ()/ancestor::node () instance of comment (),
166
+ $x/comment ()/parent::node () instance of document-node (),
167
+ $x/comment ()/parent::node () instance of element (),
168
+ $x/comment ()/parent::node () instance of comment ()
169
+ )
170
+ };
171
+
172
+ declare
173
+ %test:assertEquals("false" , "true" , "false" , "false" , "true" , "false" , "false" , "true" , "false" )
174
+ function rt:memtree-processing-instruction-in-element () {
175
+ let $x := element e1 {
176
+ processing-instruction p1 { "p1" }
177
+ }
178
+ return
179
+ (
180
+ root ($x/processing-instruction ()) instance of document-node (),
181
+ root ($x/processing-instruction ()) instance of element (),
182
+ root ($x/processing-instruction ()) instance of processing-instruction (),
183
+ $x/processing-instruction ()/ancestor::node () instance of document-node (),
184
+ $x/processing-instruction ()/ancestor::node () instance of element (),
185
+ $x/processing-instruction ()/ancestor::node () instance of processing-instruction (),
186
+ $x/processing-instruction ()/parent::node () instance of document-node (),
187
+ $x/processing-instruction ()/parent::node () instance of element (),
188
+ $x/processing-instruction ()/parent::node () instance of processing-instruction ()
189
+ )
190
+ };
191
+
192
+ declare
193
+ %test:assertEquals("false" , "true" , "false" , "false" , "true" , "false" , "false" , "true" , "false" )
194
+ function rt:memtree-text-in-element () {
195
+ let $x := element e1 {
196
+ text { "t1" }
197
+ }
198
+ return
199
+ (
200
+ root ($x/text ()) instance of document-node (),
201
+ root ($x/text ()) instance of element (),
202
+ root ($x/text ()) instance of text (),
203
+ $x/text ()/ancestor::node () instance of document-node (),
204
+ $x/text ()/ancestor::node () instance of element (),
205
+ $x/text ()/ancestor::node () instance of text (),
206
+ $x/text ()/parent::node () instance of document-node (),
207
+ $x/text ()/parent::node () instance of element (),
208
+ $x/text ()/parent::node () instance of text ()
209
+ )
210
+ };
0 commit comments