| <body> |
| <script> |
| if (window.layoutTestController) |
| layoutTestController.dumpAsText(); |
| |
| src = '<doc><elem>a<![CDATA[b]]>c</elem></doc>'; |
| doc = (new DOMParser).parseFromString(src, "application/xml"); |
| |
| elem = doc.documentElement.firstChild; |
| aText = elem.firstChild; |
| bText = elem.firstChild.nextSibling; |
| cText = elem.lastChild; |
| |
| function test(expr, context) { |
| nodeset = doc.evaluate(expr, context, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); |
| str = ""; |
| while (currNode = nodeset.iterateNext()) { |
| if (str) |
| str += " "; |
| str += currNode.nodeValue; |
| } |
| |
| document.write(expr + ", " + (context.nodeValue ? context.nodeValue : context) + ": \"" + str + "\"<br>"); |
| } |
| |
| document.write("<xmp>" + src + "</xmp>"); |
| |
| test("child::*", elem); |
| test("child::node()", elem); |
| test("descendant::*", elem); |
| test("descendant::node()", elem); |
| test("descendant::node()[2]", elem); |
| test("ancestor-or-self::node()", bText); |
| test("ancestor-or-self::*", bText); |
| test("ancestor-or-self::node()", aText); |
| test("ancestor-or-self::*", aText); |
| test("following::node()", elem); |
| test("following::node()", aText); |
| test("following::text()", aText); |
| test("following::node()", bText); |
| test("following-sibling::node()", elem); |
| test("following-sibling::node()", aText); |
| test("following-sibling::text()", aText); |
| test("following-sibling::node()", bText); |
| test("preceding::node()", bText); |
| test("preceding-sibling::node()", bText); |
| test("preceding::node()", cText); |
| test("preceding::text()", cText); |
| test("preceding-sibling::node()", cText); |
| test("preceding-sibling::text()", cText); |
| test("self::node()", bText); |
| |
| var successfullyParsed = true; |
| |
| </script> |
| </body> |