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

Re: Possible patch for explicit doctype error message

From: Olivier Thereaux <ot@w3.org>
Date: Fri, 2 Nov 2007 04:36:46 +0900
To: Chuck Houpt <chuck@habilis.net>
Cc: www-validator@w3.org
Message-ID: <20071101193646.GA23406@w3.mag.keio.ac.jp>

Hi Chuck,

On Wed, Oct 24, 2007, Chuck Houpt wrote:
> When validating a page with a user selected Doctype (eg 
> doctype=XHTML+1.0+Strict), the validator produces an error message 
> (either to Apache's error log or standard error):
> 
> The following patch suppresses the error, but maybe there is a better 
> way to fix this? The issue is that when override_doctype() is first 
> called (line 628), $File->{DOCTYPE} hasn't been set yet. Possibly 
> $File->{DOCTYPE} should be initialized to '' earlier in the script? 

I think your patch will work for most cases, unless the existing doctyle
being overriden is not known in the types config. So maybe something
like this?

===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.577
diff -u -r1.577 check
--- check       25 Oct 2007 19:43:57 -0000      1.577
+++ check       1 Nov 2007 19:22:45 -0000
@@ -1636,7 +1636,11 @@
   $File->{Content} = [split /\n/, $HTML];
 
   if ($seen) {
-    unless (($File->{Opt}->{FB}->{DOCTYPE}) or ($File->{Opt}->{DOCTYPE} eq $CFG->{Types}->{$File->{DOCTYPE}}->{Display} )) {
+    my $old_doctype_name;
+    if (defined $File->{DOCTYPE}) {
+      if (defined $CFG->{Types}->{$File->{DOCTYPE}}->{Display}) {$old_doctype_name = $CFG->{Types}->{$File->{DOCTYPE}}->{Display}}
+    } 
+    unless (($File->{Opt}->{FB}->{DOCTYPE}) or ($File->{Opt}->{DOCTYPE} eq $old_doctype_name)) {
       &add_warning('W13', {
         W13_org => $org_dtd,
         W13_new => $File->{Opt}->{DOCTYPE},

-- 
olivier
Received on Thursday, 1 November 2007 19:36:57 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:26 GMT