How about just one line--return document.implementation.createDocument()?