43 lines
1.8 KiB
HTML
43 lines
1.8 KiB
HTML
<!DOCTYPE html>
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<script type="text/javascript">
|
|
function runTest()
|
|
{
|
|
if (window.testRunner)
|
|
testRunner.dumpAsText();
|
|
|
|
var svgns = "http://www.w3.org/2000/svg";
|
|
var xlinkns = "http://www.w3.org/1999/xlink";
|
|
|
|
var serializer = new XMLSerializer();
|
|
|
|
// Example 1: Create a document with a namespaced attribute but via the DOM API but do not specific a prefix.
|
|
var doc = document.implementation.createDocument(svgns, "svg", null);
|
|
doc.documentElement.setAttributeNS(xlinkns, "href", "#foo");
|
|
var xml = serializer.serializeToString(doc);
|
|
document.getElementById("svgoutput").textContent = xml + "\n";
|
|
|
|
// Example 2: Attempt to fix the document by setting the attribute. The Node.prefix property should now contain "xlink".
|
|
doc = document.implementation.createDocument(svgns, "svg", null);
|
|
doc.documentElement.setAttributeNS(xlinkns, "href", "#foo");
|
|
doc.documentElement.setAttributeNS(xlinkns, "xlink:href", "#foo");
|
|
xml = serializer.serializeToString(doc);
|
|
document.getElementById("svgoutput2").textContent = xml + "\n";
|
|
|
|
// Example 3: Create the document with prefixes specified. The Node.prefix property should now contain "xlink".
|
|
doc = document.implementation.createDocument(svgns, "svg", null);
|
|
doc.documentElement.setAttributeNS(xlinkns, "xlink:href", "#foo");
|
|
xml = serializer.serializeToString(doc);
|
|
document.getElementById("svgoutput4").textContent = xml + "\n";
|
|
}
|
|
</script>
|
|
</head>
|
|
<body onload="runTest()">
|
|
<div id="svgoutput"></div>
|
|
<div id="svgoutput2"></div>
|
|
<div id="svgoutput3"></div>
|
|
<div id="svgoutput4"></div>
|
|
</body>
|
|
</html>
|