8

I’m trying to load local XML files with a remote XSL stylesheet. IE seems to handle this just fine but not firefox. Is there a fix for this?

6 Answers 6

8

If it's not a syntax problem, I think it's a same origin policy issue. Firefox (and also Chrome and IE9) doesn't transform a local XML with a remote XSLT for security reasons. It gives an unknown error 805303f4. Imagine that the XSLT could produce malicious JavaScript, embedded in the HTML output code.

Solutions, if you are the developer:

  • make the transformation on the server side and give the user the link to the output HTML
  • download locally (on the background) both the XML and the XSLT and then open the XML for the user

I noticed that CSS and image files can remain on the server without restrictions.

1
  • 3
    So what? Lots of HTML pages point to JS scripts on remote sites. Why can't an XML page point to an XSL on a remote site?
    – Archie
    Commented Feb 8, 2013 at 21:36
6

You could also change this setting on firefox:

  1. about.config
  2. Accept security warning (and be careful :-))
  3. Look for security.fileuri.strict_origin_policy
  4. Set it to false
1
  • 1
    But be aware that this fix will only work on your own browser.
    – Ren
    Commented Oct 29, 2012 at 12:27
3

On the original question: If you get this error with Firefox when opening your XML document:

Error loading stylesheet: An unknown error has occurred (805303f4)

and if the XSLT stylesheet is referenced in the xml-stylesheet processing instruction using an absolute URL to a site different than the site of the XML document, then one solution can be to make Firefox use CORS by installing the Force CORS add-on. Of course, this requires that the server of the XSLT file supports CORS as well.

This made the difference for me (for the case of a local XML file referencing a remote XSLT using an absolute URL).

I also have the same-origin policy for file URIs turned off in Firefox by setting in about:config:

security.fileuri.strict_origin_policy = false

but that did not do the trick in this case (and can even be set to true for this case).

2

A few things to check:

Check that you're using the right mime-type and character encoding on the server side. Firefox will work out the encoding for itself when loading a local file, but will honour the server mime-type/encoding declaration when requesting from the server.

I've seen a few posts (eg here) that claim that Firefox simply doesn't support loading remote XSL templates using absolute paths. I doubt this, and suspect it's more likely the mime issue as per above leading them to believe this, but it might be worth asking Mozilla about this directly.

Finally, have you tested that the XSL stylesheet works when pulled locally? And can you confirm that it is really XSLT, and not one of Microsoft's bizarre IE-only XSL variants, such as WD-XSL?

3
  • Hi, I have the same issue now and I am not sure which is the right mime-type to use on the server side. Right now i have <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" doctype-public="XSLT-compat" encoding="UTF-8" indent="no" omit-xml-declaration="yes" /> on the xslt file which is remote. It does work when pulled locally.
    – Pradep
    Commented Nov 6, 2012 at 19:26
  • I have the same xsl locally and remotely. The xml will only render when the xsl referenced is local.
    – urnenfeld
    Commented Jan 5, 2019 at 16:07
  • @urnenfeld see bluish's answer re same origin policy.
    – imoatama
    Commented Jan 21, 2019 at 6:36
1

I've had issues with Firefox performing the transform correctly, but was able to fix it by adding the XHTML namespace.

See the following for more info: How can I make XSLT work in chrome?

0

I have solved exactly same problem - it seems it was somehow related to the "Same origin policy". Domains http://someting.org and http://www.someting.org are not the same - my problem was referencing the .xsl stylesheet using the first variant (without the "www." part). After I've added the "www." part to my .xls stylesheet url, everything works fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.