13

I'm trying to render XML+XSL 2.0 in browser, returning .xml pages with application/xml content type and .xsl pages with text/xml. Safari is complaining for the main document: "Resource interpreted as document but transferred with MIME type application/xml." (but keeps rendering everything just fine).

I want to get rid of this warning message. What content-types should be used for the XML document?

3
  • 1
    Does "XML+XSL 2.0" mean that you use XSLT 2.0? Is there any browser that supports XSLT 2.0?
    – mzjn
    Commented Jul 16, 2011 at 9:10
  • 1
    No browser support, but Saxon CE (alpha) provides XSLT 2.0 in the browser: saxonica.com Commented Jul 16, 2011 at 16:28
  • 1
    Safari 5 and Chrome 15 work fine with XSLT 2.0 (on Mac)
    – yegor256
    Commented Nov 17, 2011 at 7:43

4 Answers 4

12
+50

I've had success using text/xml with the stylesheet as text/xsl (or perhaps this is OK as text/xml as you have it working). text/xsl is widely recognized, but not "official" (as far as I understand it).

According to RFC 3023: "If an XML document that is, the unprocessed, source XML document is readable by casual users, text/xml is preferable to application/xml. MIME user agents (and web user agents) that do not have explicit support for text/xml will treat it as text/plain, for example, by displaying the XML MIME entity as plain text. application/xml is preferable when the XML MIME entity is unreadable by casual users."

See https://www.rfc-editor.org/rfc/rfc3023#page-16

4
  • text/xsl for an XML document??
    – yegor256
    Commented Nov 18, 2011 at 15:51
  • Sorry - for the stylesheet. And text/xml for the instance document.
    – kennethmay
    Commented Nov 18, 2011 at 15:55
  • According to RFC 3023: "If an XML document that is, the unprocessed, source XML document is readable by casual users, text/xml is preferable to application/xml. MIME user agents (and web user agents) that do not have explicit support for text/xml will treat it as text/plain, for example, by displaying the XML MIME entity as plain text.Application/xml is preferable when the XML MIME entity is unreadable by casual users." tools.ietf.org/html/rfc3023#page-16
    – kennethmay
    Commented Nov 18, 2011 at 15:58
  • Updated answer to reflect above comments.
    – kennethmay
    Commented Nov 18, 2011 at 16:12
9

Peeking into the WebKit source, it's easy to see what MIME types are considered valid for each resource type. It's not a very big list.

The following 4 MIME types are supported for "Documents":

  • text/html
  • text/xml
  • text/plain
  • application/xhtml+xml

There are only 2 valid types for stylesheets:

  • text/css
  • text/xsl

Obviously, the text/html, text/plain, and text/css types don't really apply here.

If you're really just interested in silencing the warnings, sending the .xml document as text/xml and the .xsl document as text/xsl should do the trick.

On the other hand, you concede that everything's rendering fine, so you might consider the "if it ain't broke, don't fix it" strategy.

1

For what it's worth, the correct media type for XSLT would actually be application/xslt+xml, according to https://www.w3.org/TR/2007/REC-xslt20-20070123/#media-type-registration as per the official IANA registry https://www.iana.org/assignments/media-types/media-types.xhtml. And that's not new, the registration dates back to at least 2007. However, browser support for application/xslt+xml is almost non-existent.

-3

Before any transformation i do this in PHP:

header("Content-Type: application/xhtml+xml; charset=utf-8");

the part with uft-8 is important ...

1
  • 3
    That would apply if he did server-side transformation of XML to XHTML, and even then it would be problematic (IE/MSHTML does not support that MIME type). There is no "uft-8", but the "utf-8" in your code is only correct if the output actually is UTF-8-encoded. Which is not a requirement for XHTML. You did not answer the question. Commented Nov 22, 2011 at 17:43

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.