不适用于Chrome或Firefox

不适用于Chrome或Firefox

本文介绍了XSLT适用于IE,不适用于Chrome或Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 <?xml version =1.0?> 
<?xml-stylesheet type =text / xslhref =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池大小= 5; Decr池大小= 1;语句高速缓存大小= 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.0xmlns: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>项目< /标题>
< link rel =Stylesheettype =text / css
href =http://localhost/xmlStylesheets/xml.css/>
< / head>
< body>
< div id =container>
< div class =contentid =settings>
< xsl:value-of select =count(h:property)/>属性
< table class =grid>
< thead>
< tr>
< th>属性< / th>
< th>值< / 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中呈现。任何想法是什么问题?

解决方案

您的网络服务器应该返回正确的MIME类型为xsl工作表为此工作。

Mozilla需要 text / xml application / xml ,如所述。



看来,铬将是最好的服务

a> with application / xml

与许多情况一样,IE不像其他的那么挑剔浏览器,很满意 text / xsl


Given a normal nhibernate config file:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" target="_blank" lml-data-x="https://www.lmlphp.com/r?x=CtQ9yf-VsMnVPMkmCeb_2qblzEnF2trm4LI-4EK9yjb6CerN4Lh6PLQrsA7_ztnupFY"?>

<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>

I created a xslt transformation for it.

<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>

This works fine in IE, but won't render in chrome or firefox. Any ideas what the issue is?

解决方案

Your webserver should be returning the correct mime-type for the xsl sheet for this to work.

Mozilla requires text/xml or application/xml, as specified in the XSL FAQ.

It would appear that chrome would be best served with application/xml too.

As is the case many times, IE is not as fussy as other browsers and is happy with text/xsl.

这篇关于XSLT适用于IE,不适用于Chrome或Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 12:58