views:

460

answers:

2

Given a normal nhibernate config file:

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

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

+5  A: 

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.

Oded
Interesting. I never encountered a problem like this, so its good to know this may be an issue. Thanks!
Roland Bouman
additionally, I was browsing to the file directly. Once I put it on a web server and fixed the mime types, it is working in non-ie browsers. Thanks!
Tim Hoolihan
@Oded, for me both `text/xml` and `application/xml` doesn't work in chrome. It only displays a white screen. Could you guess the reason?
Manish
@Manish - Guess? Bug in chrome? Chrome developers did not implement it? You need to ask chrome developers why it doesn't work.
Oded
+1  A: 

It works great for me in opera 10.10, chromium 4.0, firefox 3.6 and ie8. I get this output:

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