Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
heck DCR for XHTML compliance
talksure
Hi everyone,
We are updating our content types to output XHTML and therefore need a way to find and update DCRs that contain HTML in them to XHTML compliance.
Can you please recommend a tool(s), process and documentation that we can use to audit and update/correct DCRs that are non compliant.
Thanks
Talksure
Find more posts tagged with
Comments
gzevin
well, I usually use google to find such tools.
a simple search for 'html2xhtml' brough a wealth of results.
e,g,, there is W3's own XSL
sheet
HTML Tidy would probably do a trick
and also, here is another script
------------------------------------------------------------------------------
<?
if (!empty($type)) {
if ($type == "path") {
if (!empty($path)) {
if (file_exists($path) && is_file($path)) {
$file = file($path);
if (substr($file[0],0,9) != "<!DOCTYPE") $doctype=0;
$file = join('', $file);
} else {
die ("No such file.");
}
} else {
die ("No file specified.");
}
} elseif ($type == "file") {
if (!empty($file)) {
} else {
die ("No file specified.");
}
} else {
die ("No file specified.");
}
# specify html file, check for doctype
//$file = file("file.html");
//if (substr($file[0],0,9) != "<!DOCTYPE") $doctype=1;
//$file = join('', $file);
# make tags and properties lower case, close empty elements, quote all properties
$search = array ("'(<\/?)(\w+)([^>]*>)'e",
"'(<\/?)(br|input|meta|link|img)([^>]*)( />)'ie",
"'(<\/?)(br|input|meta|link|img)([^>]*)(/>)'ie",
"'(<\/?)(br|input|meta|link|img)([^>]*)(>)'ie",
"'(\w+=)(\w+)'ie",
"'(\w+=)(.+?)'ie");
$replace = array ("'\\1'.strtolower('\\2').'\\3'",
"'\\1\\2\\3>'",
"'\\1\\2\\3>'",
"'\\1\\2\\3 /\\4'",
"strtolower('\\1').'\"\\2\"'",
"strtolower('\\1').'\\2'");
$file = preg_replace($search, $replace, $file);
# return xhtml-compliant document
echo "<textarea cols=\"100\" rows=\"20\">";
if (isset($doctype)) echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">'."\n";
echo stripslashes(stripslashes(stripslashes($file)));
echo "</textarea>";
} else {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<head><title>HTML -> XHTML Convertor</title></head>
<body>
<!-- WARNING: this input method is a security risk on open servers //-->
<form action="<?=$PHP_SELF?>" method="get">
<input type="hidden" name="type" value="path" />
<font face="verdana">File path:</font> <input type="text" name="path" size="50" />
<input type="submit" value="Submit" />
</form>
<b><font face="verdana">OR</font></b><br /><br />
<form action="<?=$PHP_SELF?>" method="get">
<input type="hidden" name="type" value="file" />
<font face="verdana">File contents:</font><br />
<textarea name="file" rows="10" cols="50"></textarea><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
<?
}
?>
--------------------------------------------
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU