Re: Client-side XSLT containing import/include statements does not work in Firefox
Axel Hecht <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Organization | Another Netscape Collabra Server User |
| Message-ID | <[email protected]> |
Daniel Frechette wrote:
> Hi,
>
> I want to perform XSL transformations in Firefox (v1.0.3) and IE (v6) using
> JavaScript. My problem is with the XSL scripts that contain <xsl:import ...>
> or <xsl:include ...> statements. Firefox stalls indefinitely when it calls
> importStylesheet(...) on a script that contains one or both of these
> statements. The code works well on IE and I get the expected results, but
> not on Firefox. Does anyone know what I need to do to get this working?
>
>
> Thank you,
> Daniel
>
> Here is my Javascript code:
>
> function buildPage(iXmlStr, iXslStr) {
> ...
> var xmlDoc = getDom(iXmlStr);
> var xslDoc = getDom(iXslStr);
> html = xslt(xmlDoc, xslDoc);
> ...
> };
>
> function getDom(iXmlStr) {
> if (isIE) {
> var xmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0");
> xmlDoc.loadXML(iXmlStr);
> return xmlDoc;
> }
> return (new DOMParser()).parseFromString(iXmlStr, "text/xml");
> };
>
> function xslt(iXmlDoc, iXslDoc) {
> var html = null;
> try {
> if (isIE) {
> iXmlDoc.async = false;
> iXmlDoc.resolveExternals = false;
> iXslDoc.async = false;
> iXslDoc.resolveExternals = false;
> html = iXmlDoc.transformNode(iXslDoc);
> }
> else {
> var xsltProc = new XSLTProcessor();
> xsltProc.importStylesheet(iXslDoc);
> var resultDoc = xsltProc.transformToDocument(iXmlDoc);
> var xmlSerial = new XMLSerializer;
> html = xmlSerial.serializeToString(resultDoc);
> }
> } catch (e) {
> // Do something
> }
> return html;
> };
>
>
> Here is a sample XSL file:
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fo="http://www.w3.org/1999/XSL/Format">
> <xsl:import href="http://www.myDomain.com/detailForm.xsl"/>
> </xsl:stylesheet>
>
>
just to clear that up, we do not support FO, I hope you're not trying to
get us to display that.
Anyway, are you sure that you're not falling for some same-origin-policy
thing? (Not that that should hang, actually).
that is, the script needs to run off of myDomain.com. Not file nor some
other domain.
If you can create a small testcase on the net, that would sure help us.
Axel