Search

With Symphony 2, is there a clean way to manage this situation (insert something before the doctype)?

http://symphony21.com/forum/discussions/1442/1/

P.S. I (can't have) haven't Symphony installed on the machine I'm using today, so I can't check personally :-P

I've workarounded the issue with a simpler solution than the "extension" one.

I've just removed the doctype settings from <xsl:output> and manually added

&lt;xsl:processing-instruction name="xml-stylesheet"&gt;
  &lt;xsl:text&gt;type="text/xsl" href="copy.xsl"&lt;/xsl:text&gt;
&lt;/xsl:processing-instruction&gt;
&lt;xsl:text&gt;&#xA;&lt;/xsl:text&gt;

&lt;xsl:text disable-output-escaping="yes"&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;&#xA;&lt;/xsl:text&gt;

However stripping the doctype settings from <xsl:output> causes some issues... mmm...

for valid xhtml markup, you don't want to stick anything above the doctype. I know this can cause issues with IE6 and 7.

Well... you should include the xml declaration (optional for XHTML 1.0), but this is another thing that causes issues to IE.

you should include the xml declaration

is that in the spec?

The XML declaration is indeed required for XHTML 1.1 documents. But for XHTML 1.0, the W3C says:

An XML declaration is not required in all XML documents; however XHTML document authors are strongly encouraged to use XML declarations in all their documents. Such a declaration is required when the character encoding of the document is other than the default UTF-8 or UTF-16 and no encoding was determined by a higher-level protocol.

(See http://www.w3.org/TR/xhtml1/#strict)

You should know that using the XML declaration ("prologue") on XHTML documents will throw IE 6 to quirks mode, resulting in much more CSS rendering bugs. (Search the web if you can not believe this...)

So if you do not want to have too much trouble, you may do the following:

  • Use the XHTML 1.0 strict doctype (validating ypur documents, of course)
  • serve documents as text/html
  • use UFT-8 charset
  • do not include the XML declaration

Such documents will be parseable even in ancient browsers. (Of course you will have hard CSS work if you need to support IE 5 Win and or IE 5 Mac, but that's a different story.)

ah i didn't know that. if that's the case, and you're trying to include the xml declaration, then just set this line in the main xsl file in the xsl:output to no:

omit-xml-declaration="no"

you should get this line at the top of your document now:

<?xml version="1.0" encoding="UTF-8"?>

Thank you michael-e, but I already know all these things :-) My question is different, it is about inserting something just before the doctype... its effects on IE are another story.

P.S. Serving XHTML as text/html is quite useless.

:-)

Ekheraza, I don't agree. Serving XHTML as text/html is a good way to enhance backward compatibilty if you build sites which should run on f..king IE browsers. No other browser is out there in such ancient versions (and no browser is as buggy as IE, if you talk about web standards). Ancient technology is why the W3C explicitely "allowed" serving XHTML as text/html.

michael-e, yeah it's allowed, but it's useless... there're no big differences serving XHTML 1.0 as text/html or serving HTML 4.0, they are both parsed as "HTML" instead of "XML".

Manuel, in an ideal world I would agree. But in the real world, what is our alternative? Ironically the XML declaration causes IE 6 to use quirks mode for rendering a page. Nobody needs that.

There isn't actually anything wrong with using HTML 4. It may be "out of date" but then everything "up to date" is unsupported by the majority of browsers...

I think most view XHTML as a form of forward compatibility. Serving it up as HTML is a temporary solution which hopefully allows a simple flip of a switch later.

Thank you, Lewis, you found the right words.

michael-e: yeah, the XML declaration causes IE 6 (and IE 7? I didn't try) to switch to quirks mode. With IE we are at a crossroads: we can use "standards mode" OR the "strict" XML parser, it's a matter of choice.

Note that the Internet Explorer HTML parser sees XHTML "text/html" as "broken" HTML code (the result is similar because it is flexible enough to ignore the "wrong" syntax... well... you still need some workarounds, like the extra blank space before /> ).

I think to push standards forward, we should forget about getting different browser to behave differently by throwing in extra content (ie throwing IE6 into quirksmode). I never really read up on the advantages/disadvantages of doing such, but I think with IE conditional statements, it makes it easier to make IE6 look how you want it to without compromising optimized code for FF and other compliant browsers.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details