OLD | NEW |
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/
DTD/xhtml11.dtd"> | 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"> | 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"> |
3 <head> | 3 <head> |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> |
5 <title>XMLSerializer() namespace test</title> | 5 <title>XMLSerializer() namespace test</title> |
6 <script> | 6 <script> |
7 window.addEventListener("load", function() { | 7 window.addEventListener("load", function() { |
8 if (window.testRunner) | 8 if (window.testRunner) |
9 testRunner.dumpAsText(); | 9 testRunner.dumpAsText(); |
10 | 10 |
11 var xs = new XMLSerializer(); | 11 var xs = new XMLSerializer(); |
12 var content = document.getElementById('content'); | 12 var content = document.getElementById('content'); |
13 content.firstChild.nodeValue = xs.serializeToString(document.getElementById(
'input')); | 13 content.firstChild.nodeValue = xs.serializeToString(document.getElementById(
'input')); |
14 | 14 |
15 // Original test | 15 // Original test |
16 var d = document.implementation.createDocument("urn:foo-ns", "foo:root", nul
l); | 16 var d = document.implementation.createDocument("urn:foo-ns", "foo:root", nul
l); |
17 if (!d.documentElement) { | 17 if (!d.documentElement) { |
18 // This shouldn't happen, since DomImplementation.createDocument | 18 // This shouldn't happen, since DomImplementation.createDocument |
19 // is supposed to create the root element. But in Safari, it's required
. | 19 // is supposed to create the root element. But in Safari, it's required
. |
20 d.appendChild(d.createElementNS("urn:foo-ns", "foo:root")); | 20 d.appendChild(d.createElementNS("urn:foo-ns", "foo:root")); |
21 } | 21 } |
22 var root = d.documentElement; | 22 var root = d.documentElement; |
23 root.setAttributeNS("urn:foo-ns", "foo:type", "test") | 23 root.setAttributeNS("urn:foo-ns", "foo:type", "test") |
24 | 24 |
25 var c = d.createElementNS(null, "child"); | 25 var c = d.createElementNS(null, "child"); |
26 root.appendChild(c); | 26 root.appendChild(c); |
27 | 27 |
28 c.setAttributeNS("urn:foo-ns", "foo:name", "one"); | 28 c.setAttributeNS("urn:foo-ns", "foo:name", "one"); |
29 c.setAttributeNS("urn:bar-ns", "bar:name", "two"); | 29 c.setAttributeNS("urn:bar-ns", "bar:name", "two"); |
30 var attr = d.createAttribute("name"); | 30 var attr = d.createAttributeNS(null, "name"); |
31 var text = d.createTextNode("three"); | 31 var text = d.createTextNode("three"); |
32 attr.appendChild(text); | 32 attr.appendChild(text); |
33 c.setAttributeNode(attr); | 33 c.setAttributeNode(attr); |
34 | 34 |
35 window.alert("foo:name is " + c.getAttributeNS("urn:foo-ns", "name") + " and
should be one"); | 35 window.alert("foo:name is " + c.getAttributeNS("urn:foo-ns", "name") + " and
should be one"); |
36 window.alert("bar:name is " + c.getAttributeNS("urn:bar-ns", "name") + " and
should be two"); | 36 window.alert("bar:name is " + c.getAttributeNS("urn:bar-ns", "name") + " and
should be two"); |
37 window.alert("name is " + c.getAttributeNS(null, "name") + " and should be t
hree"); | 37 window.alert("name is " + c.getAttributeNS(null, "name") + " and should be t
hree"); |
38 window.alert("node is " + d.getElementsByTagNameNS(null, "child").item(0).no
deName + " and should be child"); | 38 window.alert("node is " + d.getElementsByTagNameNS(null, "child").item(0).no
deName + " and should be child"); |
39 window.alert(xs.serializeToString(d)); | 39 window.alert(xs.serializeToString(d)); |
40 }, false); | 40 }, false); |
41 </script> | 41 </script> |
42 </head> | 42 </head> |
43 <body> | 43 <body> |
44 <pre id="content">foo</pre> | 44 <pre id="content">foo</pre> |
45 <div id="input"> | 45 <div id="input"> |
46 <div> | 46 <div> |
47 <foo:node xmlns="http://baz.com" foo:name="foo_name" bar:name="bar_name"
> | 47 <foo:node xmlns="http://baz.com" foo:name="foo_name" bar:name="bar_name"
> |
48 <node foo:name="foo_name"> | 48 <node foo:name="foo_name"> |
49 <bar:node xmlns:bar="http://bar2.com"/> | 49 <bar:node xmlns:bar="http://bar2.com"/> |
50 </node> | 50 </node> |
51 </foo:node> | 51 </foo:node> |
52 </div> | 52 </div> |
53 <bar:node> | 53 <bar:node> |
54 <br /> | 54 <br /> |
55 </bar:node> | 55 </bar:node> |
56 </div> | 56 </div> |
57 </body> | 57 </body> |
58 </html> | 58 </html> |
OLD | NEW |