validator/httpd/cgi-bin check,1.517,1.518

Update of /sources/public/validator/httpd/cgi-bin
In directory hutz:/tmp/cvs-serv5008/httpd/cgi-bin

Modified Files:
	check 
Log Message:
for documents served as XML, and for which the root element is not <html>,
the fallback to XHTML is not a great choice. Instead, we can perform a basic xml-wf checking,
and report a positive result for these.



Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.517
retrieving revision 1.518
diff -u -d -r1.517 -r1.518
--- check	7 May 2007 16:14:15 -0000	1.517
+++ check	7 May 2007 19:17:58 -0000	1.518
@@ -254,6 +254,8 @@
 # Misc simple types.
 $File->{Mode} = 'SGML'; # Default parse mode is SGML.
 
+# By default, perform validation (we may perform only xml-wf in some cases)
+$File->{XMLWF_ONLY} = FALSE;
 #
 # Listrefs.
 $File->{Warnings}   = []; # Warnings...
@@ -588,8 +590,7 @@
 #
 # Override DOCTYPE if user asked for it.
 if ($File->{Opt}->{DOCTYPE}
-    and not $File->{Opt}->{DOCTYPE} =~ /(Inline|detect)/i
-    and $File->{Opt}->{DOCTYPE} ne '1' ) {
+    and not $File->{Opt}->{DOCTYPE} =~ /(Inline|detect)/i) {
   $File = &override_doctype($File);
 }
 
@@ -781,7 +782,7 @@
 #
 # Force "XML" if type is an XML type and an FPI was not found.
 # Otherwise set the type to be the FPI.
-if (&is_xml($File) and not $File->{DOCTYPE}) {
+if (&is_xml($File) and not $File->{DOCTYPE} and  lc($File->{Root}) ne 'html') {
   $File->{Version} = 'XML';
 } else {
   $File->{Version} = $File->{DOCTYPE} unless $File->{Version};
@@ -962,7 +963,9 @@
   $T->param(tip_uri  => $tip->[0]);
   $T->param(tip_slug => $tip->[1]);
 
-  #
+  # Root Element
+  $T->param(root_element  => $File->{Root});
+  
   # Namespaces...
   $T->param(file_namespace  => $File->{Namespace});
   my %seen_ns = ();
@@ -1102,7 +1105,9 @@
   if ($File->{Opt}->{'Outline'}) {
     $T->param(file_outline => $File->{heading_outline});
   }
-
+  if ($File->{XMLWF_ONLY}){
+    $T->param(xmlwf_only => TRUE);
+  }
   my $thispage = self_url_file($File);
   $T->param(file_thispage => $thispage);
 }
@@ -2358,9 +2363,17 @@
     }
   }
 
+  if ($err->{num} eq '187')
+  # filtering out no "document type declaration; will parse without validation"
+  # if root element is not html and mode is xml...
+  {
+    # since parsing was done without validation, result can only be "well-formed"
+    if ($File->{Mode} eq 'XML' and lc($File->{Root}) ne 'html') {
+      $File->{XMLWF_ONLY} = TRUE;
+    }
+    return;
+  }
 
-  # ...
-  $File->{'Is Valid'} = FALSE if $err->{type} eq 'E';
 
   # Workaround for onsgmls as of 1.5 sometimes allegedly reporting errors
   # beyond EOL.  If you see this warning in your web server logs, please
@@ -2379,12 +2392,14 @@
     $File->{Templates}->{Error}->param(fatal_parse_extid_msg   => $err->{msg});
   }
 
-  # No DOCTYPE.
+  # No DOCTYPE found! We are falling back to vanilla DTD
   if ($err->{msg} =~ m(prolog can\'t be omitted)) {
-    my $dtd = ($File->{Mode} eq 'XML' ?
-               'XHTML 1.0 Transitional' : 'HTML 4.01 Transitional' );
-
-    add_warning('W09', {W09_dtd => $dtd});
+    if (lc($File->{Root}) eq 'html') { 
+      my $dtd = ($File->{Mode} eq 'XML' ?
+                 'XHTML 1.0 Transitional' : 'HTML 4.01 Transitional' );      
+      add_warning('W09', {W09_dtd => $dtd});
+    }
+    
     return; # Don't report this as a normal error.
   }
 
@@ -2392,6 +2407,8 @@
   abort_if_error_flagged($File, O_DOCTYPE);
 
   push @{$File->{Errors}}, $err;
+  # ...
+  $File->{'Is Valid'} = FALSE if $err->{type} eq 'E';
 
   if (defined $mess->{aux_message})
   {

Received on Monday, 7 May 2007 19:18:06 UTC