blob: 74f222a1b440cf054c7b963f495403cba1d133c6 [file] [log] [blame]
<html>
<head>
<script src="../../../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]);
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>