--- test/html-webhacc/WebHACC/Result.pm	2008/07/21 08:39:12	1.5
+++ test/html-webhacc/WebHACC/Result.pm	2008/09/11 09:13:57	1.19
@@ -2,7 +2,11 @@
 use strict;
 
 sub new ($) {
-  return bless {}, shift;
+  return bless {
+    global_status => 'conforming',
+        # or, 'should-error', 'non-conforming', 'uncertain'
+    subdoc_results => [],
+  }, shift;
 } # new
 
 sub output ($;$) {
@@ -17,10 +21,38 @@
   return $_[0]->{output};
 } # output
 
+sub parent_result ($;$) {
+  if (@_ > 1) {
+    if (defined $_[1]) {
+      $_[0]->{parent_result} = $_[1];
+    } else {
+      delete $_[0]->{parent_result};
+    }
+  }
+
+  return $_[0]->{parent_result};
+} # parent_result
+
+sub layer_applicable ($$) {
+  my $self = shift;
+  my $layer = shift;
+  $self->{layers}->{$layer}->{applicable} = 1;
+} # layer_applicable
+
+sub layer_uncertain ($$) {
+  my $self = shift;
+  my $layer = shift;
+  $self->{layers}->{$layer}->{uncertain} ||= 1;
+  $self->{layers}->{$layer}->{applicable} = 1;
+  $self->{global_status} = 'uncertain'
+      unless $self->{global_status} eq 'non-conforming';
+} # layer_uncertain
+
 sub add_error ($%) {
   my ($self, %opt) = @_;
 
   my $out = $self->output;
+  $out->has_error (1);
 
   my $error_level = $opt{level};
   if (not defined $error_level) {
@@ -49,21 +81,9 @@
     $error_layer = 'syntax'; ## NOTE: Unknown - an error of the implementation
   }
 
-  my $error_type_text = $opt{type};
-
   my $class = qq[level-$error_level layer-$error_layer];
  
-  $out->start_tag ('dt', class => $class);
-  my $has_location;
-
-  ## URL
-  
-  if (defined $opt{url}) {
-    $out->url ($opt{url});
-    $has_location = 1;
-  }
-
-  ## Line & column number
+  ## Line & column numbers (prepare values)
 
   my $line;
   my $column;
@@ -72,7 +92,7 @@
     $line = $opt{node}->get_user_data ('manakai_source_line');
     if (defined $line) {
       $column = $opt{node}->get_user_data ('manakai_source_column');
-    } else {
+    } elsif ($opt{node}->isa ('Message::IF::Node')) {
       if ($opt{node}->node_type == $opt{node}->ATTRIBUTE_NODE) {
         my $owner = $opt{node}->owner_element;
         if ($owner) {
@@ -97,14 +117,33 @@
       $column = $opt{column};
     }
   }
+  $line = $line - 1 || 1
+      if defined $line and not (defined $column and $column > 0);
+
+  $out->start_tag ('dt', class => $class,
+                   'data-type' => $opt{type},
+                   'data-level' => $error_level,
+                   'data-layer' => $error_layer,
+                   ($line ? ('data-line' => $line) : ()),
+                   ($column ? ('data-column' => $column) : ()));
+  my $has_location;
+
+  ## URL
+  
+  if (defined $opt{url}) {
+    $out->url ($opt{url});
+    $has_location = 1;
+  }
+
+  ## Line & column numbers (real output)
  
   if (defined $line) {
     if (defined $column and $column > 0) {
-      $out->xref ('Line ' . $line, target => 'line-' . $line);
-      $out->text (' column ' . $column);
+      $out->xref ('Line #', text => $line, target => 'line-' . $line);
+      $out->text (' ');
+      $out->nl_text ('column #', text => $column);
     } else {
-      $line = $line - 1 || 1;
-      $out->xref ('Line ' . $line, target => 'line-' . $line);
+      $out->xref ('Line #', text => $line, target => 'line-' . $line);
     }
     $has_location = 1;
   }
@@ -120,17 +159,48 @@
   if (defined $opt{index}) {
     if ($opt{index_has_link}) {
       $out->html (' ');
-      $out->xref ('Index ' . (0+$opt{index}),
+      $out->xref ('Index #', text => (0+$opt{index}),
                   target => 'index-' . (0+$opt{index}));
     } else {
-      $out->text (' Index ' . (0+$opt{index}));
+      $out->html (' ');
+      $out->nl_text ('Index #', text => (0+$opt{index}));
     }
     $has_location = 1;
   }
 
   if (defined $opt{value}) {
     $out->html (' ');
-    $out->code ($opt{value});
+    if (defined $opt{pos_start}) {
+      $out->start_tag ('code');
+      $out->text (substr $opt{value}, 0, $opt{pos_start});
+      $out->start_tag ('mark');
+      $out->text (substr $opt{value}, $opt{pos_start},
+                      $opt{pos_end} - $opt{pos_start} + 1);
+      $out->end_tag ('mark');
+      $out->text (substr $opt{value}, $opt{pos_end} + 1)
+          if $opt{pos_end} < length $opt{value};
+      $out->end_tag ('code');
+    } elsif ($opt{value_mark_end}) {
+      $out->start_tag ('code');
+      $out->text ($opt{value});
+      $out->start_tag ('mark');
+      $out->end_tag ('mark');
+      $out->end_tag ('code');
+    } elsif (defined $opt{value_mark}) {
+      $out->start_tag ('code');
+      for (split /($opt{value_mark})/, $opt{value}) {
+        if (/$opt{value_mark}/) {
+          $out->start_tag ('mark');
+          $out->text ($_);
+          $out->end_tag ('mark');
+        } else {
+          $out->text ($_);
+        }
+      }
+      $out->end_tag ('code');
+    } else {
+      $out->code ($opt{value});
+    }
     $has_location = 1;
   }
 
@@ -145,47 +215,28 @@
       } elsif (defined $opt{input}->{request_uri}) {
         $out->url ($opt{input}->{request_uri});
         $has_location = 1;
-      } elsif (defined $opt{input}->{uri}) {
-        $out->url ($opt{input}->{uri});
+      } elsif (defined $opt{input}->url) {
+        $out->url ($opt{input}->url);
         $has_location = 1;
       }
     }
     
     unless ($has_location) {
-      $out->text ('Unknown location');
+      $out->nl_text ('Unknown location');
     }
   }
  
   $out->start_tag ('dd', class => $class);
 
   ## Error level
