nsCOMPtr<nsILoadGroup> loadGroup; nsCOMPtr<nsIURI> loaderUri; loaderDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); loaderDocument->GetDocumentURL(getter_AddRefs(loaderUri));
nsCOMPtr<nsILoadGroup> loadGroup = loaderDocument->GetDocumentLoadGroup(); nsIURI *loaderUri = loaderDocument->GetDocumentURL();
txParseDocumentFromURI(const nsAString& aHref, const nsAString& aReferrer,                       Document* aLoader, nsAString& aErrMsg,                       Document** aResult){    NS_ENSURE_ARG_POINTER(aResult);    *aResult = nsnull;#ifndef TX_EXE    nsCOMPtr<nsIURI> documentURI;    nsresult rv = NS_NewURI(getter_AddRefs(documentURI), aHref);    NS_ENSURE_SUCCESS(rv, rv);    nsCOMPtr<nsIDOMDocument> theDocument;    nsCOMPtr<nsIDocument> loaderDocument =        do_QueryInterface(aLoader->getNSObj());    nsCOMPtr<nsILoadGroup> loadGroup;    nsCOMPtr<nsIURI> loaderUri;    loaderDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));    loaderDocument->GetDocumentURL(getter_AddRefs(loaderUri));    NS_ENSURE_TRUE(loaderUri, NS_ERROR_FAILURE);    nsCOMPtr<nsIChannel> channel;    rv = NS_NewChannel(getter_AddRefs(channel), documentURI, nsnull,                       loadGroup);    NS_ENSURE_SUCCESS(rv, rv);    nsCOMPtr<nsIHttpChannel> http = do_QueryInterface(channel);    if (http) {        nsCOMPtr<nsIURI> refUri;        NS_NewURI(getter_AddRefs(refUri), aReferrer);        if (refUri) {            http->SetReferrer(refUri);        }        http->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),	                                    NS_LITERAL_CSTRING("text/xml,application/xml,application/xhtml+xml,*/*;q=0.1"),                               PR_FALSE);    }    nsCOMPtr<nsISyncLoadDOMService> loader =      do_GetService("@mozilla.org/content/syncload-dom-service;1", &rv);    NS_ENSURE_SUCCESS(rv, rv);    rv = loader->LoadDocumentAsXML(channel, loaderUri, getter_AddRefs(theDocument));    if (NS_FAILED(rv) || !theDocument) {        aErrMsg.Append(NS_LITERAL_STRING("Document load of ") +                        aHref + NS_LITERAL_STRING(" failed."));        return rv;    }    *aResult = new Document(theDocument);    if (!*aResult) {        return NS_ERROR_FAILURE;    }    return NS_OK;#else    istream* xslInput = URIUtils::getInputStream(aHref, aErrMsg);    if (!xslInput) {        return NS_ERROR_FAILURE;    }    return txParseFromStream(*xslInput, aHref, aErrMsg, aResult);#endif}