rv = doc->Reset(nsnull, nsnull); if (NS_FAILED(rv)) return NS_ERROR_FAILURE;  if (aDoctype) { nsCOMPtr<nsIDOMNode> tmpNode; doc->AppendChild(aDoctype, getter_AddRefs(tmpNode)); }  if (aQualifiedName.Length() > 0) { nsCOMPtr<nsIDOMElement> root; rv = doc->CreateElementNS(aNamespaceURI, aQualifiedName, getter_AddRefs(root)); if (NS_SUCCEEDED(rv)) { nsCOMPtr<nsIContent> content = do_QueryInterface(root); doc->SetRootContent(content); } }
NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,                  const nsString& aNamespaceURI,                   const nsString& aQualifiedName,                   nsIDOMDocumentType* aDoctype,                  nsIURI* aBaseURI){  // XXX Ignoring the namespace, qualified name, and doctype parameters for now  nsXMLDocument* doc = new nsXMLDocument(aBaseURI);  if (doc == nsnull)    return NS_ERROR_OUT_OF_MEMORY;  return doc->QueryInterface(kIDOMDocumentIID, (void**) aInstancePtrResult);}