xml - XSLT 适用于 IE,不适用于 Chrome 或 Firefox

标签 xml google-chrome firefox xslt xml-namespaces

给定一个正常的 nhibernate 配置文件:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="http://localhost/xmlStylesheets/nhibernate.xsl"?>

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
    <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
    <property name="connection.connection_string">Data Source=MyDB;User ID=MyUser;Connection Lifetime=0;Enlist=false;Pooling=true;Max Pool Size=100;Min Pool Size=0;Incr Pool Size=5;Decr Pool Size=1;Statement Cache Size=100;</property>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
    <property name="use_outer_join">true</property>
    <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
    <property name="show_sql">true</property>
  </session-factory>
</hibernate-configuration>

我为它创建了一个 xslt 转换。

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:h="urn:nhibernate-configuration-2.2">
  <xsl:template match="h:hibernate-configuration/h:session-factory">
    <html>
      <head>
        <title>Projects</title>
        <link rel="Stylesheet" type="text/css" 
              href="http://localhost/xmlStylesheets/xml.css" />
      </head>
      <body>
        <div id="container">
          <div class="content" id="settings">
            <xsl:value-of select="count(h:property)" /> properties
            <table class="grid">
              <thead>
                <tr>
                  <th>Property</th>
                  <th>Value</th>
                </tr>
              </thead>
              <tbody>
              <xsl:for-each select="h:property">
                <tr>
                  <td><xsl:value-of select="@name" /></td>
                  <td><xsl:value-of select="." /></td>
                </tr>
              </xsl:for-each>
              </tbody>
            </table>
          </div>
        </div>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

这在 IE 中工作正常,但不会在 chrome 或 firefox 中呈现。知道问题是什么吗?

最佳答案

您的网络服务器应该为 xsl 工作表返回正确的 mime 类型,这样它才能工作。

Mozilla 需要 text/xmlapplication/xml,如 XSL FAQ 中指定的那样.

看起来 chrome 应该是 best served还有 application/xml

和很多次一样,IE 不像其他浏览器那样挑剔,而且对 text/xsl 很满意。

关于xml - XSLT 适用于 IE,不适用于 Chrome 或 Firefox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1976383/

相关文章:

python - 如何使用python将大量XML插入到另一个XML文件中?

javascript - 如果节点包含具有特定名称的子节点但出现错误,则尝试从 XML 中删除该节点

javascript - window.opener 在 firefox 中为 null

java - Android - 如何使表格行的高度大小等于

google-chrome - Chrome 扩展程序最大消息长度

wordpress - 字体未初始化但仅在三页上

android - PWA 用户选择 promise 永远不会解决

firefox - 禁止 Firefox/Firebug SHA-1 警告

windows - 在 Windows 服务模式下运行 GUI 应用程序

适用于 Windows 和 Linux 的 c++ xml、tcp/ip 库