<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script type="text/javascript">
    function runTest()
    {
        if (window.testRunner)
            testRunner.dumpAsText();

        var xmlns = "http://www.w3.org/XML/1998/namespace";

        var serializer = new XMLSerializer();

        var doc = document.implementation.createDocument("http://www.example.com/ns1","doc",null);
        doc.documentElement.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:p","http://www.example.com/p");
        doc.documentElement.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:NS2","http://www.example.com/ns2");
        var test = doc.createElementNS("http://www.example.com/ns2","test");
        doc.documentElement.appendChild(test);
        test.setAttributeNS("http://www.example.com/q","p:a","I am q");
        test.setAttributeNS("http://www.example.com/p","p:b","I am p");
        test.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.example.com/xlink");
        test.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","#foo");

        var xmlString = serializer.serializeToString(doc);

        var outputText = document.getElementById("output");
        outputText.textContent = xmlString;
    }
    </script>
</head>
    <body onload="runTest()">
        <div id="target"/>
        <div id="output"/>
    </body>
</html>
