On Mon, May 24, 2010 at 4:08 PM, Hector Virgen <djvir...@gmail.com> wrote:
> Andrew,
> You may want to inform the Doctype view helper of your selected doctype
> early on in your request (at bootstrap is great) because other view helpers
> will use it to determine if tags need to be self-closed or not.
> --
> Hector

I have it set in the bootstrap. The DocType view helper injected the
desired <!DOCTYPE >:

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

It was doing this part fine, and all tags generated by the framework
are correctly closed.

The problem was with my layout script. The top of it looked like this:

<?xml version="1.0" standalone="yes"?>
<?php echo $this->doctype(); ?>

<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
<?php echo $this->headMeta()->setHttpEquiv('Content-Type',
'application/xml+html; charset=utf-8'); ?>

....

I didn't pay much attention to the fact that my editor program had
inserted the ' standalone="yes"' string in the xml declaration.
Changing my layout script to this made all the browsers I tested happy
with the contents generated by ZF:

<?xml version="1.0" standalone="no"?>
<?php echo $this->doctype(); ?>

<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
<?php echo $this->headMeta()->setHttpEquiv('Content-Type',
'application/xml+html; charset=utf-8'); ?>

....


That enabled the browsers to look up the entity references included in
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd (via <!ENTITY %
HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN"
"xhtml-lat1.ent">) and that made all the difference.

The problem with the Zend_View_Helper_HeadStyle helper is that it
generates style tags that look like this:

<style type="text/css" media="screen">
<!--
body { margin: 0 }
-->
</style>

The X/HTML comment tags are necessary for backward compatibility to
prevent the browsers that do not recognize the <style> tag from
rendering the contents. The issue is that they cause the contents of
the style tag to be ignored in some browsers if the server sends a
Content-Type: application/xhtml+xml mime-type header. I'm not really
sure there is a safe way to fix this in a fully backward compatible
manner. Instead, based on this document
(https://developer.mozilla.org/en/Properly_Using_CSS_and_JavaScript_in_XHTML_Documents#Do_not_use_inline_style_or_script_in_XHTML)
I just avoid using the HeadStyle view helper in favor of saving style
information to an external CSS stylesheet and linking to it using the
HeadLink view helper.

Andrew

Reply via email to