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).
我尝试在浏览器中呈现XML+XSL 2.0,返回. XML页面,其中包含应用程序/ XML内容类型,以及带有文本/ XML的. XSL页面。Safari对主文档提出了抱怨:“资源被解释为文档,但是用MIME类型的应用程序/xml传输。”(但总是表现得很好)。
I want to get rid of this warning message. What content-types should be used for the XML document?
我想删掉这个警告信息。XML文档应该使用哪些内容类型?
3 个解决方案
#1
7
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).
我已经成功地将文本/xml与样式表作为文本/xsl一起使用(或者可以将其作为文本/xml使用)。文本/xsl被广泛认可,但不是“官方”(据我所知)。
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."
根据RFC 3023:“如果一个XML文档,即未经处理的源XML文档被普通用户可读,那么文本/ XML比应用程序/ XML更可取。没有显式支持文本/xml的MIME用户代理(和web用户代理)将把它当作文本/纯文本,例如,将xml MIME实体显示为纯文本。当普通用户无法读懂xml MIME实体时,应用程序/xml更可取。
See https://tools.ietf.org/html/rfc3023#page-16
见https://tools.ietf.org/html/rfc3023 # 16页
#2
4
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.
仔细查看WebKit源代码,很容易发现对于每个资源类型,什么MIME类型被认为是有效的。这不是一个很大的列表。
The following 4 MIME types are supported for "Documents":
“文档”支持以下4种MIME类型:
text/html
- text / html
text/xml
- text / xml
text/plain
- 文本/平原
application/xhtml+xml
- application / xhtml + xml
There are only 2 valid types for stylesheets:
样式表只有两种有效类型:
text/css
- 文本/ css
text/xsl
- 文本/ xsl
Obviously, the text/html
, text/plain
, and text/css
types don't really apply here.
显然,文本/html、文本/纯文本和文本/css类型在这里并不适用。
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.
如果您真的想要让警告安静下来,那么可以将.xml文档作为文本/xml发送,将.xsl文档作为文本/xsl发送。
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.
另一方面,你承认一切都很好,所以你可以考虑“如果它没有坏,就不要修复它”的策略。
#3
0
Before any transformation i do this in PHP:
在任何转换之前,我用PHP来做这个:
header("Content-Type: application/xhtml+xml; charset=utf-8");
the part with uft-8 is important ...
uft-8的部分很重要……
#1
7
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).
我已经成功地将文本/xml与样式表作为文本/xsl一起使用(或者可以将其作为文本/xml使用)。文本/xsl被广泛认可,但不是“官方”(据我所知)。
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."
根据RFC 3023:“如果一个XML文档,即未经处理的源XML文档被普通用户可读,那么文本/ XML比应用程序/ XML更可取。没有显式支持文本/xml的MIME用户代理(和web用户代理)将把它当作文本/纯文本,例如,将xml MIME实体显示为纯文本。当普通用户无法读懂xml MIME实体时,应用程序/xml更可取。
See https://tools.ietf.org/html/rfc3023#page-16
见https://tools.ietf.org/html/rfc3023 # 16页
#2
4
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.
仔细查看WebKit源代码,很容易发现对于每个资源类型,什么MIME类型被认为是有效的。这不是一个很大的列表。
The following 4 MIME types are supported for "Documents":
“文档”支持以下4种MIME类型:
text/html
- text / html
text/xml
- text / xml
text/plain
- 文本/平原
application/xhtml+xml
- application / xhtml + xml
There are only 2 valid types for stylesheets:
样式表只有两种有效类型:
text/css
- 文本/ css
text/xsl
- 文本/ xsl
Obviously, the text/html
, text/plain
, and text/css
types don't really apply here.
显然,文本/html、文本/纯文本和文本/css类型在这里并不适用。
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.
如果您真的想要让警告安静下来,那么可以将.xml文档作为文本/xml发送,将.xsl文档作为文本/xsl发送。
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.
另一方面,你承认一切都很好,所以你可以考虑“如果它没有坏,就不要修复它”的策略。
#3
0
Before any transformation i do this in PHP:
在任何转换之前,我用PHP来做这个:
header("Content-Type: application/xhtml+xml; charset=utf-8");
the part with uft-8 is important ...
uft-8的部分很重要……