validator/httpd/cgi-bin check,1.649,1.650

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

Modified Files:
	check 
Log Message:
* improved wording for fuzzy-matched elements and attributes
* adding handling of case for "attribute not allowed for a particular element/context"



Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.649
retrieving revision 1.650
diff -u -d -r1.649 -r1.650
--- check	17 Feb 2009 14:10:41 -0000	1.649
+++ check	2 Mar 2009 18:32:36 -0000	1.650
@@ -3005,13 +3005,19 @@
       my $bogus_elt_attr = $err->{msg};
       $bogus_elt_attr =~ s/.*"(.+)".*/$1/;
       
-      if (
-          ((exists $self->{CFG}->{Attributes}->{lc($bogus_elt_attr)}) and ($err->{num} eq '108'))
-          or
-           ((exists $self->{CFG}->{Elements}->{lc($bogus_elt_attr)}) and ($err->{num} eq '76'))
+      if ( (
+             ((exists $self->{CFG}->{Attributes}->{lc($bogus_elt_attr)}) and ($err->{num} eq '108'))
+           or
+             ((exists $self->{CFG}->{Elements}->{lc($bogus_elt_attr)}) and ($err->{num} eq '76'))
           )
+          and (lc($bogus_elt_attr) ne $bogus_elt_attr)
+        ) 
       { 
-          $err->{msg} .= '. Maybe you meant "'.lc($bogus_elt_attr).'"?';
+          $err->{msg} .= '. Did you mean "'.lc($bogus_elt_attr).'"?';
+      }
+      elsif((lc($bogus_elt_attr) eq $bogus_elt_attr) and ($err->{num} eq '108')) {
+          # attribute not available in this context.
+          $err->{msg} = 'Attribute '.$bogus_elt_attr.' exists, but can not be used for this element.';
       }
       else {
           my @matches;
@@ -3030,11 +3036,11 @@
               #     $err->{msg} .= '<br /> match '.$match.': '.$distances{$match};
               # }
                if (@matches > 1){
-                  $err->{msg} .= '. Maybe you meant "'.$matches_sorted[0].'" or "'.$matches_sorted[1].'"?';
+                  $err->{msg} .= '. Did you mean "'.$matches_sorted[0].'" or "'.$matches_sorted[1].'"?';
               
               }
               else {
-                  $err->{msg} .= '. Maybe you meant "'.$matches_sorted[0].'"?';
+                  $err->{msg} .= '. Did you mean "'.$matches_sorted[0].'"?';
               }
           }
       }

Received on Monday, 2 March 2009 18:32:48 UTC