What content-type should be used for XML+XSL presentation?

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://tools.ietf.org/html/rfc3023#page-16


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.

Tags:

Xml

Xslt