~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/dom/work/testxpath.cpp

  • Committer: ishmal
  • Date: 2006-04-12 13:25:21 UTC
  • Revision ID: ishmal@users.sourceforge.net-20060412132521-5ynoezpwbzq4d1c3
Add new rearranged /dom directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Phoebe DOM Implementation.
 
3
 *
 
4
 * This is a C++ approximation of the W3C DOM model, which follows
 
5
 * fairly closely the specifications in the various .idl files, copies of
 
6
 * which are provided for reference.  Most important is this one:
 
7
 *
 
8
 * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
 
9
 *
 
10
 * Authors:
 
11
 *   Bob Jamison
 
12
 *
 
13
 * Copyright (C) 2005 Bob Jamison
 
14
 *
 
15
 *  This library is free software; you can redistribute it and/or
 
16
 *  modify it under the terms of the GNU Lesser General Public
 
17
 *  License as published by the Free Software Foundation; either
 
18
 *  version 2.1 of the License, or (at your option) any later version.
 
19
 *
 
20
 *  This library is distributed in the hope that it will be useful,
 
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
23
 *  Lesser General Public License for more details.
 
24
 *
 
25
 *  You should have received a copy of the GNU Lesser General Public
 
26
 *  License along with this library; if not, write to the Free Software
 
27
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
28
 */
 
29
 
 
30
 
 
31
 
 
32
#include "dom.h"
 
33
#include "lsimpl.h"
 
34
#include "xpathparser.h"
 
35
 
 
36
#include <stdio.h>
 
37
 
 
38
using namespace org::w3c::dom;
 
39
using namespace org::w3c::dom::xpath;
 
40
 
 
41
 
 
42
typedef struct
 
43
{
 
44
    char *xpathStr;
 
45
    char *desc;
 
46
    char *xml;
 
47
} XpathTest;
 
48
 
 
49
XpathTest xpathTests[] =
 
