53 |
|
|
54 |
my $class = qq[level-$error_level layer-$error_layer]; |
my $class = qq[level-$error_level layer-$error_layer]; |
55 |
|
|
56 |
$out->start_tag ('dt', class => $class); |
## Line & column numbers (prepare values) |
|
|
|
|
## URL |
|
|
|
|
|
if (defined $opt{url}) { |
|
|
$out->url ($opt{url}); |
|
|
} |
|
|
|
|
|
## Line & column number |
|
57 |
|
|
58 |
my $line; |
my $line; |
59 |
my $column; |
my $column; |
62 |
$line = $opt{node}->get_user_data ('manakai_source_line'); |
$line = $opt{node}->get_user_data ('manakai_source_line'); |
63 |
if (defined $line) { |
if (defined $line) { |
64 |
$column = $opt{node}->get_user_data ('manakai_source_column'); |
$column = $opt{node}->get_user_data ('manakai_source_column'); |
65 |
} else { |
} elsif ($opt{node}->isa ('Message::IF::Node')) { |
66 |
if ($opt{node}->node_type == $opt{node}->ATTRIBUTE_NODE) { |
if ($opt{node}->node_type == $opt{node}->ATTRIBUTE_NODE) { |
67 |
my $owner = $opt{node}->owner_element; |
my $owner = $opt{node}->owner_element; |
68 |
if ($owner) { |
if ($owner) { |
87 |
$column = $opt{column}; |
$column = $opt{column}; |
88 |
} |
} |
89 |
} |
} |
90 |
|
$line = $line - 1 || 1 |
91 |
|
if defined $line and not (defined $column and $column > 0); |
92 |
|
|
93 |
|
$out->start_tag ('dt', class => $class, |
94 |
|
'data-type' => $opt{type}, |
95 |
|
'data-level' => $error_level, |
96 |
|
'data-layer' => $error_layer, |
97 |
|
($line ? ('data-line' => $line) : ()), |
98 |
|
($column ? ('data-column' => $column) : ())); |
99 |
|
my $has_location; |
100 |
|
|
101 |
|
## URL |
102 |
|
|
103 |
|
if (defined $opt{url}) { |
104 |
|
$out->url ($opt{url}); |
105 |
|
$has_location = 1; |
106 |
|
} |
107 |
|
|
108 |
|
## Line & column numbers (real output) |
109 |
|
|
110 |
if (defined $line) { |
if (defined $line) { |
111 |
if (defined $column and $column > 0) { |
if (defined $column and $column > 0) { |
112 |
$out->xref ('Line ' . $line, target => 'line-' . $line); |
$out->xref ('Line #', text => $line, target => 'line-' . $line); |
113 |
$out->text (' column ' . $column); |
$out->text (' '); |
114 |
|
$out->nl_text ('column #', text => $column); |
115 |
} else { |
} else { |
116 |
$line = $line - 1 || 1; |
$out->xref ('Line #', text => $line, target => 'line-' . $line); |
|
$out->xref ('Line ' . $line, target => 'line-' . $line); |
|
117 |
} |
} |
118 |
|
$has_location = 1; |
119 |
} |
} |
120 |
|
|
121 |
## Node path |
## Node path |
123 |
if (defined $opt{node}) { |
if (defined $opt{node}) { |
124 |
$out->html (' '); |
$out->html (' '); |
125 |
$out->node_link ($opt{node}); |
$out->node_link ($opt{node}); |
126 |
|
$has_location = 1; |
127 |
} |
} |
128 |
|
|
129 |
if (defined $opt{index}) { |
if (defined $opt{index}) { |
130 |
if ($opt{index_has_link}) { |
if ($opt{index_has_link}) { |
131 |
$out->html (' '); |
$out->html (' '); |
132 |
$out->xref ('Index ' . (0+$opt{index}), |
$out->xref ('Index #', text => (0+$opt{index}), |
133 |
target => 'index-' . (0+$opt{index})); |
target => 'index-' . (0+$opt{index})); |
134 |
} else { |
} else { |
135 |
$out->text (' Index ' . (0+$opt{index})); |
$out->html (' '); |
136 |
|
$out->nl_text ('Index #', text => (0+$opt{index})); |
137 |
} |
} |
138 |
|
$has_location = 1; |
139 |
} |
} |
140 |
|
|
141 |
if (defined $opt{value}) { |
if (defined $opt{value}) { |
142 |
$out->html (' '); |
$out->html (' '); |
143 |
$out->code ($opt{value}); |
$out->code ($opt{value}); |
144 |
|
$has_location = 1; |
145 |
|
} |
146 |
|
|
147 |
|
unless ($has_location) { |
148 |
|
if (defined $opt{input}) { |
149 |
|
if (defined $opt{input}->{container_node}) { |
150 |
|
my $original_input = $out->input; |
151 |
|
$out->input ($opt{input}->{parent_input}); |
152 |
|
$out->node_link ($opt{input}->{container_node}); |
153 |
|
$out->input ($original_input); |
154 |
|
$has_location = 1; |
155 |
|
} elsif (defined $opt{input}->{request_uri}) { |
156 |
|
$out->url ($opt{input}->{request_uri}); |
157 |
|
$has_location = 1; |
158 |
|
} elsif (defined $opt{input}->{uri}) { |
159 |
|
$out->url ($opt{input}->{uri}); |
160 |
|
$has_location = 1; |
161 |
|
} |
162 |
|
} |
163 |
|
|
164 |
|
unless ($has_location) { |
165 |
|
$out->text ('Unknown location'); |
166 |
|
} |
167 |
} |
} |
168 |
|
|
169 |
$out->start_tag ('dd', class => $class); |
$out->start_tag ('dd', class => $class); |
170 |
$out->text ($error_type_text); |
|
171 |
|
## Error level |
172 |
|
|
173 |
|
if ($error_level eq 'm') { |
174 |
|
$out->html (qq[<strong><a href="../error-description#level-m"><em class=rfc2119>MUST</em>-level |
175 |
|
error</a></strong>: ]); |
176 |
|
} elsif ($error_level eq 's') { |
177 |
|
$out->html (qq[<strong><a href="../error-description#level-s"><em class=rfc2119>SHOULD</em>-level |
178 |
|
error</a></strong>: ]); |
179 |
|
} elsif ($error_level eq 'w') { |
180 |
|
$out->html (qq[<strong><a href="../error-description#level-w">Warning</a></strong>: ]); |
181 |
|
} elsif ($error_level eq 'u') { |
182 |
|
$out->html (qq[<strong><a href="../error-description#level-u">Not |
183 |
|
supported</a></strong>: ]); |
184 |
|
} elsif ($error_level eq 'i') { |
185 |
|
$out->html (qq[<strong><a href="../error-description#level-i">Information</a></strong>: ]); |
186 |
|
} |
187 |
|
|
188 |
|
## Error message |
189 |
|
|
190 |
|
$out->nl_text ($error_type_text, node => $opt{node}, text => $opt{text}); |
191 |
|
|
192 |
|
## Additional error description |
193 |
|
|
194 |
if (defined $opt{text}) { |
if (defined $opt{text}) { |
195 |
$out->html (' (<q>'); |
$out->html (' (<q>'); |
196 |
$out->text ($opt{text}); |
$out->text ($opt{text}); |
197 |
$out->html ('</q>)'); |
$out->html ('</q>)'); |
198 |
} |
} |
199 |
|
|
200 |
|
## Link to a long description |
201 |
|
|
202 |
my $fragment = $opt{type}; |
my $fragment = $opt{type}; |
203 |
$fragment =~ tr/ /-/; |
$fragment =~ tr/ /-/; |
204 |
$fragment = $out->encode_url_component ($fragment); |
$fragment = $out->encode_url_component ($fragment); |
205 |
$out->text (' ['); |
$out->text (' ['); |
206 |
$out->link ('Description', url => '../error-description#' . $fragment); |
$out->link ('Description', url => '../error-description#' . $fragment, |
207 |
|
rel => 'help'); |
208 |
$out->text (']'); |
$out->text (']'); |
209 |
|
|
210 |
|
|
280 |
my $score_base = 20; |
my $score_base = 20; |
281 |
my $score_unit = $score_base / 100; |
my $score_unit = $score_base / 100; |
282 |
for ( |
for ( |
283 |
[Transfer => 'transfer', ''], |
[Transfer => 'transfer', '#transfer-errors'], |
284 |
[Character => 'char', ''], |
[Character => 'char', ''], |
285 |
[Syntax => 'syntax', '#parse-errors'], |
[Syntax => 'syntax', '#parse-errors'], |
286 |
[Structure => 'structure', '#document-errors'], |
[Structure => 'structure', '#document-errors'], |
328 |
$out->end_section; |
$out->end_section; |
329 |
} # generate_result_section |
} # generate_result_section |
330 |
|
|
|
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[<strong><a href="../error-description#level-m"><em class=rfc2119>MUST</em>-level |
|
|
error</a></strong>: ]; |
|
|
} elsif ($err->{level} eq 's') { |
|
|
$r = qq[<strong><a href="../error-description#level-s"><em class=rfc2119>SHOULD</em>-level |
|
|
error</a></strong>: ]; |
|
|
} elsif ($err->{level} eq 'w') { |
|
|
$r = qq[<strong><a href="../error-description#level-w">Warning</a></strong>: |
|
|
]; |
|
|
} elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') { |
|
|
$r = qq[<strong><a href="../error-description#level-u">Not |
|
|
supported</a></strong>: ]; |
|
|
} elsif ($err->{level} eq 'i') { |
|
|
$r = qq[<strong><a href="../error-description#level-i">Information</a></strong>: ]; |
|
|
} else { |
|
|
my $elevel = htescape ($err->{level}); |
|
|
$r = qq[<strong><a href="../error-description#level-$elevel">$elevel</a></strong>: |
|
|
]; |
|
|
} |
|
|
|
|
|
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[<a href="#$_[0]->{id_prefix}node-@{[refaddr $_[1]]}">] . |
|
|
($self->get_node_path ($_[1])) . qq[</a>]; |
|
|
## BUG: ^ must be escaped |
|
|
} # get_node_link |
|
|
|
|
331 |
1; |
1; |