From e15cf8bac00a1f1ab9faee8c72e1fa5565345c69 Mon Sep 17 00:00:00 2001 From: "peterv%netscape.com" Date: Tue, 17 Apr 2001 11:13:13 +0000 Subject: [PATCH] Fix for bug 56087 (XSLTProcessor::TransformDocument can't work on existing document). Not part of the default build. r=dr, sr=jst. git-svn-id: svn://10.0.0.236/trunk@92551 18797224-902f-48f8-a5cc-f745e15eee43 --- .../source/xslt/XSLTProcessor.cpp | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp index 1ead8d4d339..444ac8f900f 100644 --- a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp +++ b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp @@ -38,7 +38,7 @@ * Olivier Gerardin * -- Changed behavior of passing parameters to templates * - * $Id: XSLTProcessor.cpp,v 1.42 2001-04-12 14:04:45 peterv%netscape.com Exp $ + * $Id: XSLTProcessor.cpp,v 1.43 2001-04-17 11:13:13 peterv%netscape.com Exp $ */ #include "XSLTProcessor.h" @@ -55,6 +55,10 @@ #include "nsIObserverService.h" #include "nsIURL.h" #include "nsIServiceManager.h" +#include "nsIIOService.h" +#include "nsILoadGroup.h" +#include "nsIChannel.h" +#include "nsNetCID.h" //#include "nslog.h" #else #include "printers.h" @@ -68,7 +72,7 @@ /** * XSLTProcessor is a class for Processing XSL stylesheets * @author Keith Visco - * @version $Revision: 1.42 $ $Date: 2001-04-12 14:04:45 $ + * @version $Revision: 1.43 $ $Date: 2001-04-17 11:13:13 $ **/ /** @@ -1741,6 +1745,24 @@ XSLTProcessor::TransformDocument(nsIDOMNode* aSourceDOM, } Document* xslDocument = new Document(styleDOMDocument); + nsCOMPtr loadGroup; + nsCOMPtr channel; + nsCOMPtr inputDocument(do_QueryInterface(sourceDOMDocument)); + if (inputDocument) { + inputDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + nsCOMPtr serv(do_GetService(NS_IOSERVICE_CONTRACTID)); + if (serv) { + // Create a temporary channel to get nsIDocument->Reset to + // do the right thing. We want the output document to get + // much of the input document's characteristics. + serv->NewChannelFromURI(inputDocument->GetDocumentURL(), + getter_AddRefs(channel)); + } + } + + nsCOMPtr outputDocument(do_QueryInterface(aOutputDoc)); + outputDocument->Reset(channel, loadGroup); + Document* resultDocument = new Document(aOutputDoc); //-- create a new ProcessorState @@ -1770,9 +1792,9 @@ XSLTProcessor::TransformDocument(nsIDOMNode* aSourceDOM, nsCOMPtr anObserverService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &res); if (NS_SUCCEEDED(res)) { Node* docElement = resultDocument->getDocumentElement(); - nsIDOMNode* nsDocElement; + nsISupports* nsDocElement; if (docElement) { - nsDocElement = NS_STATIC_CAST(nsIDOMNode*, docElement->getNSObj()); + nsDocElement = docElement->getNSObj(); } else { nsDocElement = nsnull;