Use document.importNode before appendChild.