Re: QF: Javascript sections not XHTML compliant?
| From: | Klaus Guenther | Date: | Wed, 22 Oct 2003 15:55:10 +0000 |
| Subject: | Re: QF: Javascript sections not XHTML compliant? | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-22915@lists.php.net to get a copy of this message | ||
"Ignatius Reilly" <ignatius.reilly@free.fr> wrote:
> Should PEAR CS not require that JS sections - or for that matter all HTML
> output - be XHTML-strict compliant? (didn't see anything to this effect in
> the doc)
> eg:
> <script type="text/javascript">
> //<![CDATA[
> ...
> //]]>
> </script>
>
> instead of the usual
> <script type="text/javascript">
> <!--
> ...
> // -->
> </script>
> which AFAI is not XHTML compliant
> (Comments (<!-- ... -->) must not contain double dashes (--) )
> therefore statements such as --x will cause non-conformance
>
> Ignatius
OK, here's the skivvy...
<![CDATA[ ... ]]!> is only properly handled when the document is sent as mime
type 'application/xhtml+xml', 'application/xml', 'application/xml'. If
it is
sent as text/html, it is parsed as HTML, not XHTML. Unfortunately, the only
browsers supporting XHTML properly are Mozilla (i.e., Gecko engine) and, to a
degree, Opera:
(http://www.opera.com/docs/specs/ states that Opera doesn't properly handle
scripting in XML mode). Forgot where to find the useragent details on the w3c
site, but if you want them, email me and I'll get them to you as soon as I
get home.
See http://www.w3.org/TR/xhtml-media-types/#summary
for more details on mime
types.
Pages served as text/html will always be rendered with the html renderer
instead of the xml renderer. Since most browsers (i.e., IE) don't support the
XML rendering, you can as good as forget trying to get strict XHTML
compliance unless you are saving the page locally.
Check the _generateHead() method of my HTML_Page class for my solution:
http://cvs.php.net/co.php/pear/HTML_Page/Page.php?r=1.27
hth,
Klaus