50
{
 
51
 
 
52
{
 
53
"/AAA",
 
54
"Select the root element AAA",
 
55
"     <AAA>\n"
 
56
"          <BBB/>\n"
 
57
"          <CCC/>\n"
 
58
"          <BBB/>\n"
 
59
"          <BBB/>\n"
 
60
"          <DDD>\n"
 
61
"               <BBB/>\n"
 
62
"          </DDD>\n"
 
63
"          <CCC/>\n"
 
64
"     </AAA>\n"
 
65
},
 
66
 
 
67
{
 
68
"/AAA/CCC",
 
69
"Select all elements CCC which are children of the root element AAA",
 
70
"     <AAA>\n"
 
71
"          <BBB/>\n"
 
72
"          <CCC/>\n"
 
73
"          <BBB/>\n"
 
74
"          <BBB/>\n"
 
75
"          <DDD>\n"
 
76
"               <BBB/>\n"
 
77
"          </DDD>\n"
 
78
"          <CCC/>\n"
 
79
"     </AAA>\n"
 
80
},
 
81
 
 
82
{
 
83
"/AAA/DDD/BBB",
 
84
"Select all elements BBB which are children of DDD which are children of the root element AAA",
 
85
"     <AAA>\n"
 
86
"          <BBB/>\n"
 
87
"          <CCC/>\n"
 
88
"          <BBB/>\n"
 
89
"          <BBB/>\n"
 
90
"          <DDD>\n"
 
91
"               <BBB/>\n"
 
92
"          </DDD>\n"
 
93
"          <CCC/>\n"
 
94
"     </AAA>\n"
 
95
},
 
96
 
 
97
{
 
98
"//BBB",
 
99
"Select all elements BBB",
 
100
"     <AAA>\n"
 
101
"          <BBB/>\n"
 
102
"          <CCC/>\n"
 
103
"          <BBB/>\n"
 
104
"          <DDD>\n"
 
105
"               <BBB/>\n"
 
106
"          </DDD>\n"
 
107
"          <CCC>\n"
 
108
"               <DDD>\n"
 
109
"                    <BBB/>\n"
 
110
"                    <BBB/>\n"
 
111
"               </DDD>\n"
 
112
"          </CCC>\n"
 
113
"     </AAA>\n"
 
114
},
 
115
 
 
116
{
 
117
"//DDD/BBB",
 
118
"Select all elements BBB which are children of DDD",
 
119
"     <AAA>\n"
 
120
"          <BBB/>\n"
 
121
"          <CCC/>\n"
 
122
"          <BBB/>\n"
 
123
"          <DDD>\n"
 
124
"               <BBB/>\n"
 
125
"          </DDD>\n"
 
126
"          <CCC>\n"
 
127
"               <DDD>\n"
 
128
"                    <BBB/>\n"
 
129
"                    <BBB/>\n"
 
130
"               </DDD>\n"
 
131
"          </CCC>\n"
 
132
"     </AAA>\n"
 
133
},
 
134
 
 
135
{
 
136
"/AAA/CCC/DDD/*",
 
137
"Select all elements enclosed by elements /AAA/CCC/DDD",
 
138
"     <AAA>\n"
 
139
"          <XXX>\n"
 
140
"               <DDD>\n"
 
141
"                    <BBB/>\n"
 
142
"                    <BBB/>\n"
 
143
"                    <EEE/>\n"
 
144
"                    <FFF/>\n"
 
145
"               </DDD>\n"
 
146
"          </XXX>\n"
 
147
"          <CCC>\n"
 
148
"               <DDD>\n"
 
149
"                    <BBB/>\n"
 
150
"                    <BBB/>\n"
 
151
"                    <EEE/>\n"
 
152
"                    <FFF/>\n"
 
153
"               </DDD>\n"
 
154
"          </CCC>\n"
 
155
"          <CCC>\n"
 
156
"               <BBB>\n"
 
157
"                    <BBB>\n"
 
158
"                         <BBB/>\n"
 
159
"                    </BBB>\n"
 
160
"               </BBB>\n"
 
161
"          </CCC>\n"
 
162
"     </AAA>\n"
 
163
},
 
164
 
 
165
{
 
166
"/*/*/*/BBB",
 
167
"Select all elements BBB which have 3 ancestors",
 
168
"     <AAA>\n"
 
169
"          <XXX>\n"
 
170
"               <DDD>\n"
 
171
"                    <BBB/>\n"
 
172
"                    <BBB/>\n"
 
173
"                    <EEE/>\n"
 
174
"                    <FFF/>\n"
 
175
"               </DDD>\n"
 
176
"          </XXX>\n"
 
177
"          <CCC>\n"
 
178
"               <DDD>\n"
 
179
"                    <BBB/>\n"
 
180
"                    <BBB/>\n"
 
181
"                    <EEE/>\n"
 
182
"                    <FFF/>\n"
 
183
"               </DDD>\n"
 
184
"          </CCC>\n"
 
185
"          <CCC>\n"
 
186
"               <BBB>\n"
 
187
"                    <BBB>\n"
 
188
"                         <BBB/>\n"
 
189
"                    </BBB>\n"
 
190
"               </BBB>\n"
 
191
"          </CCC>\n"
 
192
"     </AAA>\n"
 
193
},
 
194
 
 
195
{
 
196
"//*",
 
197
"Select all elements",
 
198
"     <AAA>\n"
 
199
"          <XXX>\n"
 
200
"               <DDD>\n"
 
201
"                    <BBB/>\n"
 
202
"                    <BBB/>\n"
 
203
"                    <EEE/>\n"
 
204
"                    <FFF/>\n"
 
205
"               </DDD>\n"
 
206
"          </XXX>\n"
 
207
"          <CCC>\n"
 
208
"               <DDD>\n"
 
209
"                    <BBB/>\n"
 
210
"                    <BBB/>\n"
 
211
"                    <EEE/>\n"
 
212
"                    <FFF/>\n"
 
213
"               </DDD>\n"
 
214
"          </CCC>\n"
 
215
"          <CCC>\n"
 
216
"               <BBB>\n"
 
217
"                    <BBB>\n"
 
218
"                         <BBB/>\n"
 
219
"                    </BBB>\n"
 
220
"               </BBB>\n"
 
221
"          </CCC>\n"
 
222
"     </AAA>\n"
 
223
},
 
224
 
 
225
{
 
226
"/AAA/BBB[1]",
 
227
"Select the first BBB child of element AAA",
 
228
"     <AAA>\n"
 
229
"          <BBB/>\n"
 
230
"          <BBB/>\n"
 
231
"          <BBB/>\n"
 
232
"          <BBB/>\n"
 
233
"     </AAA>\n"
 
234
},
 
235
 
 
236
{
 
237
"/AAA/BBB[last()]",
 
238
"Select the last BBB child of element AAA",
 
239
"     <AAA>\n"
 
240
"          <BBB/>\n"
 
241
"          <BBB/>\n"
 
242
"          <BBB/>\n"
 
243
"          <BBB/>\n"
 
244
"     </AAA>\n"
 
245
},
 
246
 
 
247
{
 
248
"//@id",
 
249
"Select all attributes @id",
 
250
"     <AAA>\n"
 
251
"          <BBB id = 'b1'/>\n"
 
252
"          <BBB id = 'b2'/>\n"
 
253
"          <BBB name = 'bbb'/>\n"
 
254
"          <BBB/>\n"
 
255
"     </AAA>\n"
 
256
},
 
257
 
 
258
{
 
259
"//BBB[@id]",
 
260
"Select BBB elements which have attribute id",
 
261
"     <AAA>\n"
 
262
"          <BBB id = 'b1'/>\n"
 
263
"          <BBB id = 'b2'/>\n"
 
264
"          <BBB name = 'bbb'/>\n"
 
265
"          <BBB/>\n"
 
266
"     </AAA>\n"
 
267
},
 
268
 
 
269
{
 
270
"//BBB[@name]",
 
271
"Select BBB elements which have attribute name",
 
272
"     <AAA>\n"
 
273
"          <BBB id = 'b1'/>\n"
 
274
"          <BBB id = 'b2'/>\n"
 
275
"          <BBB name = 'bbb'/>\n"
 
276
"          <BBB/>\n"
 
277
"     </AAA>\n"
 
278
},
 
279
 
 
280
{
 
281
"//BBB[@*]",
 
282
"Select BBB elements which have any attribute",
 
283
"     <AAA>\n"
 
284
"          <BBB id = 'b1'/>\n"
 
285
"          <BBB id = 'b2'/>\n"
 
286
"          <BBB name = 'bbb'/>\n"
 
287
"          <BBB/>\n"
 
288
"     </AAA>\n"
 
289
},
 
290
 
 
291
{
 
292
"//BBB[not(@*)]",
 
293
"Select BBB elements without an attribute",
 
294
"     <AAA>\n"
 
295
"          <BBB id = 'b1'/>\n"
 
296
"          <BBB id = 'b2'/>\n"
 
297
"          <BBB name = 'bbb'/>\n"
 
298
"          <BBB/>\n"
 
299
"     </AAA>\n"
 
300
},
 
301
 
 
302
{
 
303
"//BBB[@id='b1']",
 
304
"Select BBB elements which have attribute id with value b1",
 
305
"     <AAA>\n"
 
306
"          <BBB id = 'b1'/>\n"
 
307
"          <BBB name = ' bbb '/>\n"
 
308
"          <BBB name = 'bbb'/>\n"
 
309
"     </AAA>\n"
 
310
},
 
311
 
 
312
{
 
313
"//BBB[@name='bbb']",
 
314
"Select BBB elements which have attribute name with value 'bbb'",
 
315
"     <AAA>\n"
 
316
"          <BBB id = 'b1'/>\n"
 
317
"          <BBB name = ' bbb '/>\n"
 
318
"          <BBB name = 'bbb'/>\n"
 
319
"     </AAA>\n"
 
320
},
 
321
 
 
322
{
 
323
"//BBB[normalize-space(@name)='bbb']",
 
324
"Select BBB elements which have attribute name with value bbb, leading and trailing spaces are removed before comparison",
 
325
"     <AAA>\n"
 
326
"          <BBB id = 'b1'/>\n"
 
327
"          <BBB name = ' bbb '/>\n"
 
328
"          <BBB name = 'bbb'/>\n"
 
329
"     </AAA>\n"
 
330
},
 
331
 
 
332
{
 
333
"//*[count(BBB)=2]",
 
334
"Select elements which have two children BBB",
 
335
"     <AAA>\n"
 
336
"          <CCC>\n"
 
337
"               <BBB/>\n"
 
338
"               <BBB/>\n"
 
339
"               <BBB/>\n"
 
340
"          </CCC>\n"
 
341
"          <DDD>\n"
 
342
"               <BBB/>\n"
 
343
"               <BBB/>\n"
 
344
"          </DDD>\n"
 
345
"          <EEE>\n"
 
346
"               <CCC/>\n"
 
347
"               <DDD/>\n"
 
348
"          </EEE>\n"
 
349
"     </AAA>\n"
 
350
},
 
351
 
 
352
{
 
353
"//*[count(*)=2]",
 
354
"Select elements which have 2 children",
 
355
"     <AAA>\n"
 
356
"          <CCC>\n"
 
357
"               <BBB/>\n"
 
358
"               <BBB/>\n"
 
359
"               <BBB/>\n"
 
360
"          </CCC>\n"
 
361
"          <DDD>\n"
 
362
"               <BBB/>\n"
 
363
"               <BBB/>\n"
 
364
"          </DDD>\n"
 
365
"          <EEE>\n"
 
366
"               <CCC/>\n"
 
367
"               <DDD/>\n"
 
368
"          </EEE>\n"
 
369
"     </AAA>\n"
 
370
},
 
371
 
 
372
{
 
373
"//*[count(*)=3]",
 
374
"Select elements which have 3 children",
 
375
"     <AAA>\n"
 
376
"          <CCC>\n"
 
377
"               <BBB/>\n"
 
378
"               <BBB/>\n"
 
379
"               <BBB/>\n"
 
380
"          </CCC>\n"
 
381
"          <DDD>\n"
 
382
"               <BBB/>\n"
 
383
"               <BBB/>\n"
 
384
"          </DDD>\n"
 
385
"          <EEE>\n"
 
386
"               <CCC/>\n"
 
387
"               <DDD/>\n"
 
388
"          </EEE>\n"
 
389
"     </AAA>\n"
 
390
},
 
391
 
 
392
{
 
393
"//*[name()='BBB']",
 
394
"Select all elements with name BBB, equivalent with //BBB",
 
395
"     <AAA>\n"
 
396
"          <BCC>\n"
 
397
"               <BBB/>\n"
 
398
"               <BBB/>\n"
 
399
"               <BBB/>\n"
 
400
"          </BCC>\n"
 
401
"          <DDB>\n"
 
402
"               <BBB/>\n"
 
403
"               <BBB/>\n"
 
404
"          </DDB>\n"
 
405
"          <BEC>\n"
 
406
"               <CCC/>\n"
 
407
"               <DBD/>\n"
 
408
"          </BEC>\n"
 
409
"     </AAA>\n"
 
410
},
 
411
 
 
412
{
 
413
"//*[starts-with(name(),'B')]",
 
414
"Select all elements name of which starts with letter B",
 
415
"     <AAA>\n"
 
416
"          <BCC>\n"
 
417
"               <BBB/>\n"
 
418
"               <BBB/>\n"
 
419
"               <BBB/>\n"
 
420
"          </BCC>\n"
 
421
"          <DDB>\n"
 
422
"               <BBB/>\n"
 
423
"               <BBB/>\n"
 
424
"          </DDB>\n"
 
425
"          <BEC>\n"
 
426
"               <CCC/>\n"
 
427
"               <DBD/>\n"
 
428
"          </BEC>\n"
 
429
"     </AAA>\n"
 
430
},
 
431
 
 
432
{
 
433
"//*[contains(name(),'C')]",
 
434
"Select all elements name of which contain letter C",
 
435
"     <AAA>\n"
 
436
"          <BCC>\n"
 
437
"               <BBB/>\n"
 
438
"               <BBB/>\n"
 
439
"               <BBB/>\n"
 
440
"          </BCC>\n"
 
441
"          <DDB>\n"
 
442
"               <BBB/>\n"
 
443
"               <BBB/>\n"
 
444
"          </DDB>\n"
 
445
"          <BEC>\n"
 
446
"               <CCC/>\n"
 
447
"               <DBD/>\n"
 
448
"          </BEC>\n"
 
449
"     </AAA>\n"
 
450
},
 
451
 
 
452
{
 
453
"//*[string-length(name()) = 3]",
 
454
"Select elements with three-letter name",
 
455
"     <AAA>\n"
 
456
"          <Q/>\n"
 
457
"          <SSSS/>\n"
 
458
"          <BB/>\n"
 
459
"          <CCC/>\n"
 
460
"          <DDDDDDDD/>\n"
 
461
"          <EEEE/>\n"
 
462
"     </AAA>\n"
 
463
},
 
464
 
 
465
{
 
466
"//*[string-length(name()) < 3]",
 
467
"Select elements name of which has one or two characters",
 
468
"     <AAA>\n"
 
469
"          <Q/>\n"
 
470
"          <SSSS/>\n"
 
471
"          <BB/>\n"
 
472
"          <CCC/>\n"
 
473
"          <DDDDDDDD/>\n"
 
474
"          <EEEE/>\n"
 
475
"     </AAA>\n"
 
476
},
 
477
 
 
478
{
 
479
"//*[string-length(name()) > 3]",
 
480
"Select elements with name longer than three characters",
 
481
"     <AAA>\n"
 
482
"          <Q/>\n"
 
483
"          <SSSS/>\n"
 
484
"          <BB/>\n"
 
485
"          <CCC/>\n"
 
486
"          <DDDDDDDD/>\n"
 
487
"          <EEEE/>\n"
 
488
"     </AAA>\n"
 
489
},
 
490
 
 
491
{
 
492
"//CCC | //BBB",
 
493
"Select all elements CCC and BBB",
 
494
"     <AAA>\n"
 
495
"          <BBB/>\n"
 
496
"          <CCC/>\n"
 
497
"          <DDD>\n"
 
498
"               <CCC/>\n"
 
499
"          </DDD>\n"
 
500
"          <EEE/>\n"
 
501
"     </AAA>\n"
 
502
},
 
503
 
 
504
{
 
505
"/AAA/EEE | //BBB",
 
506
"Select all elements BBB and elements EEE which are children of root element AAA",
 
507
"     <AAA>\n"
 
508
"          <BBB/>\n"
 
509
"          <CCC/>\n"
 
510
"          <DDD>\n"
 
511
"               <CCC/>\n"
 
512
"          </DDD>\n"
 
513
"          <EEE/>\n"
 
514
"     </AAA>\n"
 
515
},
 
516
 
 
517
{
 
518
"/AAA/EEE | //DDD/CCC | /AAA | //BBB",
 
519
"Number of combinations is not restricted",
 
520
"     <AAA>\n"
 
521
"          <BBB/>\n"
 
522
"          <CCC/>\n"
 
523
"          <DDD>\n"
 
524
"               <CCC/>\n"
 
525
"          </DDD>\n"
 
526
"          <EEE/>\n"
 
527
"     </AAA>\n"
 
528
},
 
529
 
 
530
{
 
531
"/AAA",
 
532
"Equivalent of /child::AAA",
 
533
"     <AAA>\n"
 
534
"          <BBB/>\n"
 
535
"          <CCC/>\n"
 
536
"     </AAA>\n"
 
537
},
 
538
 
 
539
{
 
540
"/child::AAA",
 
541
"Equivalent of /AAA",
 
542
"     <AAA>\n"
 
543
"          <BBB/>\n"
 
544
"          <CCC/>\n"
 
545
"     </AAA>\n"
 
546
},
 
547
 
 
548
{
 
549
"/AAA/BBB",
 
550
"Equivalent of /child::AAA/child::BBB",
 
551
"     <AAA>\n"
 
552
"          <BBB/>\n"
 
553
"          <CCC/>\n"
 
554
"     </AAA>\n"
 
555
},
 
556
 
 
557
{
 
558
"/child::AAA/child::BBB",
 
559
"Equivalent of /AAA/BBB",
 
560
"     <AAA>\n"
 
561
"          <BBB/>\n"
 
562
"          <CCC/>\n"
 
563
"     </AAA>\n"
 
564
},
 
565
 
 
566
{
 
567
"/child::AAA/BBB",
 
568
"Both possibilities can be combined",
 
569
"     <AAA>\n"
 
570
"          <BBB/>\n"
 
571
"          <CCC/>\n"
 
572
"     </AAA>\n"
 
573
},
 
574
 
 
575
{
 
576
"/descendant::*",
 
577
"Select all descendants of document root and therefore all elements",
 
578
"     <AAA>\n"
 
579
"          <BBB>\n"
 
580
"               <DDD>\n"
 
581
"                    <CCC>\n"
 
582
"                         <DDD/>\n"
 
583
"                         <EEE/>\n"
 
584
"                    </CCC>\n"
 
585
"               </DDD>\n"
 
586
"          </BBB>\n"
 
587
"          <CCC>\n"
 
588
"               <DDD>\n"
 
589
"                    <EEE>\n"
 
590
"                         <DDD>\n"
 
591
"                              <FFF/>\n"
 
592
"                         </DDD>\n"
 
593
"                    </EEE>\n"
 
594
"               </DDD>\n"
 
595
"          </CCC>\n"
 
596
"     </AAA>\n"
 
597
},
 
598
 
 
599
{
 
600
"/AAA/BBB/descendant::*",
 
601
"Select all descendants of /AAA/BBB",
 
602
"     <AAA>\n"
 
603
"          <BBB>\n"
 
604
"               <DDD>\n"
 
605
"                    <CCC>\n"
 
606
"                         <DDD/>\n"
 
607
"                         <EEE/>\n"
 
608
"                    </CCC>\n"
 
609
"               </DDD>\n"
 
610
"          </BBB>\n"
 
611
"          <CCC>\n"
 
612
"               <DDD>\n"
 
613
"                    <EEE>\n"
 
614
"                         <DDD>\n"
 
615
"                              <FFF/>\n"
 
616
"                         </DDD>\n"
 
617
"                    </EEE>\n"
 
618
"               </DDD>\n"
 
619
"          </CCC>\n"
 
620
"     </AAA>\n"
 
621
},
 
622
 
 
623
{
 
624
"//CCC/descendant::*",
 
625
"Select all elements which have CCC among its ancestors",
 
626
"     <AAA>\n"
 
627
"          <BBB>\n"
 
628
"               <DDD>\n"
 
629
"                    <CCC>\n"
 
630
"                         <DDD/>\n"
 
631
"                         <EEE/>\n"
 
632
"                    </CCC>\n"
 
633
"               </DDD>\n"
 
634
"          </BBB>\n"
 
635
"          <CCC>\n"
 
636
"               <DDD>\n"
 
637
"                    <EEE>\n"
 
638
"                         <DDD>\n"
 
639
"                              <FFF/>\n"
 
640
"                         </DDD>\n"
 
641
"                    </EEE>\n"
 
642
"               </DDD>\n"
 
643
"          </CCC>\n"
 
644
"     </AAA>\n"
 
645
},
 
646
 
 
647
{
 
648
"//CCC/descendant::DDD",
 
649
"Select elements DDD which have CCC among its ancestors",
 
650
"     <AAA>\n"
 
651
"          <BBB>\n"
 
652
"               <DDD>\n"
 
653
"                    <CCC>\n"
 
654
"                         <DDD/>\n"
 
655
"                         <EEE/>\n"
 
656
"                    </CCC>\n"
 
657
"               </DDD>\n"
 
658
"          </BBB>\n"
 
659
"          <CCC>\n"
 
660
"               <DDD>\n"
 
661
"                    <EEE>\n"
 
662
"                         <DDD>\n"
 
663
"                              <FFF/>\n"
 
664
"                         </DDD>\n"
 
665
"                    </EEE>\n"
 
666
"               </DDD>\n"
 
667
"          </CCC>\n"
 
668
"     </AAA>\n"
 
669
},
 
670
 
 
671
{
 
672
"//DDD/parent::*",
 
673
"Select all parents of DDD element",
 
674
"     <AAA>\n"
 
675
"          <BBB>\n"
 
676
"               <DDD>\n"
 
677
"                    <CCC>\n"
 
678
"                         <DDD/>\n"
 
679
"                         <EEE/>\n"
 
680
"                    </CCC>\n"
 
681
"               </DDD>\n"
 
682
"          </BBB>\n"
 
683
"          <CCC>\n"
 
684
"               <DDD>\n"
 
685
"                    <EEE>\n"
 
686
"                         <DDD>\n"
 
687
"                              <FFF/>\n"
 
688
"                         </DDD>\n"
 
689
"                    </EEE>\n"
 
690
"               </DDD>\n"
 
691
"          </CCC>\n"
 
692
"     </AAA>\n"
 
693
},
 
694
 
 
695
{
 
696
"/AAA/BBB/DDD/CCC/EEE/ancestor::*",
 
697
"Select all elements given in this absolute path",
 
698
"     <AAA>\n"
 
699
"          <BBB>\n"
 
700
"               <DDD>\n"
 
701
"                    <CCC>\n"
 
702
"                         <DDD/>\n"
 
703
"                         <EEE/>\n"
 
704
"                    </CCC>\n"
 
705
"               </DDD>\n"
 
706
"          </BBB>\n"
 
707
"          <CCC>\n"
 
708
"               <DDD>\n"
 
709
"                    <EEE>\n"
 
710
"                         <DDD>\n"
 
711
"                              <FFF/>\n"
 
712
"                         </DDD>\n"
 
713
"                    </EEE>\n"
 
714
"               </DDD>\n"
 
715
"          </CCC>\n"
 
716
"     </AAA>\n"
 
717
},
 
718
 
 
719
{
 
720
"//FFF/ancestor::*",
 
721
"Select ancestors of FFF element",
 
722
"     <AAA>\n"
 
723
"          <BBB>\n"
 
724
"               <DDD>\n"
 
725
"                    <CCC>\n"
 
726
"                         <DDD/>\n"
 
727
"                         <EEE/>\n"
 
728
"                    </CCC>\n"
 
729
"               </DDD>\n"
 
730
"          </BBB>\n"
 
731
"          <CCC>\n"
 
732
"               <DDD>\n"
 
733
"                    <EEE>\n"
 
734
"                         <DDD>\n"
 
735
"                              <FFF/>\n"
 
736
"                         </DDD>\n"
 
737
"                    </EEE>\n"
 
738
"               </DDD>\n"
 
739
"          </CCC>\n"
 
740
"     </AAA>\n"
 
741
},
 
742
 
 
743
{
 
744
"/AAA/BBB/following-sibling::*",
 
745
"The following-sibling axis contains all the following siblings of the context node.",
 
746
"     <AAA>\n"
 
747
"          <BBB>\n"
 
748
"               <CCC/>\n"
 
749
"               <DDD/>\n"
 
750
"          </BBB>\n"
 
751
"          <XXX>\n"
 
752
"               <DDD>\n"
 
753
"                    <EEE/>\n"
 
754
"                    <DDD/>\n"
 
755
"                    <CCC/>\n"
 
756
"                    <FFF/>\n"
 
757
"                    <FFF>\n"
 
758
"                         <GGG/>\n"
 
759
"                    </FFF>\n"
 
760
"               </DDD>\n"
 
761
"          </XXX>\n"
 
762
"          <CCC>\n"
 
763
"               <DDD/>\n"
 
764
"          </CCC>\n"
 
765
"     </AAA>\n"
 
766
},
 
767
 
 
768
{
 
769
"//CCC/following-sibling::*",
 
770
"The following-sibling axis contains all the following siblings of the context node.",
 
771
"     <AAA>\n"
 
772
"          <BBB>\n"
 
773
"               <CCC/>\n"
 
774
"               <DDD/>\n"
 
775
"          </BBB>\n"
 
776
"          <XXX>\n"
 
777
"               <DDD>\n"
 
778
"                    <EEE/>\n"
 
779
"                    <DDD/>\n"
 
780
"                    <CCC/>\n"
 
781
"                    <FFF/>\n"
 
782
"                    <FFF>\n"
 
783
"                         <GGG/>\n"
 
784
"                    </FFF>\n"
 
785
"               </DDD>\n"
 
786
"          </XXX>\n"
 
787
"          <CCC>\n"
 
788
"               <DDD/>\n"
 
789
"          </CCC>\n"
 
790
"     </AAA>\n"
 
791
},
 
792
 
 
793
{
 
794
"/AAA/XXX/preceding-sibling::*",
 
795
"The preceding-sibling axis contains all the preceding siblings of the context node.",
 
796
"     <AAA>\n"
 
797
"          <BBB>\n"
 
798
"               <CCC/>\n"
 
799
"               <DDD/>\n"
 
800
"          </BBB>\n"
 
801
"          <XXX>\n"
 
802
"               <DDD>\n"
 
803
"                    <EEE/>\n"
 
804
"                    <DDD/>\n"
 
805
"                    <CCC/>\n"
 
806
"                    <FFF/>\n"
 
807
"                    <FFF>\n"
 
808
"                         <GGG/>\n"
 
809
"                    </FFF>\n"
 
810
"               </DDD>\n"
 
811
"          </XXX>\n"
 
812
"          <CCC>\n"
 
813
"               <DDD/>\n"
 
814
"          </CCC>\n"
 
815
"     </AAA>\n"
 
816
},
 
817
 
 
818
{
 
819
"//CCC/preceding-sibling::*",
 
820
"The preceding-sibling axis contains all the preceding siblings of the context node",
 
821
"     <AAA>\n"
 
822
"          <BBB>\n"
 
823
"               <CCC/>\n"
 
824
"               <DDD/>\n"
 
825
"          </BBB>\n"
 
826
"          <XXX>\n"
 
827
"               <DDD>\n"
 
828
"                    <EEE/>\n"
 
829
"                    <DDD/>\n"
 
830
"                    <CCC/>\n"
 
831
"                    <FFF/>\n"
 
832
"                    <FFF>\n"
 
833
"                         <GGG/>\n"
 
834
"                    </FFF>\n"
 
835
"               </DDD>\n"
 
836
"          </XXX>\n"
 
837
"          <CCC>\n"
 
838
"               <DDD/>\n"
 
839
"          </CCC>\n"
 
840
"     </AAA>\n"
 
841
},
 
842
 
 
843
{
 
844
"/AAA/XXX/following::*",
 
845
"The following axis contains all nodes in the same document as the context "
 
846
"node that are after the context node in document order, "
 
847
"excluding any descendants and excluding attribute nodes and namespace nodes.",
 
848
"     <AAA>\n"
 
849
"          <BBB>\n"
 
850
"               <CCC/>\n"
 
851
"               <ZZZ>\n"
 
852
"                    <DDD/>\n"
 
853
"                    <DDD>\n"
 
854
"                         <EEE/>\n"
 
855
"                    </DDD>\n"
 
856
"               </ZZZ>\n"
 
857
"               <FFF>\n"
 
858
"                    <GGG/>\n"
 
859
"               </FFF>\n"
 
860
"          </BBB>\n"
 
861
"          <XXX>\n"
 
862
"               <DDD>\n"
 
863
"                    <EEE/>\n"
 
864
"                    <DDD/>\n"
 
865
"                    <CCC/>\n"
 
866
"                    <FFF/>\n"
 
867
"                    <FFF>\n"
 
868
"                         <GGG/>\n"
 
869
"                    </FFF>\n"
 
870
"               </DDD>\n"
 
871
"          </XXX>\n"
 
872
"          <CCC>\n"
 
873
"               <DDD/>\n"
 
874
"          </CCC>\n"
 
875
"     </AAA>\n"
 
876
},
 
877
 
 
878
{
 
879
"//ZZZ/following::*",
 
880
"The following axis contains all nodes in the same document as the context "
 
881
"node that are after the context node in document order, "
 
882
"excluding any descendants and excluding attribute nodes and namespace nodes.",
 
883
"     <AAA>\n"
 
884
"          <BBB>\n"
 
885
"               <CCC/>\n"
 
886
"               <ZZZ>\n"
 
887
"                    <DDD/>\n"
 
888
"                    <DDD>\n"
 
889
"                         <EEE/>\n"
 
890
"                    </DDD>\n"
 
891
"               </ZZZ>\n"
 
892
"               <FFF>\n"
 
893
"                    <GGG/>\n"
 
894
"               </FFF>\n"
 
895
"          </BBB>\n"
 
896
"          <XXX>\n"
 
897
"               <DDD>\n"
 
898
"                    <EEE/>\n"
 
899
"                    <DDD/>\n"
 
900
"                    <CCC/>\n"
 
901
"                    <FFF/>\n"
 
902
"                    <FFF>\n"
 
903
"                         <GGG/>\n"
 
904
"                    </FFF>\n"
 
905
"               </DDD>\n"
 
906
"          </XXX>\n"
 
907
"          <CCC>\n"
 
908
"               <DDD/>\n"
 
909
"          </CCC>\n"
 
910
"     </AAA>\n"
 
911
},
 
912
 
 
913
{
 
914
"/AAA/XXX/preceding::*",
 
915
"The preceding axis contains all nodes in the same document as the "
 
916
"context node that are before the context node in document order, "
 
917
"excluding any ancestors and excluding attribute nodes and namespace nodes",
 
918
"     <AAA>\n"
 
919
"          <BBB>\n"
 
920
"               <CCC/>\n"
 
921
"               <ZZZ>\n"
 
922
"                    <DDD/>\n"
 
923
"               </ZZZ>\n"
 
924
"          </BBB>\n"
 
925
"          <XXX>\n"
 
926
"               <DDD>\n"
 
927
"                    <EEE/>\n"
 
928
"                    <DDD/>\n"
 
929
"                    <CCC/>\n"
 
930
"                    <FFF/>\n"
 
931
"                    <FFF>\n"
 
932
"                         <GGG/>\n"
 
933
"                    </FFF>\n"
 
934
"               </DDD>\n"
 
935
"          </XXX>\n"
 
936
"          <CCC>\n"
 
937
"               <DDD/>\n"
 
938
"          </CCC>\n"
 
939
"     </AAA>\n"
 
940
},
 
941
 
 
942
{
 
943
"//GGG/preceding::*",
 
944
"The preceding axis contains all nodes in the same document as the "
 
945
"context node that are before the context node in document order, "
 
946
"excluding any ancestors and excluding attribute nodes and namespace nodes",
 
947
"     <AAA>\n"
 
948
"          <BBB>\n"
 
949
"               <CCC/>\n"
 
950
"               <ZZZ>\n"
 
951
"                    <DDD/>\n"
 
952
"               </ZZZ>\n"
 
953
"          </BBB>\n"
 
954
"          <XXX>\n"
 
955
"               <DDD>\n"
 
956
"                    <EEE/>\n"
 
957
"                    <DDD/>\n"
 
958
"                    <CCC/>\n"
 
959
"                    <FFF/>\n"
 
960
"                    <FFF>\n"
 
961
"                         <GGG/>\n"
 
962
"                    </FFF>\n"
 
963
"               </DDD>\n"
 
964
"          </XXX>\n"
 
965
"          <CCC>\n"
 
966
"               <DDD/>\n"
 
967
"          </CCC>\n"
 
968
"     </AAA>\n"
 
969
},
 
970
 
 
971
{
 
972
"/AAA/XXX/descendant-or-self::*",
 
973
"The descendant-or-self axis contains the "
 
974
"context node and the descendants of the context node",
 
975
"     <AAA>\n"
 
976
"          <BBB>\n"
 
977
"               <CCC/>\n"
 
978
"               <ZZZ>\n"
 
979
"                    <DDD/>\n"
 
980
"               </ZZZ>\n"
 
981
"          </BBB>\n"
 
982
"          <XXX>\n"
 
983
"               <DDD>\n"
 
984
"                    <EEE/>\n"
 
985
"                    <DDD/>\n"
 
986
"                    <CCC/>\n"
 
987
"                    <FFF/>\n"
 
988
"                    <FFF>\n"
 
989
"                         <GGG/>\n"
 
990
"                    </FFF>\n"
 
991
"               </DDD>\n"
 
992
"          </XXX>\n"
 
993
"          <CCC>\n"
 
994
"               <DDD/>\n"
 
995
"          </CCC>\n"
 
996
"     </AAA>\n"
 
997
},
 
998
 
 
999
{
 
1000
"//CCC/descendant-or-self::*",
 
1001
"The descendant-or-self axis contains the "
 
1002
"context node and the descendants of the context node",
 
1003
"     <AAA>\n"
 
1004
"          <BBB>\n"
 
1005
"               <CCC/>\n"
 
1006
"               <ZZZ>\n"
 
1007
"                    <DDD/>\n"
 
1008
"               </ZZZ>\n"
 
1009
"          </BBB>\n"
 
1010
"          <XXX>\n"
 
1011
"               <DDD>\n"
 
1012
"                    <EEE/>\n"
 
1013
"                    <DDD/>\n"
 
1014
"                    <CCC/>\n"
 
1015
"                    <FFF/>\n"
 
1016
"                    <FFF>\n"
 
1017
"                         <GGG/>\n"
 
1018
"                    </FFF>\n"
 
1019
"               </DDD>\n"
 
1020
"          </XXX>\n"
 
1021
"          <CCC>\n"
 
1022
"               <DDD/>\n"
 
1023
"          </CCC>\n"
 
1024
"     </AAA>\n"
 
1025
},
 
1026
 
 
1027
{
 
1028
"/AAA/XXX/DDD/EEE/ancestor-or-self::*",
 
1029
"The ancestor-or-self axis contains the context node and the "
 
1030
"ancestors of the context node; thus, the ancestor-or-self axis "
 
1031
"will always include the root node.",
 
1032
"     <AAA>\n"
 
1033
"          <BBB>\n"
 
1034
"               <CCC/>\n"
 
1035
"               <ZZZ>\n"
 
1036
"                    <DDD/>\n"
 
1037
"               </ZZZ>\n"
 
1038
"          </BBB>\n"
 
1039
"          <XXX>\n"
 
1040
"               <DDD>\n"
 
1041
"                    <EEE/>\n"
 
1042
"                    <DDD/>\n"
 
1043
"                    <CCC/>\n"
 
1044
"                    <FFF/>\n"
 
1045
"                    <FFF>\n"
 
1046
"                         <GGG/>\n"
 
1047
"                    </FFF>\n"
 
1048
"               </DDD>\n"
 
1049
"          </XXX>\n"
 
1050
"          <CCC>\n"
 
1051
"               <DDD/>\n"
 
1052
"          </CCC>\n"
 
1053
"     </AAA>\n"
 
1054
},
 
1055
 
 
1056
{
 
1057
"//GGG/ancestor-or-self::*",
 
1058
"The ancestor-or-self axis contains the context node and the "
 
1059
"ancestors of the context node; thus, the ancestor-or-self axis "
 
1060
"will always include the root node.",
 
1061
"     <AAA>\n"
 
1062
"          <BBB>\n"
 
1063
"               <CCC/>\n"
 
1064
"               <ZZZ>\n"
 
1065
"                    <DDD/>\n"
 
1066
"               </ZZZ>\n"
 
1067
"          </BBB>\n"
 
1068
"          <XXX>\n"
 
1069
"               <DDD>\n"
 
1070
"                    <EEE/>\n"
 
1071
"                    <DDD/>\n"
 
1072
"                    <CCC/>\n"
 
1073
"                    <FFF/>\n"
 
1074
"                    <FFF>\n"
 
1075
"                         <GGG/>\n"
 
1076
"                    </FFF>\n"
 
1077
"               </DDD>\n"
 
1078
"          </XXX>\n"
 
1079
"          <CCC>\n"
 
1080
"               <DDD/>\n"
 
1081
"          </CCC>\n"
 
1082
"     </AAA>\n"
 
1083
},
 
1084
 
 
1085
{
 
1086
"//GGG/ancestor::*",
 
1087
"The ancestor, descendant, following, preceding and self axes partition a document",
 
1088
"     <AAA>\n"
 
1089
"          <BBB>\n"
 
1090
"               <CCC/>\n"
 
1091
"               <ZZZ/>\n"
 
1092
"          </BBB>\n"
 
1093
"          <XXX>\n"
 
1094
"               <DDD>\n"
 
1095
"                    <EEE/>\n"
 
1096
"                    <FFF>\n"
 
1097
"                         <HHH/>\n"
 
1098
"                         <GGG>\n"
 
1099
"                              <JJJ>\n"
 
1100
"                                   <QQQ/>\n"
 
1101
"                              </JJJ>\n"
 
1102
"                              <JJJ/>\n"
 
1103
"                         </GGG>\n"
 
1104
"                         <HHH/>\n"
 
1105
"                    </FFF>\n"
 
1106
"               </DDD>\n"
 
1107
"          </XXX>\n"
 
1108
"          <CCC>\n"
 
1109
"               <DDD/>\n"
 
1110
"          </CCC>\n"
 
1111
"     </AAA>\n"
 
1112
},
 
1113
 
 
1114
{
 
1115
"//GGG/descendant::*",
 
1116
"The ancestor, descendant, following, preceding and self axes partition a document",
 
1117
"     <AAA>\n"
 
1118
"          <BBB>\n"
 
1119
"               <CCC/>\n"
 
1120
"               <ZZZ/>\n"
 
1121
"          </BBB>\n"
 
1122
"          <XXX>\n"
 
1123
"               <DDD>\n"
 
1124
"                    <EEE/>\n"
 
1125
"                    <FFF>\n"
 
1126
"                         <HHH/>\n"
 
1127
"                         <GGG>\n"
 
1128
"                              <JJJ>\n"
 
1129
"                                   <QQQ/>\n"
 
1130
"                              </JJJ>\n"
 
1131
"                              <JJJ/>\n"
 
1132
"                         </GGG>\n"
 
1133
"                         <HHH/>\n"
 
1134
"                    </FFF>\n"
 
1135
"               </DDD>\n"
 
1136
"          </XXX>\n"
 
1137
"          <CCC>\n"
 
1138
"               <DDD/>\n"
 
1139
"          </CCC>\n"
 
1140
"     </AAA>\n"
 
1141
},
 
1142
 
 
1143
{
 
1144
"//GGG/following::*",
 
1145
"The ancestor, descendant, following, preceding and self axes partition a document",
 
1146
"     <AAA>\n"
 
1147
"          <BBB>\n"
 
1148
"               <CCC/>\n"
 
1149
"               <ZZZ/>\n"
 
1150
"          </BBB>\n"
 
1151
"          <XXX>\n"
 
1152
"               <DDD>\n"
 
1153
"                    <EEE/>\n"
 
1154
"                    <FFF>\n"
 
1155
"                         <HHH/>\n"
 
1156
"                         <GGG>\n"
 
1157
"                              <JJJ>\n"
 
1158
"                                   <QQQ/>\n"
 
1159
"                              </JJJ>\n"
 
1160
"                              <JJJ/>\n"
 
1161
"                         </GGG>\n"
 
1162
"                         <HHH/>\n"
 
1163
"                    </FFF>\n"
 
1164
"               </DDD>\n"
 
1165
"          </XXX>\n"
 
1166
"          <CCC>\n"
 
1167
"               <DDD/>\n"
 
1168
"          </CCC>\n"
 
1169
"     </AAA>\n"
 
1170
},
 
1171
 
 
1172
{
 
1173
"//GGG/preceding::*",
 
1174
"The ancestor, descendant, following, preceding and self axes partition a document",
 
1175
"     <AAA>\n"
 
1176
"          <BBB>\n"
 
1177
"               <CCC/>\n"
 
1178
"               <ZZZ/>\n"
 
1179
"          </BBB>\n"
 
1180
"          <XXX>\n"
 
1181
"               <DDD>\n"
 
1182
"                    <EEE/>\n"
 
1183
"                    <FFF>\n"
 
1184
"                         <HHH/>\n"
 
1185
"                         <GGG>\n"
 
1186
"                              <JJJ>\n"
 
1187
"                                   <QQQ/>\n"
 
1188
"                              </JJJ>\n"
 
1189
"                              <JJJ/>\n"
 
1190
"                         </GGG>\n"
 
1191
"                         <HHH/>\n"
 
1192
"                    </FFF>\n"
 
1193
"               </DDD>\n"
 
1194
"          </XXX>\n"
 
1195
"          <CCC>\n"
 
1196
"               <DDD/>\n"
 
1197
"          </CCC>\n"
 
1198
"     </AAA>\n"
 
1199
},
 
1200
 
 
1201
{
 
1202
"//GGG/self::*",
 
1203
"The ancestor, descendant, following, preceding and self axes partition a document",
 
1204
"     <AAA>\n"
 
1205
"          <BBB>\n"
 
1206
"               <CCC/>\n"
 
1207
"               <ZZZ/>\n"
 
1208
"          </BBB>\n"
 
1209
"          <XXX>\n"
 
1210
"               <DDD>\n"
 
1211
"                    <EEE/>\n"
 
1212
"                    <FFF>\n"
 
1213
"                         <HHH/>\n"
 
1214
"                         <GGG>\n"
 
1215
"                              <JJJ>\n"
 
1216
"                                   <QQQ/>\n"
 
1217
"                              </JJJ>\n"
 
1218
"                              <JJJ/>\n"
 
1219
"                         </GGG>\n"
 
1220
"                         <HHH/>\n"
 
1221
"                    </FFF>\n"
 
1222
"               </DDD>\n"
 
1223
"          </XXX>\n"
 
1224
"          <CCC>\n"
 
1225
"               <DDD/>\n"
 
1226
"          </CCC>\n"
 
1227
"     </AAA>\n"
 
1228
},
 
1229
 
 
1230
{
 
1231
"//GGG/ancestor::* | //GGG/descendant::* | //GGG/following::* | //GGG/preceding::* | //GGG/self::*",
 
1232
"The ancestor, descendant, following, preceding and self axes partition a document",
 
1233
"     <AAA>\n"
 
1234
"          <BBB>\n"
 
1235
"               <CCC/>\n"
 
1236
"               <ZZZ/>\n"
 
1237
"          </BBB>\n"
 
1238
"          <XXX>\n"
 
1239
"               <DDD>\n"
 
1240
"                    <EEE/>\n"
 
1241
"                    <FFF>\n"
 
1242
"                         <HHH/>\n"
 
1243
"                         <GGG>\n"
 
1244
"                              <JJJ>\n"
 
1245
"                                   <QQQ/>\n"
 
1246
"                              </JJJ>\n"
 
1247
"                              <JJJ/>\n"
 
1248
"                         </GGG>\n"
 
1249
"                         <HHH/>\n"
 
1250
"                    </FFF>\n"
 
1251
"               </DDD>\n"
 
1252
"          </XXX>\n"
 
1253
"          <CCC>\n"
 
1254
"               <DDD/>\n"
 
1255
"          </CCC>\n"
 
1256
"     </AAA>\n"
 
1257
},
 
1258
 
 
1259
{
 
1260
"//BBB[position() mod 2 = 0 ]",
 
1261
"Select even BBB elements",
 
1262
"     <AAA>\n"
 
1263
"          <BBB/>\n"
 
1264
"          <BBB/>\n"
 
1265
"          <BBB/>\n"
 
1266
"          <BBB/>\n"
 
1267
"          <BBB/>\n"
 
1268
"          <BBB/>\n"
 
1269
"          <BBB/>\n"
 
1270
"          <BBB/>\n"
 
1271
"          <CCC/>\n"
 
1272
"          <CCC/>\n"
 
1273
"          <CCC/>\n"
 
1274
"     </AAA>\n"
 
1275
},
 
1276
 
 
1277
{
 
1278
"//BBB[ position() = floor(last() div 2 + 0.5) or position() = ceiling(last() div 2 + 0.5) ]",
 
1279
"Select middle BBB element(s)",
 
1280
"     <AAA>\n"
 
1281
"          <BBB/>\n"
 
1282
"          <BBB/>\n"
 
1283
"          <BBB/>\n"
 
1284
"          <BBB/>\n"
 
1285
"          <BBB/>\n"
 
1286
"          <BBB/>\n"
 
1287
"          <BBB/>\n"
 
1288
"          <BBB/>\n"
 
1289
"          <CCC/>\n"
 
1290
"          <CCC/>\n"
 
1291
"          <CCC/>\n"
 
1292
"     </AAA>\n"
 
1293
},
 
1294
 
 
1295
{
 
1296
"//CCC[ position() = floor(last() div 2 + 0.5) or position() = ceiling(last() div 2 + 0.5) ]",
 
1297
"Select middle CCC element(s)",
 
1298
"     <AAA>\n"
 
1299
"          <BBB/>\n"
 
1300
"          <BBB/>\n"
 
1301
"          <BBB/>\n"
 
1302
"          <BBB/>\n"
 
1303
"          <BBB/>\n"
 
1304
"          <BBB/>\n"
 
1305
"          <BBB/>\n"
 
1306
"          <BBB/>\n"
 
1307
"          <CCC/>\n"
 
1308
"          <CCC/>\n"
 
1309
"          <CCC/>\n"
 
1310
"     </AAA>\n"
 
1311
},
 
1312
 
 
1313
{  //end data
 
1314
NULL,
 
1315
NULL,
 
1316
NULL,
 
1317
}
 
1318
 
 
1319
};
 
