3 <script src=
"../../../resources/js-test.js"></script>
4 <script src=
"../xpath-test-pre.js"></script>
7 <div id=
"console"></div>
10 var doc
= (new DOMParser
).parseFromString(
22 '<choice index="2" />' +
26 var ROOT
= doc
.documentElement
;
27 var I1
= ROOT
.firstChild
;
28 var G1
= I1
.nextSibling
;
29 var I2
= G1
.firstChild
;
30 var G2
= I2
.nextSibling
;
31 var I3
= G2
.firstChild
;
32 var I4
= G2
.nextSibling
;
33 var I5
= I4
.nextSibling
;
34 var I6
= G1
.nextSibling
;
36 test(doc
, doc
.documentElement
, '//item[@id >= 2 and @id <= 4]', [I2
, I3
, I4
]);
37 test(doc
, doc
.documentElement
, '/doc/child::item[1]', [I1
]);
38 test(doc
, doc
.documentElement
, '//group[@id="g2"]/ancestor::*[1]', [G1
]);
39 test(doc
, doc
.documentElement
, '//item[@id="2"]/following-sibling::item[1]', [I4
]);
40 test(doc
, doc
.documentElement
, '//item[@id="5"]/preceding-sibling::item[1]', [I4
]);
41 test(doc
, doc
.documentElement
, '//group[@id="g2"]/following::item[1]', [I4
]);
42 test(doc
, doc
.documentElement
, '//group[@id="g2"]/preceding::item[1]', [I2
]);
43 test(doc
, doc
.documentElement
, '//group[@id="g1"]/descendant-or-self::item[1]', [I2
]);
44 test(doc
, doc
.documentElement
, '//group[@id="g2"]/ancestor-or-self::*[1]', [G2
]);
45 test(doc
, doc
.documentElement
, '//group/descendant::item[number(//choice/@index)*2]', [I5
]);
46 test(doc
, doc
.documentElement
, '(//item[@id="5"]/preceding-sibling::item)[1]', [I2
]);