blob: 0924abc7991cd0f0b295e27b2448c1fb14227ae1 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:foo="http://foo.com" xmlns:bar="http://bar.com" version="-//W3C//DTD XHTML 1.1//EN" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>XMLSerializer() namespace test</title>
<script>
window.addEventListener("load", function() {
if (window.testRunner)
testRunner.dumpAsText();
var xs = new XMLSerializer();
var content = document.getElementById('content');
content.firstChild.nodeValue = xs.serializeToString(document.getElementById('input'));
// Original test
var d = document.implementation.createDocument("urn:foo-ns", "foo:root", null);
if (!d.documentElement) {
// This shouldn't happen, since DomImplementation.createDocument
// is supposed to create the root element. But in Safari, it's required.
d.appendChild(d.createElementNS("urn:foo-ns", "foo:root"));
}
var root = d.documentElement;
root.setAttributeNS("urn:foo-ns", "foo:type", "test")
var c = d.createElementNS(null, "child");
root.appendChild(c);
c.setAttributeNS("urn:foo-ns", "foo:name", "one");
c.setAttributeNS("urn:bar-ns", "bar:name", "two");
var attr = d.createAttributeNS(null, "name");
attr.value += "three";
c.setAttributeNode(attr);
window.alert("foo:name is " + c.getAttributeNS("urn:foo-ns", "name") + " and should be one");
window.alert("bar:name is " + c.getAttributeNS("urn:bar-ns", "name") + " and should be two");
window.alert("name is " + c.getAttributeNS(null, "name") + " and should be three");
window.alert("node is " + d.getElementsByTagNameNS(null, "child").item(0).nodeName + " and should be child");
window.alert(xs.serializeToString(d));
}, false);
</script>
</head>
<body>
<pre id="content">foo</pre>
<div id="input">
<div>
<foo:node xmlns="http://baz.com" foo:name="foo_name" bar:name="bar_name">
<node foo:name="foo_name">
<bar:node xmlns:bar="http://bar2.com"/>
</node>
</foo:node>
</div>
<bar:node>
<br />
</bar:node>
</div>
</body>
</html>