1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2 <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">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8"/>
5 <title>XMLSerializer() namespace test
</title>
7 window
.addEventListener("load", function() {
9 testRunner
.dumpAsText();
11 var xs
= new XMLSerializer();
12 var content
= document
.getElementById('content');
13 content
.firstChild
.nodeValue
= xs
.serializeToString(document
.getElementById('input'));
16 var d
= document
.implementation
.createDocument("urn:foo-ns", "foo:root", null);
17 if (!d
.documentElement
) {
18 // This shouldn't happen, since DomImplementation.createDocument
19 // is supposed to create the root element. But in Safari, it's required.
20 d
.appendChild(d
.createElementNS("urn:foo-ns", "foo:root"));
22 var root
= d
.documentElement
;
23 root
.setAttributeNS("urn:foo-ns", "foo:type", "test")
25 var c
= d
.createElementNS(null, "child");
28 c
.setAttributeNS("urn:foo-ns", "foo:name", "one");
29 c
.setAttributeNS("urn:bar-ns", "bar:name", "two");
30 var attr
= d
.createAttributeNS(null, "name");
32 c
.setAttributeNode(attr
);
34 window
.alert("foo:name is " + c
.getAttributeNS("urn:foo-ns", "name") + " and should be one");
35 window
.alert("bar:name is " + c
.getAttributeNS("urn:bar-ns", "name") + " and should be two");
36 window
.alert("name is " + c
.getAttributeNS(null, "name") + " and should be three");
37 window
.alert("node is " + d
.getElementsByTagNameNS(null, "child").item(0).nodeName
+ " and should be child");
38 window
.alert(xs
.serializeToString(d
));
43 <pre id=
"content">foo
</pre>
46 <foo:node xmlns=
"http://baz.com" foo:
name=
"foo_name" bar:
name=
"bar_name">
47 <node foo:
name=
"foo_name">
48 <bar:node xmlns:
bar=
"http://bar2.com"/>