Subject:html DOCTYPE is ignored in XSLT preview Author:Christos Karras Date:25 Nov 2003 12:48 PM
I have a stylesheet that outputs HTML 4.01 and has a DOCTYPE declaration at the begining:
<xsl:text disable-output-escaping="yes"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"></xsl:text>
However, this declaration seems to be ignored in the XSLT Preview window. But if I open the generated html file in a web browser, the DOCTYPE is there and the page is rendered correctly.
(When this line is at the begining of an HTML file, it activates Internet Explorer's standards compliant rendering. This can make a huge difference for pages that use CSS positioning because IE6 emulates old IE5 bugs when there is no DOCTYPE declaration.)
By looking at the files generated by Stylus in my Temp directory, I have found that the DOCTYPE declaration becomes enclosed in a SPAN:
<SPAN S_='021E7648 15' X_='0235FB5C FFFFFFFF'><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"></SPAN>
Which makes IE ignore the line.
Would it be possible to fix Stylus so that it won't enclose anything before the <HTML> tag inside <SPAN> tags? Or is there something I could do to workaround this problem?
Subject:Re: html DOCTYPE is ignored in XSLT preview Author:Minollo I. Date:25 Nov 2003 01:07 PM
The SPAN elements are used by Stylus to enable backmapping in the preview
window; as the DOCTYPE declaration is being generated as part of a normal
xsl:text instruction, we don't have much flexibility there to understand
that we should skip the backmapping information.
A better way to generate the DOCTYPE declaration would be to add
doctype-public and doctype-system attributes to the xsl:output instruction;
something like:
{xsl:output doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
doctype-system="http://www.w3.org/TR/html4/loose.dtd"}
The generated DOCTYPE declaration won't be disrupted by SPAN elements.
Also, you may turn on the "Preview in external browser" checkbox in the
scenario properties; that will open the HTML result in an external IE
instance, avoiding inclusion of SPAN tags.
Subject:Re: html DOCTYPE is ignored in XSLT preview Author:Christos Karras Date:25 Nov 2003 01:27 PM
Thanks, I didn't know about
the "doctype-public" and "doctype-system" parameters for xsl:output, I added them to my stylesheet and now I get the correct result in the XSLT preview window