XML error in Firefox. Trying to render HTML

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

XML error in Firefox. Trying to render HTML

MattJanis
Hello, I'm trying to work with XML to have it rendered in both IE and
Firefox. The code I found online uses one HTML file, which renders all
XML files fine in IE 6+, but errors out in FF. Here's a sample of my
code, and I'm wondering if anyone can help provide the solution, and
get this working in Firefox!

The Firefox error is:
Error: ActiveXObject is not defined
Source File: functions.js
Line: 42


Thanks in advance!


        function RenderDocument( pathToXml, pathToXsl )
        {
                var xslt = new ActiveXObject("Msxml2.XSLTemplate"); //
Firefox error
                var xslDoc = new
ActiveXObject("Msxml2.FreeThreadedDOMDocument");
                var xslProc;


                // load xsl
                xslDoc.async = false;
                xslDoc.resolveExternals = false;
                xslDoc.load( pathToXsl );


                xslt.stylesheet = xslDoc;


                // load xml
                var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
                xmlDoc.async = false;
                xmlDoc.resolveExternals = false;
                xmlDoc.preserveWhiteSpace = true;
                xmlDoc.load( pathToXml );


                if(xmlDoc.documentElement == null)
                {
                        //alert ("Could not load XML file " +
pathToXml);
                        location.replace("unknown.html");
                }


                // processor
                xslProc = xslt.createProcessor();
                xslProc.input = xmlDoc;


                // add params
                if(args.sort)
                {
                        xslProc.addParameter("sort", args.sort);
                }
                xslProc.addParameter("xmlFilePath", pathToXml);


                // transform
                xslProc.transform();


                document.write( xslProc.output );
        }

_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: XML error in Firefox. Trying to render HTML

Martin Honnen-3
[hidden email] wrote:

> Hello, I'm trying to work with XML to have it rendered in both IE and
> Firefox. The code I found online uses one HTML file, which renders all
> XML files fine in IE 6+, but errors out in FF. Here's a sample of my
> code, and I'm wondering if anyone can help provide the solution, and
> get this working in Firefox!
>
> The Firefox error is:
> Error: ActiveXObject is not defined
> Source File: functions.js
> Line: 42


>                 var xslt = new ActiveXObject("Msxml2.XSLTemplate"); //

Firefox/Mozilla or other cross platform browsers like Opera don't
support script creation of Windows ActiveX components with new ActiveX.

With Firefox/Mozilla and with Opera 9 if you want to programmatically
execute XSLT transformations then see this documentation
<http://developer.mozilla.org/en/docs/Using_the_Mozilla_JavaScript_interface_to_XSL_Transformations>
And it can't hurt to read
<http://www.mozilla.org/projects/xslt/faq.html>
and first check whether your stylesheets use the namespace
http://www.w3.org/1999/XSL/Transform at all, otherwise neither Mozilla
nor Opera will do anything with them.


--

        Martin Honnen
        http://JavaScript.FAQTs.com/
_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml