Re: application/xhtml+xml

Nikodem wrote:
>
> Does validator even send application/xhtml+xml in Accept header?! It 
> always complains that my page with such code:
>
> $xhtml = false;
> if(preg_match('/application\/xhtml\+xml(?![+a-z])(;q=(0\.\d{1,3}|[01]))?/i', 
> $_SERVER['HTTP_ACCEPT'], $matches))
> {
>     $xhtmlQ = isset($matches[2])?$matches[2]:1;
>     if($xhtmlQ!=0) $xhtml = true;
> }
> header('Content-Type: 
> '.($xhtml?'application/xhtml+xml':'text/html').'; charset=utf-8');
>
> has differences between Content-Type and DTD.
>
Unfortunately not, Nikodem. The Validator is a bit naughty in that regard.
All of the other validators I have tested send an accept header, but not 
the W3C_validator  :-(
The lack of an accept header is an ongoing issue and something that 
really bugs me and a lot of other people: 
http://www.w3.org/Bugs/Public/show_bug.cgi?id=18

Here's a simplified version of the PHP content negotiation script that I 
use on my sites. At the present moment it seems to be the best way to 
ensure that your pages are validated as XHTML when using the W3C_validator.

if (stristr($_SERVER['HTTP_ACCEPT'], "application/xhtml+xml") ||
   stristr($_SERVER["HTTP_USER_AGENT"], "W3C_Validator"))
{
   $mime = "application/xhtml+xml";
}   else
{
   $mime = "text/html";   }
header("Content-Type: $mime; charset=utf-8");


Hope that helps

-- 
Dean Edridge
http://www.zealmedia.co.nz/

Received on Wednesday, 26 September 2007 13:43:36 UTC