【问题标题】:XSLT works in IE, not in Chrome or FirefoxXSLT 在 IE 中有效,在 Chrome 或 Firefox 中无效
【发布时间】:2015-11-17 07:10:07
【问题描述】:

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

<?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 中呈现。任何想法是什么问题?

【问题讨论】:

    标签: xml google-chrome firefox xslt xml-namespaces


    【解决方案1】:

    您的网络服务器应该为 xsl 工作表返回正确的 mime 类型以使其正常工作。

    Mozilla 需要text/xmlapplication/xml,如XSL FAQ 中所指定。

    看来 chrome 应该是 best servedapplication/xml

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

    【讨论】:

    • 有趣。我从来没有遇到过这样的问题,所以很高兴知道这可能是一个问题。谢谢!
    • 另外,我直接浏览到文件。一旦我把它放在网络服务器上并修复了 mime 类型,它就可以在非 ie 浏览器中运行。谢谢!
    • 对我来说,text/xmlapplication/xml 在 chrome 中都不起作用。它只显示一个白屏。你能猜出原因吗?
    • @Manish - 你猜?铬中的错误? Chrome 开发者没有实现吗?您需要询问 chrome 开发人员为什么它不起作用。
    【解决方案2】:

    它在 opera 10.10、chromium 4.0、firefox 3.6 和 ie8 中非常适合我。我得到这个输出:

    8 properties
    Property    Value
    connection.provider NHibernate.Connection.DriverConnectionProvider
    dialect NHibernate.Dialect.Oracle10gDialect
    connection.driver_class NHibernate.Driver.OracleDataClientDriver
    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;
    proxyfactory.factory_class  NHibernate.ByteCode.Castle.ProxyFactoryFactory,         NHibernate.ByteCode.Castle
    use_outer_join  true
    query.substitutions true 1, false 0, yes 'Y', no 'N'
    show_sql    true
    

    【讨论】:

      猜你喜欢
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多