1320
 
 
1321
 
 
1322
 
 
1323
bool doStringTest(char *str)
 
1324
{
 
1325
    XPathParser xp;
 
1326
    xp.setDebug(true);
 
1327
 
 
1328
    if (!xp.parse(str))
 
1329
        return false;
 
1330
 
 
1331
 
 
1332
    return true;
 
1333
}
 
1334
 
 
1335
 
 
1336
 
 
1337
bool doStringTests()
 
1338
{
 
1339
    for (XpathTest *xpt = xpathTests ; xpt->xpathStr ; xpt++)
 
1340
        {
 
1341
        if (!doStringTest(xpt->xpathStr))
 
1342
            return false;
 
1343
        }
 
1344
    return true;
 
1345
}
 
1346
 
 
1347
void dumpDoc(Document *doc)
 
1348
{
 
1349
    ls::DOMImplementationLSImpl domImpl;
 
1350
    ls::LSSerializer &serializer = domImpl.createLSSerializer();
 
1351
    ls::LSOutput output = domImpl.createLSOutput();
 
1352
    io::StdWriter writer;
 
1353
    output.setCharacterStream(&writer);
 
1354
    serializer.write(doc, output);
 
1355
}
 
1356
 
 
1357
 
 
1358
bool doXmlTest(XpathTest *xpt)
 
