Home | History | Annotate | Download | only in py-dom-xpath
      1 <html>
      2 <head>
      3 <link rel="stylesheet" href="../../js/resources/js-test-style.css">
      4 <script src="../../js/resources/js-test-pre.js"></script>
      5 <script src="../xpath-test-pre.js"></script>
      6 </head>
      7 <body>
      8 <div id="console"></div>
      9 
     10 <script>
     11 var doc = (new DOMParser).parseFromString(
     12     '<doc id="0">' +
     13         '<item id="1" />' +
     14         '<group id="g1">' +
     15             '<item id="2" />' +
     16             '<group id="g2">' +
     17                 '<item id="3" />' +
     18             '</group>' +
     19             '<item id="4" />' +
     20             '<item id="5" />' +
     21         '</group>' +
     22         '<item id="6" />' +
     23         '<choice index="2" />' +
     24    '</doc>',
     25     'application/xml');
     26 
     27 var ROOT = doc.documentElement;
     28 var I1 = ROOT.firstChild;
     29 var G1 = I1.nextSibling;
     30 var I2 = G1.firstChild;
     31 var G2 = I2.nextSibling;
     32 var I3 = G2.firstChild;
     33 var I4 = G2.nextSibling;
     34 var I5 = I4.nextSibling;
     35 var I6 = G1.nextSibling;
     36 
     37 test(doc, doc.documentElement, '//item[@id >= 2 and @id <= 4]', [I2, I3, I4]);
     38 test(doc, doc.documentElement, '/doc/child::item[1]', [I1]);
     39 test(doc, doc.documentElement, '//group[@id="g2"]/ancestor::*[1]', [G1]);
     40 test(doc, doc.documentElement, '//item[@id="2"]/following-sibling::item[1]', [I4]);
     41 test(doc, doc.documentElement, '//item[@id="5"]/preceding-sibling::item[1]', [I4]);
     42 test(doc, doc.documentElement, '//group[@id="g2"]/following::item[1]', [I4]);
     43 test(doc, doc.documentElement, '//group[@id="g2"]/preceding::item[1]', [I2]);
     44 test(doc, doc.documentElement, '//group[@id="g1"]/descendant-or-self::item[1]', [I2]);
     45 test(doc, doc.documentElement, '//group[@id="g2"]/ancestor-or-self::*[1]', [G2]);
     46 test(doc, doc.documentElement, '//group/descendant::item[number(//choice/@index)*2]', [I5]);
     47 test(doc, doc.documentElement, '(//item[@id="5"]/preceding-sibling::item)[1]', [I2]);
     48 
     49 
     50 var successfullyParsed = true;
     51 
     52 
     53 
     54 
     55 
     56