views:

27

answers:

1

I have the following simple XSL style sheet:

<?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns="http://www.w3.org/1999/xhtml" version="1.0">
  <xsl:output encoding="utf-8" method="html" />

  <xsl:template match="/">

    <xsl:text disable-output-escaping="yes">
    &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&amp;gt;
      </xsl:text>
    <html>
      <head><title>hello world</title></head>
      <body>
        <p>hello world</p>
        </body>
      </html>
    </xsl:template>

  </xsl:stylesheet>

When I use it, Internet Explorer 7 and Safari 5.0.2 both simply display "hello world", as expected. However, Firefox 3.6.10 displays something different:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;

hello world

I'm guessing that Firefox is taking the first xsl:text command literally, while IE and Safari are treating it as part of the page. Are IE and Safari correctly rendering this, or is Firefox?

(I'm doing the xsl:text thing to make the MSXML library output the correct tags for HTML5 compliance.)

+1  A: 

To ouput DOCTYPE declaration for standar mode render is not needed for modern browser. Only IE has some problems: it renders in standar mode but loosing CSS engine new features (IE7 rollback to IE6, as example).

The xsl:output declaration is the best tool, but some Opera version has some problem with fn:document when ussing output declaration with PUBLIC and SYSTEM identifiers. I should test Opera 10.X behavior new that Opera 9.X has very low market share.

The only workaround is to output the DOCTYPE declaration as you did (DOE text), but only for IE: you can test for xsl:vendor with system-property function.

Alejandro
I just tried Opera 10.62 and apparently it doesn't want to display any XSL at all. Is there a secret trick for making that work?
Colen
@Colen: I have an old XML/XSLT driven cross browser site [here](http://www.aranedabienesraices.com.ar). Feel free to reuse this code.
Alejandro
Thanks very much!
Colen
@Colen: You are wellcome! Ask any time.
Alejandro