I assume you're using PHP Mordechai? If so, copy&paste this -- based off Simon's script but altered for 1.1 DTD instead of 1.0Tran, with added sniffing::


$charset = "iso-8859-1";
$mime = "text/html";
function fix_code($buffer) {
return (preg_replace("!\s*/>!", ">", $buffer));
}
if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ||
stristr($_SERVER["HTTP_USER_AGENT"],"Opera/6") ||
stristr($_SERVER["HTTP_USER_AGENT"],"Opera/7") ||
stristr($_SERVER["HTTP_USER_AGENT"],"WDG_Validator") ||
stristr($_SERVER["HTTP_USER_AGENT"],"W3C_Validator") ||
stristr($_SERVER["HTTP_USER_AGENT"],"W3C_CSS_Validator")
) {
if(preg_match("/application\/xhtml\+xml;q=0(\.[1-9]+)/i",$_SERVER["HTTP_ACCEPT"],$matches)) {
$xhtml_q = $matches[1];
if(preg_match("/text\/html;q=0(\.[1-9]+)/i",$_SERVER["HTTP_ACCEPT"],$matches)) {
$html_q = $matches[1];
if($xhtml_q >= $html_q) {
$mime = "application/xhtml+xml";
}
}
} else {
$mime = "application/xhtml+xml";
}
}
if($mime == "application/xhtml+xml") {
$prolog_type = "<?xml version=\"1.0\" encoding=\"$charset\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\";>\n<html xmlns=\"http://www.w3.org/1999/xhtml\"; xml:lang=\"en\">\n";
} else {
ob_start("fix_code");
$prolog_type = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\";>\n<html lang=\"en\">\n";
}
header("Content-Type: $mime;charset=$charset");
header("Vary: Accept");
print $prolog_type;
?>


--
Ryan Christie        | e: [EMAIL PROTECTED]
Harrisonburg, VA     | w: http://shadyland.theward.net
-------------------() ()------------------------------

*****************************************************
The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
*****************************************************




Reply via email to