1359
{
 
1360
    //### READ
 
1361
    ls::DOMImplementationLSImpl domImpl;
 
1362
    ls::LSInput input = domImpl.createLSInput();
 
1363
    ls::LSParser &parser = domImpl.createLSParser(0, "");
 
1364
    input.setStringData(xpt->xml);
 
1365
    Document *doc = parser.parse(input);
 
1366
 
 
1367
    //### XPATH
 
1368
    XPathParser xp;
 
1369
    xp.setDebug(true);
 
1370
 
 
1371
    org::w3c::dom::NodeList list = xp.evaluate(doc, xpt->xpathStr);
 
1372
    for (unsigned int i=0 ; i<list.getLength() ; i++)
 
1373
        {
 
1374
        org::w3c::dom::Node *n = list.item(i);
 
1375
        }
 
1376
 
 
1377
    //dumpDoc(doc);
 
1378
 
 
1379
    delete doc;
 
1380
    return true;
 
1381
}
 
1382
 
 
1383
bool doXmlTests()
 
1384
{
 
1385
    for (XpathTest *xpt = xpathTests ; xpt->xpathStr ; xpt++)
 
1386
        {
 
1387
        if (!doXmlTest(xpt))
 
1388
            return false;
 
1389
        }
 
1390
    return true;
 
1391
}
 
1392
 
 
1393
bool doTests()
 
1394
{
 
1395
    /*
 
1396
    if (!doStringTests())
 
1397
        {
 
1398
        printf("## Failed string tests\n");
 
1399
        return false;
 
1400
        }
 
1401
    */
 
1402
    if (!doXmlTests())
 
1403
        {
 
1404
        printf("## Failed xml tests\n");
 
1405
        return false;
 
1406
        }
 
1407
    return true;
 
1408
}
 
1409
 
 
1410
 
 
1411
 
 
1412
int main(int argc, char **argv)
 
1413
{
 
1414
    doTests();
 
1415
    return 0;
 
1416
}