--- test/html-webhacc/WebHACC/Result.pm 2008/07/20 16:53:10 1.2 +++ test/html-webhacc/WebHACC/Result.pm 2008/08/02 06:07:11 1.7 @@ -53,15 +53,7 @@ my $class = qq[level-$error_level layer-$error_layer]; - $out->start_tag ('dt', class => $class); - - ## URL - - if (defined $opt{url}) { - $out->url ($opt{url}); - } - - ## Line & column number + ## Line & column numbers (prepare values) my $line; my $column; @@ -70,7 +62,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) { @@ -95,15 +87,35 @@ $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; } ## Node path @@ -111,37 +123,88 @@ if (defined $opt{node}) { $out->html (' '); $out->node_link ($opt{node}); + $has_location = 1; } 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}); + $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 ('Unknown location'); + } } $out->start_tag ('dd', class => $class); - $out->text ($error_type_text); + + ## 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->nl_text ($error_type_text, node => $opt{node}, text => $opt{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 +328,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;