Home | History | Annotate | Download | only in xpath
      1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
      2 <html>
      3 <head>
      4 <link rel="stylesheet" href="../js/resources/js-test-style.css">
      5 <script src="../js/resources/js-test-pre.js"></script>
      6 </head>
      7 <body>
      8 <div id="console"></div>
      9 
     10 <script>
     11     doc = (new DOMParser).parseFromString(
     12         '<?xml version="1.0" encoding="ISO-8859-1"?>' +
     13         '<!DOCTYPE doc []>' +
     14         '<?xml-stylesheet "Data"  ?>' +
     15         '<!' + '-- comment -->' +
     16         '<doc attr="&lt;&amp;nbsp;>">0  <elem>1</elem><!' + '--  comment  -->a<![CDATA[-cdata-]]>b<elem>2</elem><empty></empty></doc>',
     17         'application/xml');
     18 
     19     PI = doc.firstChild;
     20     while (PI.nodeType != Node.PROCESSING_INSTRUCTION_NODE)
     21         PI = PI.nextSibling;
     22 
     23     COMMENT = doc.firstChild;
     24     while (COMMENT.nodeType != Node.COMMENT_NODE)
     25         COMMENT = COMMENT.nextSibling;
     26 
     27     ATTR = doc.documentElement.getAttributeNode("attr");
     28 
     29     CDATA = doc.documentElement.firstChild;
     30     while (CDATA.nodeType != Node.CDATA_SECTION_NODE)
     31         CDATA = CDATA.nextSibling;
     32 
     33     TEXT = doc.documentElement.firstChild;
     34     
     35     EMPTY = doc.documentElement.lastChild;
     36 
     37     shouldBe("doc.evaluate('.', doc, null, XPathResult.STRING_TYPE, null).stringValue", "'0  1a-cdata-b2'");
     38     shouldBe("doc.evaluate('.', doc.documentElement, null, XPathResult.STRING_TYPE, null).stringValue", "'0  1a-cdata-b2'");
     39     shouldBe("doc.evaluate('.', PI, null, XPathResult.STRING_TYPE, null).stringValue", "'\"Data\"  '");
     40     shouldBe("doc.evaluate('.', COMMENT, null, XPathResult.STRING_TYPE, null).stringValue", "' comment '");
     41     shouldBe("doc.evaluate('.', CDATA, null, XPathResult.STRING_TYPE, null).stringValue", "'-cdata-'");
     42     shouldBe("doc.evaluate('.', TEXT, null, XPathResult.STRING_TYPE, null).stringValue", "'0  '");
     43     shouldBe("doc.evaluate('.', EMPTY, null, XPathResult.STRING_TYPE, null).stringValue", "''");
     44     shouldBe("doc.evaluate('.', ATTR, null, XPathResult.STRING_TYPE, null).stringValue", "'<&nbsp;>'");
     45 
     46     var successfullyParsed = true;
     47 
     48 </script>
     49 <script src="../js/resources/js-test-post.js"></script>
     50 </body>
     51 </html>
     52