--- test/html-webhacc/WebHACC/Result.pm 2008/07/20 16:53:10 1.2 +++ test/html-webhacc/WebHACC/Result.pm 2008/07/21 05:48:55 1.4 @@ -54,11 +54,13 @@ 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 @@ -104,6 +106,7 @@ $line = $line - 1 || 1; $out->xref ('Line ' . $line, target => 'line-' . $line); } + $has_location = 1; } ## Node path @@ -111,6 +114,7 @@ if (defined $opt{node}) { $out->html (' '); $out->node_link ($opt{node}); + $has_location = 1; } if (defined $opt{index}) { @@ -121,27 +125,76 @@ } else { $out->text (' Index ' . (0+$opt{index})); } + $has_location = 1; } if (defined $opt{value}) { $out->html (' '); $out->code ($opt{value}); + $has_location = 1; + } + + unless ($has_location) { + if (defined $opt{input}) { + if (defined $opt{input}->{container_node}) { + my $original_input = $out->input; + $out->input ($opt{input}->{parent_input}); + $out->node_link ($opt{input}->{container_node}); + $out->input ($original_input); + $has_location = 1; + } 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}); + $has_location = 1; + } + } + + unless ($has_location) { + $out->text ('No location information available'); + } } $out->start_tag ('dd', class => $class); + + ## Error level + + 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 (')'); } + + ## Link to a long description my $fragment = $opt{type}; $fragment =~ tr/ /-/; $fragment = $out->encode_url_component ($fragment); $out->text (' ['); - $out->link ('Description', url => '../error-description#' . $fragment); + $out->link ('Description', url => '../error-description#' . $fragment, + rel => 'help'); $out->text (']'); @@ -265,77 +318,4 @@ $out->end_section; } # generate_result_section -sub _get_error_label ($$) { - my $self = shift; - my ($input, $err) = @_; - - -} # get_error_label - -sub get_error_level_label ($) { - my $self = shift; - my $err = shift; - - my $r = ''; - - if (not defined $err->{level} or $err->{level} eq 'm') { - $r = qq[MUST-level - error: ]; - } elsif ($err->{level} eq 's') { - $r = qq[SHOULD-level - error: ]; - } elsif ($err->{level} eq 'w') { - $r = qq[Warning: - ]; - } elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') { - $r = qq[Not - supported: ]; - } elsif ($err->{level} eq 'i') { - $r = qq[Information: ]; - } else { - my $elevel = htescape ($err->{level}); - $r = qq[$elevel: - ]; - } - - return $r; -} # get_error_level_label - -sub get_node_path ($) { - my $self = shift; - my $node = shift; - my @r; - while (defined $node) { - my $rs; - if ($node->node_type == 1) { - $rs = $node->node_name; - $node = $node->parent_node; - } elsif ($node->node_type == 2) { - $rs = '@' . $node->node_name; - $node = $node->owner_element; - } elsif ($node->node_type == 3) { - $rs = '"' . $node->data . '"'; - $node = $node->parent_node; - } elsif ($node->node_type == 9) { - @r = ('') unless @r; - $rs = ''; - $node = $node->parent_node; - } else { - $rs = '#' . $node->node_type; - $node = $node->parent_node; - } - unshift @r, $rs; - } - return join '/', @r; -} # get_node_path - -use Scalar::Util qw/refaddr/; - -sub get_node_link ($$) { - my $self = shift; - return qq[] . - ($self->get_node_path ($_[1])) . qq[]; - ## BUG: ^ must be escaped -} # get_node_link - 1;