- From: Olivier Thereaux via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 05 May 2008 02:46:09 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/validator/httpd/cgi-bin
In directory hutz:/tmp/cvs-serv12115/httpd/cgi-bin
Modified Files:
check
Log Message:
* if the root element has a namespace, and even neither mime type,
doctype nor xml declaration have helped detect the proper parse mode,
switch to XML checking mode.
* If the document has no doctype but we are in XML mode and a root namespace
was found, filter out the "no doctype" errors.
Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.586
retrieving revision 1.587
diff -u -d -r1.586 -r1.587
--- check 28 Apr 2008 06:44:40 -0000 1.586
+++ check 5 May 2008 02:46:07 -0000 1.587
@@ -2204,10 +2204,15 @@
/x
? 'XML' : 'TBD' );
- if (($parseModeFromMimeType eq 'TBD') and ($parseModeFromXMLDecl eq 'TBD') and (!exists $CFG->{Types}->{$fpi})) {
+ my $parseModeFromNamespace = 'TBD';
+ if ($File->{Namespace}) { $parseModeFromNamespace = 'XML'}
+
+ if (($parseModeFromMimeType eq 'TBD') and ($parseModeFromXMLDecl eq 'TBD') and ($parseModeFromNamespace eq 'TBD') and (!exists $CFG->{Types}->{$fpi})) {
# if the mime type is text/html (ambiguous, hence TBD mode)
+ # and the doctype isn't in the catalogue
# and XML prolog detection was unsuccessful
- # and the doctype isn't in the catalogue... we scream
+ # and we found no namespace at the root
+ # ... throw in a warning
&add_warning('W06', {
W06_mime => $File->{ContentType},
w06_doctype => $File->{DOCTYPE}
@@ -2215,10 +2220,10 @@
return;
}
- $parseModeFromDoctype = 'TBD' unless $parseModeFromDoctype eq 'SGML' or $parseModeFromDoctype eq 'XML';
+ $parseModeFromDoctype = 'TBD' unless $parseModeFromDoctype eq 'SGML' or $parseModeFromDoctype eq 'XML' or $parseModeFromNamespace eq 'XML';
- if (($parseModeFromDoctype eq 'TBD') and ($parseModeFromXMLDecl eq 'TBD') and ($parseModeFromMimeType eq 'TBD')) {
- # if all three factors are useless to give us a parse mode
+ if (($parseModeFromDoctype eq 'TBD') and ($parseModeFromXMLDecl eq 'TBD') and ($parseModeFromMimeType eq 'TBD') and ($parseModeFromNamespace eq 'TBD')) {
+ # if all factors are useless to give us a parse mode
# => we use SGML as a default
$File->{Mode} = 'SGML';
$File->{ModeChoice} = 'Fallback';
@@ -2252,11 +2257,19 @@
$File->{ModeChoice} = 'Doctype';
return;
}
+ elsif ($parseModeFromXMLDecl ne 'TBD') {
+ # the mime type is ambiguous (hence we didn't stop at the previous test)
+ # but by now we're sure that the document type is a good indication
+ # so we use that.
+ $File->{Mode} = $parseModeFromXMLDecl;
+ $File->{ModeChoice} = 'XMLDecl';
+ return;
+ }
else {
# this is the last case. We know that all three modes are not TBD,
# yet both mime type and doctype tests have failed => we are saved by the XML declaration
- $File->{Mode} = $parseModeFromXMLDecl;
- $File->{ModeChoice} = 'XMLDecl';
+ $File->{Mode} = $parseModeFromNamespace;
+ $File->{ModeChoice} = 'Namespace';
}
}
@@ -2708,6 +2721,12 @@
# hoping to get the DTDs fixed, see http://lists.w3.org/Archives/Public/www-html-editor/2007AprJun/0010.html
return; # don't report this, just proceed
}
+ if (($err->{num} eq '344') and ($File->{Namespace}) and ($File->{Mode} eq 'XML') ) {
+ # we are in XML mode, we have a namespace, but no doctype.
+ # the validator will already have said "no doctype, falling back to default" above
+ # no need to report this.
+ return; # don't report this, just proceed
+ }
if (($err->{num} eq '248') or ($err->{num} eq '247') or ($err->{num} eq '246')) {
# these two errors should be triggered by -wmin-tag to report shorttag used,
Received on Monday, 5 May 2008 02:46:39 UTC