summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/xpath/py-dom-xpath/predicates.html
blob: 557e6f7bbe88ef91ae9f7d3ce4ef098c2cb8e91d (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
<html>
<head>
<link rel="stylesheet" href="../../js/resources/js-test-style.css">
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../xpath-test-pre.js"></script>
</head>
<body>
<div id="console"></div>

<script>
var doc = (new DOMParser).parseFromString(
    '<doc id="0">' +
        '<item id="1" />' +
        '<group id="g1">' +
            '<item id="2" />' +
            '<group id="g2">' +
                '<item id="3" />' +
            '</group>' +
            '<item id="4" />' +
            '<item id="5" />' +
        '</group>' +
        '<item id="6" />' +
        '<choice index="2" />' +
   '</doc>',
    'application/xml');

var ROOT = doc.documentElement;
var I1 = ROOT.firstChild;
var G1 = I1.nextSibling;
var I2 = G1.firstChild;
var G2 = I2.nextSibling;
var I3 = G2.firstChild;
var I4 = G2.nextSibling;
var I5 = I4.nextSibling;
var I6 = G1.nextSibling;

test(doc, doc.documentElement, '//item[@id >= 2 and @id <= 4]', [I2, I3, I4]);
test(doc, doc.documentElement, '/doc/child::item[1]', [I1]);
test(doc, doc.documentElement, '//group[@id="g2"]/ancestor::*[1]', [G1]);
test(doc, doc.documentElement, '//item[@id="2"]/following-sibling::item[1]', [I4]);
test(doc, doc.documentElement, '//item[@id="5"]/preceding-sibling::item[1]', [I4]);
test(doc, doc.documentElement, '//group[@id="g2"]/following::item[1]', [I4]);
test(doc, doc.documentElement, '//group[@id="g2"]/preceding::item[1]', [I2]);
test(doc, doc.documentElement, '//group[@id="g1"]/descendant-or-self::item[1]', [I2]);
test(doc, doc.documentElement, '//group[@id="g2"]/ancestor-or-self::*[1]', [G2]);
test(doc, doc.documentElement, '//group/descendant::item[number(//choice/@index)*2]', [I5]);
test(doc, doc.documentElement, '(//item[@id="5"]/preceding-sibling::item)[1]', [I2]);


var successfullyParsed = true;

</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>