if (nsnull == gGlobalDocLoader) { NS_NEWXPCOM(gGlobalDocLoader, nsDocLoaderImpl); if (nsnull == gGlobalDocLoader) { rv = NS_ERROR_OUT_OF_MEMORY; goto done; }  NS_ADDREF(gGlobalDocLoader);
typeIndex = 0; while(gXMLTypes[typeIndex]) { if (0== PL_strcmp(gXMLTypes[typeIndex++], aContentType)) { return CreateXMLDocument(aURL, aCommand, aContainer, aDocListener, aDocViewer); }
nsDocumentLoaderFactory::CreateInstance(nsISupports* aOuter,                                        const nsIID& aIID,                                        void** aResult){    nsresult rv;    nsIDocumentLoader* inst;    static nsDocLoaderImpl* gGlobalDocLoader = nsnull;    if (nsnull == aResult) {        rv = NS_ERROR_NULL_POINTER;        goto done;    }    *aResult = nsnull;    if (nsnull != aOuter) {        rv = NS_ERROR_NO_AGGREGATION;        goto done;    }    if (nsnull == gGlobalDocLoader) {        NS_NEWXPCOM(gGlobalDocLoader, nsDocLoaderImpl);        if (nsnull == gGlobalDocLoader) {            rv = NS_ERROR_OUT_OF_MEMORY;            goto done;        }        NS_ADDREF(gGlobalDocLoader);    // RefCount = 1    }    rv = gGlobalDocLoader->CreateDocumentLoader(&inst);    if (NS_OK != rv) {        rv = NS_ERROR_OUT_OF_MEMORY;        goto done;    }    *aResult = inst;done:    return rv;}