11

I have an XML file which is styled using an XSL file. When opening the XML file in Firefox, I get no problems, (although strangely, sometimes it will only display after I hit "reload"), but in Chrome/Chromium I get the error message:

Resource interpreted as Stylesheet but transferred with MIME type application/xml

The files are up here: http://jonreeve.com/test/mike/biblexml.xml

I don't think there's anything irregular about the XML/XSL syntax, and the links all seem to be worded correctly, too.

Furthermore, this doesn't seem to be similar to all the similar-looking questions here, which seem to be dealing with javascript and other applications. This one is just pure XML/XSL.

Jonathan
  • 10,571
  • 13
  • 67
  • 103

2 Answers2

9

The XSLT 1.0 spec clearly states that the appropriate MIME type for XSLT is text/xml and application/xml

The MIME media types text/xml and application/xml [RFC2376] should be used for XSLT stylesheets. It is possible that a media type will be registered specifically for XSLT stylesheets; if and when it is, that media type may also be used.

In XSLT 2.0 this was changed to application/xslt+xml.

But

In the absence of a registered media type for XSLT stylesheets, some vendors' products have adopted different conventions, notably type="text/xsl".

Chrome 32.0.1700.107 returns errors:

Resource interpreted as Stylesheet but transferred with MIME type text/xml;

Resource interpreted as Stylesheet but transferred with MIME type application/xml;

Resource interpreted as Stylesheet but transferred with MIME type application/xslt+xml;

Chrome returns no error if text/xsl type passed.

Elazar
  • 20,415
  • 4
  • 46
  • 67
Mikl
  • 673
  • 9
  • 19
  • 2
    There is an open Chrome issue https://bugs.chromium.org/p/chromium/issues/detail?id=447866 for it. Voting it will uprise its priority. – Binyamin Jul 05 '18 at 08:30
1

XSLT should be delivered with MIME type application/xslt+xml, not application/xml. You should configure your server to do so. You need a .htaccess file that contains the line

AddType application/xslt+xml .xsl

This associates the extension .xsl with the correct MIME type. If you already have a .htaccess file in the XSLT's directory or in a parent directory, you can add the line. Otherwise, create such a file.

Thomas W
  • 14,757
  • 6
  • 48
  • 67
  • 1
    Adding an .htaccess file gives me a "Forbidden" message with the note "Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request." I tried making the files executable, but this has no effect. – Jonathan Dec 07 '12 at 18:18