if (doctype != null && doctype.getOwnerDocument() != null) {
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
DOMMessageFormatter.formatMessage(
DOMMessageFormatter.XML_DOMAIN,
"WRONG_DOCUMENT_ERR", null));
}
DocumentImpl doc = new WMLDocumentImpl(doctype);
// If namespaceURI and qualifiedName are null return a Document with no document element.
if (qualifiedName != null || namespaceURI != null) {
Element e = doc.createElementNS(namespaceURI, qualifiedName);
doc.appendChild(e);
}
return doc;