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 xmlns:a="http://www.example.com/a">' +
     13     '    <element attribute="&quot;value&quot;">&lt;text&gt;</element>' +
     14     '    followed' +
     15     '    <?processing  instruction ?>' +
     16     '    by' +
     17     '    <!-- comment -->' +
     18     '    more text' +
     19     '    <a:item attribute="1" a:attribute="2" />' +
     20     '</doc>',
     21     'application/xml');
     22 var nsResolver = doc.createNSResolver(doc.documentElement);
     23 
     24 test(doc, doc.documentElement, 'normalize-space(/)', "<text> followed by more text", nsResolver);
     25 test(doc, doc.documentElement, 'name(/)', "", nsResolver);
     26 test(doc, doc.documentElement, 'local-name(/)', "", nsResolver);
     27 test(doc, doc.documentElement, 'namespace-uri(/)', "", nsResolver);
     28 
     29 test(doc, doc.documentElement, 'normalize-space(/doc)', "<text> followed by more text", nsResolver);
     30 
     31 test(doc, doc.documentElement, 'string(//a:item)', "", nsResolver);
     32 test(doc, doc.documentElement, 'name(//a:item)', "a:item", nsResolver);
     33 test(doc, doc.documentElement, 'local-name(//a:item)', "item", nsResolver);
     34 test(doc, doc.documentElement, 'namespace-uri(//a:item)', "http://www.example.com/a", nsResolver);
     35 
     36 test(doc, doc.documentElement, 'string(//@attribute)', '\"value\"', nsResolver);
     37 test(doc, doc.documentElement, 'name(//@a:attribute)', 'a:attribute', nsResolver);
     38 test(doc, doc.documentElement, 'local-name(//@a:attribute)', 'attribute', nsResolver);
     39 test(doc, doc.documentElement, 'namespace-uri(//@a:attribute)', 'http://www.example.com/a', nsResolver);
     40 
     41 test(doc, doc.documentElement, 'string(//processing-instruction())', 'instruction ', nsResolver);
     42 test(doc, doc.documentElement, 'name(//processing-instruction())', 'processing', nsResolver);
     43 test(doc, doc.documentElement, 'local-name(//processing-instruction())', 'processing', nsResolver);
     44 test(doc, doc.documentElement, 'namespace-uri(//processing-instruction())', '', nsResolver);
     45 
     46 test(doc, doc.documentElement, 'string(//comment())', ' comment ', nsResolver);
     47 test(doc, doc.documentElement, 'name(//comment())', '', nsResolver);
     48 test(doc, doc.documentElement, 'local-name(//comment())', '', nsResolver);
     49 test(doc, doc.documentElement, 'namespace-uri(//comment())', '', nsResolver);
     50 
     51 test(doc, doc.documentElement, 'string(//element/text())', '<text>', nsResolver);
     52 test(doc, doc.documentElement, 'name(//element/text())', '', nsResolver);
     53 test(doc, doc.documentElement, 'local-name(//element/text())', '', nsResolver);
     54 test(doc, doc.documentElement, 'namespace-uri(//element/text())', '', nsResolver);
     55 
     56 
     57 var successfullyParsed = true;
     58 
     59 </script>
     60 <script src="../../js/resources/js-test-post.js"></script>
     61 </body>
     62 </html>
     63