What type of content should be used to represent XML + XSL?

I am trying to display XML + XSL 2.0 in a browser by returning .xml pages with application/xml and .xsl content .xsl with text/xml . Safari complains about the main document: "The resource is interpreted as a document, but passed using a MIME-type application / xml." (but keeps everything in order).

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

+8
xml xslt
source share
3 answers

I have had success using text / xml with a stylesheet like text / xsl (or maybe it's ok like text / xml since you have work to do). text / xsl is widely recognized, but not "official" (as I understand it).

According to RFC 3023: "If the XML document, which is, raw, the source XML document is read by random users, the text / xml is preferable for the 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 an XML MIME object as plain text. Using / xml is preferable when the XML MIME subject is not read by random users. "

See https://tools.ietf.org/html/rfc3023#page-16

+7
source share

Looking into the WebKit source, it is easy to see which MIME types are considered valid for each type of resource. This is not a very long 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 style sheets:

  • text/css
  • text/xsl

Obviously, the types text/html , text/plain and text/css are not applicable here.

If you are really interested in disabling alerts, send the .xml document as text/xml , and the .xsl document as text/xsl should do the trick.

On the other hand, you agree that all rendering is excellent, so you can consider the strategy "if it hasn't broken, don't fix it."

+4
source share

Before any conversion, I do this in PHP:

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

important part with uft-8 ...

0
source share

All Articles