+  $out->nl_text ('Error level ' . $error_level);
+  $out->text (': ');
   
-  if ($error_level eq 'm') {
-    $out->html (qq[MUST-level
-        error: ]);
-  } elsif ($error_level eq 's') {
-    $out->html (qq[SHOULD-level
-        error: ]);
-  } elsif ($error_level eq 'w') {
-    $out->html (qq[Warning: ]);
-  } elsif ($error_level eq 'u') {
-    $out->html (qq[Not
-        supported: ]);
-  } elsif ($error_level eq 'i') {
-    $out->html (qq[Information: ]);
-  }
-
   ## Error message
-
-  $out->text ($error_type_text);
-
-  ## Additional error description
-
-  if (defined $opt{text}) {
-    $out->html (' (');
-    $out->text ($opt{text});
-    $out->html ('
)');
-  }
+  my $error_type_text = $opt{type};
+  $out->nl_text ($error_type_text, node => $opt{node}, text => $opt{text},
+                 value => $opt{value}, char => $opt{char},
+                 octets => $opt{octets});
   
   ## Link to a long description
 
@@ -193,128 +244,229 @@
   $fragment =~ tr/ /-/;
   $fragment = $out->encode_url_component ($fragment);
   $out->text (' [');
-  $out->link ('Description', url => '../error-description#' . $fragment,
-              rel => 'help');
+  $out->start_tag ('a', href => '../error-description#' . $fragment,
+                   rel => 'help');
+  $out->nl_text ('Description');
+  $out->end_tag ('a');
   $out->text (']');
 
-
-#    my ($type, $cls, $msg) = main::get_text ($opt{type}, $opt{level});
-#    $out->html (qq[
The conformance - checker cannot decide whether the document is conforming or - not, since the document contains one or more unsupported - features. The document might or might not be conforming.
]); - } elsif ($result->{conforming_min}) { - $out->html (qq[No conformance-error is - found in this document.
]); - } elsif ($result->{conforming_max}) { - $out->html (qq[This document - is likely non-conforming, but in rare case - it might be conforming.
]); - } else { - $out->html (qq[This document is - non-conforming.
]); - } + my $para_class = { + 'conforming' => 'result-para no-error', + 'should-error' => 'result-para should-errors', + 'non-conforming' => 'result-para must-errors', + 'uncertain' => 'result-para uncertain', + }->{$self->{global_status}}; + $out->start_tag ('p', class => $para_class); + $out->nl_text ('Conformance is ' . $self->{global_status}); + $out->end_tag ('p'); $out->html (qq[| - | MUST-level -Errors | -SHOULD-level -Errors | -Warnings | -Score | ||
|---|---|---|---|---|---|---|
| $label | $result->{$_->[1]}->{must}$uncertain | $result->{$_->[1]}->{should}$uncertain | $result->{$_->[1]}->{warning}$uncertain | ]); - if ($uncertain) { - $out->html (qq[−∞..$result->{$_->[1]}->{score_max}]); - } elsif ($result->{$_->[1]}->{score_min} != $result->{$_->[1]}->{score_max}) { - $out->html (qq[ | $result->{$_->[1]}->{score_min}..$result->{$_->[1]}->{score_max}]); - } else { - $out->html (qq[ | $result->{$_->[1]}->{score_min}]); - } - $out->html (qq[ / 20]); - } - - $score_max += $score_base; - - $out->html (qq[ - | 
| Semantics | 0? | 0? | 0? | −∞..$score_base / 20 - | ||
| Total | -$must_error? | -$should_error? | -$warning? | -−∞..$score_max / 100 - | 
Important: This conformance checking service -is under development. The result above might be wrong.
]); + $out->nl_text ('This checker is work in progress.'); $out->end_section; } # generate_result_section