child3.setAttributeNS("http://a1","attr1", "");
child3.setAttributeNS("http://a2","xsl:attr2", "");
child3.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:a1", "http://a1");
child3.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xsl", "http://a2");
Element child4 = doc.createElementNS(null, "child4");
child4.setAttributeNS("http://a1", "xsl:attr1", "");
child4.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "default");
child3.appendChild(child4);
root.appendChild(child3);