summaryrefslogtreecommitdiff
path: root/test/testcases/tests/level3/xpath/Conformance_Expressions.xml
blob: d3d1f38b7b89930258aec16b3f1d04d54951b08c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="test-to-html.xsl" type="text/xml"?>
<!--
 Copyright (c) 2003 World Wide Web Consortium,

 (Massachusetts Institute of Technology, European Research Consortium for
 Informatics and Mathematics, Keio University). All Rights Reserved. This
 work is distributed under the W3C(r) Software License [1] in the hope that
 it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
-->

<!DOCTYPE test SYSTEM "dom3.dtd" [
  <!ENTITY % entities SYSTEM "dom3xpathents.ent">
  %entities;
]>
<test xmlns="&level3;" name="Conformance_Expressions">
  <metadata>
    <title>Conformance_Expressions</title>
    <creator>Bob Clary</creator>
    <description>
      1.3 Conformance - Iterate over a list of strings containing 
      valid XPath expressions, calling XPathEvaluator.createExpression 
      for each. If no expections are thrown and each result is non-null, 
      then the test passes.
    </description>
    <date qualifier="created">2003-11-18</date>
    <subject resource="&spec;#Conformance"/>
    <subject resource="&spec;#XPathEvaluator"/>
    <subject resource="&spec;#XPathEvaluator-createNSResolver"/>
    <subject resource="&spec;#XPathEvaluator-createExpression"/>
    <subject resource="&spec;#XPathNSResolver"/>
  </metadata>

  <!-- Standard Variables -->

  <var name="doc"         type="Document"/>
  <var name="resolver"    type="XPathNSResolver"/>
  <var name="evaluator"   type="XPathEvaluator"/>

  <!-- Inputs -->

  <var name="expression"           type="DOMString"/>

  <!-- Test Variables -->

  <var name="expressionList"       type="List"/>
  <var name="xpathexpression"      type="XPathExpression"/>

  <load var="doc" href="staffNS" willBeModified="false"/>

  <createXPathEvaluator var='evaluator' document='doc'/>

  <createNSResolver var="resolver" obj="evaluator" nodeResolver="doc"/>

  <!-- test root absolute expression -->
  <append collection="expressionList" item="&quot;/&quot;"/>

  <!-- test verbose axes and basic node tests -->
  <append collection="expressionList" item="&quot;child::comment()&quot;"/>
  <append collection="expressionList" item="&quot;child::text()&quot;"/>
  <append collection="expressionList" item="&quot;child::processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;child::processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;child::node()&quot;"/>
  <append collection="expressionList" item="&quot;child::*&quot;"/>
  <append collection="expressionList" item="&quot;child::nist:*&quot;"/>
  <append collection="expressionList" item="&quot;child::employee&quot;"/>

  <append collection="expressionList" item="&quot;descendant::comment()&quot;"/>
  <append collection="expressionList" item="&quot;descendant::text()&quot;"/>
  <append collection="expressionList" item="&quot;descendant::processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;descendant::processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;descendant::node()&quot;"/>
  <append collection="expressionList" item="&quot;descendant::*&quot;"/>
  <append collection="expressionList" item="&quot;descendant::nist:*&quot;"/>
  <append collection="expressionList" item="&quot;descendant::employee&quot;"/>

  <append collection="expressionList" item="&quot;parent::comment()&quot;"/>
  <append collection="expressionList" item="&quot;parent::text()&quot;"/>
  <append collection="expressionList" item="&quot;parent::processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;parent::processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;parent::node()&quot;"/>
  <append collection="expressionList" item="&quot;parent::*&quot;"/>
  <append collection="expressionList" item="&quot;parent::nist:*&quot;"/>
  <append collection="expressionList" item="&quot;parent::employee&quot;"/>

  <append collection="expressionList" item="&quot;ancestor::comment()&quot;"/>
  <append collection="expressionList" item="&quot;ancestor::text()&quot;"/>
  <append collection="expressionList" item="&quot;ancestor::processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;ancestor::processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;ancestor::node()&quot;"/>
  <append collection="expressionList" item="&quot;ancestor::*&quot;"/>
  <append collection="expressionList" item="&quot;ancestor::nist:*&quot;"/>
  <append collection="expressionList" item="&quot;ancestor::employee&quot;"/>

  <append collection="expressionList" item="&quot;following-sibling::comment()&quot;"/>
  <append collection="expressionList" item="&quot;following-sibling::text()&quot;"/>
  <append collection="expressionList" item="&quot;following-sibling::processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;following-sibling::processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;following-sibling::node()&quot;"/>
  <append collection="expressionList" item="&quot;following-sibling::*&quot;"/>
  <append collection="expressionList" item="&quot;following-sibling::nist:*&quot;"/>
  <append collection="expressionList" item="&quot;following-sibling::employee&quot;"/>

  <append collection="expressionList" item="&quot;preceding-sibling::comment()&quot;"/>
  <append collection="expressionList" item="&quot;preceding-sibling::text()&quot;"/>
  <append collection="expressionList" item="&quot;preceding-sibling::processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;preceding-sibling::processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;preceding-sibling::node()&quot;"/>
  <append collection="expressionList" item="&quot;preceding-sibling::*&quot;"/>
  <append collection="expressionList" item="&quot;preceding-sibling::nist:*&quot;"/>
  <append collection="expressionList" item="&quot;preceding-sibling::employee&quot;"/>

  <append collection="expressionList" item="&quot;following::comment()&quot;"/>
  <append collection="expressionList" item="&quot;following::text()&quot;"/>
  <append collection="expressionList" item="&quot;following::processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;following::processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;following::node()&quot;"/>
  <append collection="expressionList" item="&quot;following::*&quot;"/>
  <append collection="expressionList" item="&quot;following::nist:*&quot;"/>
  <append collection="expressionList" item="&quot;following::employee&quot;"/>

  <append collection="expressionList" item="&quot;preceding::comment()&quot;"/>
  <append collection="expressionList" item="&quot;preceding::text()&quot;"/>
  <append collection="expressionList" item="&quot;preceding::processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;preceding::processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;preceding::node()&quot;"/>
  <append collection="expressionList" item="&quot;preceding::*&quot;"/>
  <append collection="expressionList" item="&quot;preceding::nist:*&quot;"/>
  <append collection="expressionList" item="&quot;preceding::employee&quot;"/>

  <append collection="expressionList" item="&quot;attribute::comment()&quot;"/>
  <append collection="expressionList" item="&quot;attribute::text()&quot;"/>
  <append collection="expressionList" item="&quot;attribute::processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;attribute::processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;attribute::node()&quot;"/>
  <append collection="expressionList" item="&quot;attribute::*&quot;"/>
  <append collection="expressionList" item="&quot;attribute::nist:*&quot;"/>
  <append collection="expressionList" item="&quot;attribute::employee&quot;"/>

  <append collection="expressionList" item="&quot;namespace::comment()&quot;"/>
  <append collection="expressionList" item="&quot;namespace::text()&quot;"/>
  <append collection="expressionList" item="&quot;namespace::processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;namespace::processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;namespace::node()&quot;"/>
  <append collection="expressionList" item="&quot;namespace::*&quot;"/>
  <append collection="expressionList" item="&quot;namespace::nist:*&quot;"/>
  <append collection="expressionList" item="&quot;namespace::employee&quot;"/>

  <append collection="expressionList" item="&quot;self::comment()&quot;"/>
  <append collection="expressionList" item="&quot;self::text()&quot;"/>
  <append collection="expressionList" item="&quot;self::processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;self::processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;self::node()&quot;"/>
  <append collection="expressionList" item="&quot;self::*&quot;"/>
  <append collection="expressionList" item="&quot;self::nist:*&quot;"/>
  <append collection="expressionList" item="&quot;self::employee&quot;"/>

  <append collection="expressionList" item="&quot;descendant-or-self::comment()&quot;"/>
  <append collection="expressionList" item="&quot;descendant-or-self::text()&quot;"/>
  <append collection="expressionList" item="&quot;descendant-or-self::processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;descendant-or-self::processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;descendant-or-self::node()&quot;"/>
  <append collection="expressionList" item="&quot;descendant-or-self::*&quot;"/>
  <append collection="expressionList" item="&quot;descendant-or-self::nist:*&quot;"/>
  <append collection="expressionList" item="&quot;descendant-or-self::employee&quot;"/>

  <append collection="expressionList" item="&quot;ancestor-or-self::comment()&quot;"/>
  <append collection="expressionList" item="&quot;ancestor-or-self::text()&quot;"/>
  <append collection="expressionList" item="&quot;ancestor-or-self::processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;ancestor-or-self::processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;ancestor-or-self::node()&quot;"/>
  <append collection="expressionList" item="&quot;ancestor-or-self::*&quot;"/>
  <append collection="expressionList" item="&quot;ancestor-or-self::nist:*&quot;"/>
  <append collection="expressionList" item="&quot;ancestor-or-self::employee&quot;"/>

  <!-- test common abbreviations -->
  <append collection="expressionList" item="&quot;comment()&quot;"/>
  <append collection="expressionList" item="&quot;text()&quot;"/>
  <append collection="expressionList" item="&quot;processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;node()&quot;"/>
  <append collection="expressionList" item="&quot;*&quot;"/>
  <append collection="expressionList" item="&quot;nist:*&quot;"/>
  <append collection="expressionList" item="&quot;employee&quot;"/>

  <append collection="expressionList" item="&quot;.//comment()&quot;"/>
  <append collection="expressionList" item="&quot;.//text()&quot;"/>
  <append collection="expressionList" item="&quot;.//processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;.//processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;.//node()&quot;"/>
  <append collection="expressionList" item="&quot;.//*&quot;"/>
  <append collection="expressionList" item="&quot;.//nist:*&quot;"/>
  <append collection="expressionList" item="&quot;.//employee&quot;"/>

  <append collection="expressionList" item="&quot;../comment()&quot;"/>
  <append collection="expressionList" item="&quot;../text()&quot;"/>
  <append collection="expressionList" item="&quot;../processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;../processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;../node()&quot;"/>
  <append collection="expressionList" item="&quot;../*&quot;"/>
  <append collection="expressionList" item="&quot;../nist:*&quot;"/>
  <append collection="expressionList" item="&quot;../employee&quot;"/>

  <append collection="expressionList" item="&quot;@attributename&quot;"/>

  <append collection="expressionList" item="&quot;./comment()&quot;"/>
  <append collection="expressionList" item="&quot;./text()&quot;"/>
  <append collection="expressionList" item="&quot;./processing-instruction()&quot;"/>
  <append collection="expressionList" item="&quot;./processing-instruction('name')&quot;"/>
  <append collection="expressionList" item="&quot;./node()&quot;"/>
  <append collection="expressionList" item="&quot;./*&quot;"/>
  <append collection="expressionList" item="&quot;./nist:*&quot;"/>
  <append collection="expressionList" item="&quot;./employee&quot;"/>

  <!-- test Union -->
  <append collection="expressionList" item="&quot;comment() | text() | processing-instruction() | node()&quot;"/>

  <!-- test various predicates -->

  <append collection="expressionList" item="&quot;employee[address]&quot;"/>
  <append collection="expressionList" item="&quot;employee/address[@street]&quot;"/>
  <append collection="expressionList" item="&quot;employee[position='Computer Specialist']&quot;"/>
  <append collection="expressionList" item="&quot;employee[position!='Computer Specialist']&quot;"/>
  <append collection="expressionList" item="&quot;employee[gender='Male' or gender='Female']&quot;"/>
  <append collection="expressionList" item="&quot;employee[gender!='Male' and gender!='Female']&quot;"/>
  <append collection="expressionList" item="&quot;employee/address[@street='Yes']&quot;"/>
  <append collection="expressionList" item="&quot;employee/address[@street!='Yes']&quot;"/>
  <append collection="expressionList" item="&quot;employee[position()=1]&quot;"/>
  <append collection="expressionList" item="&quot;employee[1]&quot;"/>
  <append collection="expressionList" item="&quot;employee[position()=last()]&quot;"/>
  <append collection="expressionList" item="&quot;employee[last()]&quot;"/>
  <append collection="expressionList" item="&quot;employee[position()&gt;1 and position&lt;last()]&quot;"/>
  <append collection="expressionList" item="&quot;employee[position()&gt;=1 and position&lt;=last()]&quot;"/>
  <append collection="expressionList" item="&quot;employee[count(.)&gt;0]&quot;"/>
  <append collection="expressionList" item="&quot;employee[position() mod 2=0]&quot;"/>
  <append collection="expressionList" item="&quot;employee[position() mod -2=0]&quot;"/>
  <append collection="expressionList" item="&quot;employee[position() div 2=0]&quot;"/>
  <append collection="expressionList" item="&quot;employee[position() div -2=-1]&quot;"/>
  <append collection="expressionList" item="&quot;employee[position() div 2 * 2=position()]&quot;"/>
  <append collection="expressionList" item="&quot;employee[3 &gt; 2 &gt; 1]&quot;"/>
  <append collection="expressionList" item="&quot;id('CANADA')&quot;"/>
  <append collection="expressionList" item="&quot;*[local-name()='employee']&quot;"/>
  <append collection="expressionList" item="&quot;*[local-name(.)='employee']&quot;"/>
  <append collection="expressionList" item="&quot;*[local-name(employee)='employee']&quot;"/>
  <append collection="expressionList" item="&quot;*[local-name()='employee']&quot;"/>
  <append collection="expressionList" item="&quot;*[namespace-uri()='http://www.nist.gov']&quot;"/>
  <append collection="expressionList" item="&quot;*[name()='nist:employee']&quot;"/>
  <append collection="expressionList" item="&quot;*[string()]&quot;"/>
  <append collection="expressionList" item="&quot;*[string(10 div foo)='NaN']&quot;"/>
  <append collection="expressionList" item="&quot;*[concat('a', 'b', 'c')]&quot;"/>
  <append collection="expressionList" item="&quot;*[starts-with('employee', 'emp')]&quot;"/>
  <append collection="expressionList" item="&quot;*[contains('employee', 'emp')]&quot;"/>
  <append collection="expressionList" item="&quot;*[substring-before('employeeId', 'Id')]&quot;"/>
  <append collection="expressionList" item="&quot;*[substring-after('employeeId', 'employee')]&quot;"/>
  <append collection="expressionList" item="&quot;*[substring('employeeId', 4)]&quot;"/>
  <append collection="expressionList" item="&quot;*[substring('employeeId', 4, 5)]&quot;"/>
  <append collection="expressionList" item="&quot;*[string-length()=2]&quot;"/>
  <append collection="expressionList" item="&quot;*[string-length(.)=string-length(normalize-space(.))]&quot;"/>
  <append collection="expressionList" item="&quot;*[translate('bar', 'abc', 'ABC')='BAr']&quot;"/>
  <append collection="expressionList" item="&quot;*[boolean(.)]&quot;"/>
  <append collection="expressionList" item="&quot;*[not(boolean(.))]&quot;"/>
  <append collection="expressionList" item="&quot;*[true()]&quot;"/>
  <append collection="expressionList" item="&quot;*[false()]&quot;"/>
  <append collection="expressionList" item="&quot;*[lang('en')]&quot;"/>
  <append collection="expressionList" item="&quot;*[number()]&quot;"/>
  <append collection="expressionList" item="&quot;*[number('4')]&quot;"/>
  <append collection="expressionList" item="&quot;*[floor(.)]&gt;0&quot;"/>
  <append collection="expressionList" item="&quot;*[ceiling(.)]&lt;1&quot;"/>
  <append collection="expressionList" item="&quot;*[round(number(.))=0]&lt;1&quot;"/>

  <for-each collection="expressionList" member="expression">
    <createExpression var="xpathexpression" 
                      obj="evaluator" 
                      resolver="resolver" 
                      expression="expression"/>
  </for-each>
</test>