W3C home > Mailing lists > Public > www-validator@w3.org > September 2007

Re: application/xhtml+xml

From: Dean Edridge <dean@55.co.nz>
Date: Thu, 27 Sep 2007 01:43:22 +1200
To: nikn1@gazeta.pl
Cc: www-validator@w3.org
Message-id: <46FA61FA.2090003@55.co.nz>

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

This archive was generated by hypermail 2.3.1 : Wednesday, 10 December 2014 20:09:00 UTC