1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml" > 3 <head> 4 <title>Namespace Resolver Test Case</title> 5 </head> 6 <body> 7 <div id="result">FAILURE</div> 8 <script type="text/javascript"><![CDATA[ 9 if (window.layoutTestController) 10 layoutTestController.dumpAsText(); 11 12 function nsResolver(sPrefix) { 13 switch (sPrefix) { 14 case "foo": 15 return "http://www.example.com"; 16 break; 17 default: 18 return null; 19 break; 20 } 21 } 22 23 var sXml = "<root xmlns='http://www.example.com'><child>SUCCESS</child></root>"; 24 var oXmlDom = (new DOMParser()).parseFromString(sXml, "text/xml"); 25 26 try { 27 28 var oResult = oXmlDom.evaluate("foo:child/text()", oXmlDom.documentElement, nsResolver, 29 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); 30 31 document.getElementById("result").textContent = oResult.iterateNext().nodeValue; 32 33 } catch (ex) { 34 document.getElementById("result").textContent = ex; 35 } 36 ]]></script> 37 38 </body> 39 </html> 40