52 |
my ($self, %opt) = @_; |
my ($self, %opt) = @_; |
53 |
|
|
54 |
my $out = $self->output; |
my $out = $self->output; |
55 |
|
$out->has_error (1); |
56 |
|
|
57 |
my $error_level = $opt{level}; |
my $error_level = $opt{level}; |
58 |
if (not defined $error_level) { |
if (not defined $error_level) { |
81 |
$error_layer = 'syntax'; ## NOTE: Unknown - an error of the implementation |
$error_layer = 'syntax'; ## NOTE: Unknown - an error of the implementation |
82 |
} |
} |
83 |
|
|
|
my $error_type_text = $opt{type}; |
|
|
|
|
84 |
my $class = qq[level-$error_level layer-$error_layer]; |
my $class = qq[level-$error_level layer-$error_layer]; |
85 |
|
|
86 |
## Line & column numbers (prepare values) |
## Line & column numbers (prepare values) |
117 |
$column = $opt{column}; |
$column = $opt{column}; |
118 |
} |
} |
119 |
} |
} |
120 |
|
$line += $opt{line_diff} || 0 if defined $line; |
121 |
|
$column += $opt{column_diff} || 0 if defined $column; |
122 |
$line = $line - 1 || 1 |
$line = $line - 1 || 1 |
123 |
if defined $line and not (defined $column and $column > 0); |
if defined $line and not (defined $column and $column > 0); |
124 |
|
|
170 |
$has_location = 1; |
$has_location = 1; |
171 |
} |
} |
172 |
|
|
173 |
if (defined $opt{value}) { |
if (not defined $opt{valueref} and defined $opt{value}) { |
174 |
|
$opt{valueref} = \($opt{value}); |
175 |
|
} |
176 |
|
|
177 |
|
if (defined $opt{valueref}) { |
178 |
$out->html (' '); |
$out->html (' '); |
179 |
$out->code ($opt{value}); |
if (defined $opt{pos_start}) { |
180 |
|
$out->start_tag ('code'); |
181 |
|
$out->text (substr ${$opt{valueref}}, 0, $opt{pos_start}); |
182 |
|
$out->start_tag ('mark'); |
183 |
|
$out->text (substr ${$opt{valueref}}, $opt{pos_start}, |
184 |
|
$opt{pos_end} - $opt{pos_start}); |
185 |
|
$out->end_tag ('mark'); |
186 |
|
$out->text (substr ${$opt{valueref}}, $opt{pos_end}) |
187 |
|
if $opt{pos_end} < length ${$opt{valueref}}; |
188 |
|
$out->end_tag ('code'); |
189 |
|
} elsif ($opt{value_mark_end}) { |
190 |
|
$out->start_tag ('code'); |
191 |
|
$out->text (${$opt{valueref}}); |
192 |
|
$out->start_tag ('mark'); |
193 |
|
$out->end_tag ('mark'); |
194 |
|
$out->end_tag ('code'); |
195 |
|
} elsif (defined $opt{value_mark}) { |
196 |
|
$out->start_tag ('code'); |
197 |
|
for (split /($opt{value_mark})/, ${$opt{valueref}}) { |
198 |
|
if (/$opt{value_mark}/) { |
199 |
|
$out->start_tag ('mark'); |
200 |
|
$out->text ($_); |
201 |
|
$out->end_tag ('mark'); |
202 |
|
} else { |
203 |
|
$out->text ($_); |
204 |
|
} |
205 |
|
} |
206 |
|
$out->end_tag ('code'); |
207 |
|
} else { |
208 |
|
$out->code (${$opt{valueref}}); |
209 |
|
} |
210 |
$has_location = 1; |
$has_location = 1; |
211 |
} |
} |
212 |
|
|
221 |
} elsif (defined $opt{input}->{request_uri}) { |
} elsif (defined $opt{input}->{request_uri}) { |
222 |
$out->url ($opt{input}->{request_uri}); |
$out->url ($opt{input}->{request_uri}); |
223 |
$has_location = 1; |
$has_location = 1; |
224 |
} elsif (defined $opt{input}->{uri}) { |
} elsif (defined $opt{input}->url) { |
225 |
$out->url ($opt{input}->{uri}); |
$out->url ($opt{input}->url); |
226 |
$has_location = 1; |
$has_location = 1; |
227 |
} |
} |
228 |
} |
} |
229 |
|
|
230 |
unless ($has_location) { |
unless ($has_location) { |
231 |
$out->text ('Unknown location'); |
$out->nl_text ('Unknown location'); |
232 |
} |
} |
233 |
} |
} |
234 |
|
|
239 |
$out->text (': '); |
$out->text (': '); |
240 |
|
|
241 |
## Error message |
## Error message |
242 |
$out->nl_text ($error_type_text, node => $opt{node}, text => $opt{text}); |
my $error_type_text = $opt{type}; |
243 |
|
$out->nl_text ($error_type_text, node => $opt{node}, text => $opt{text}, |
244 |
## Additional error description |
value => ${$opt{valueref} or \''}, char => $opt{char}, |
245 |
if (defined $opt{text}) { |
octets => $opt{octets}); |
|
$out->html (' (<q>'); |
|
|
$out->text ($opt{text}); |
|
|
$out->html ('</q>)'); |
|
|
} |
|
246 |
|
|
247 |
## Link to a long description |
## Link to a long description |
248 |
|
|
250 |
$fragment =~ tr/ /-/; |
$fragment =~ tr/ /-/; |
251 |
$fragment = $out->encode_url_component ($fragment); |
$fragment = $out->encode_url_component ($fragment); |
252 |
$out->text (' ['); |
$out->text (' ['); |
253 |
$out->link ('Description', url => '../error-description#' . $fragment, |
$out->start_tag ('a', href => '../error-description#' . $fragment, |
254 |
rel => 'help'); |
rel => 'help'); |
255 |
|
$out->nl_text ('Description'); |
256 |
|
$out->end_tag ('a'); |
257 |
$out->text (']'); |
$out->text (']'); |
258 |
|
|
259 |
if ($error_level eq 'm') { |
if ($error_level eq 'm') { |
320 |
$out->start_tag ('th', colspan => 7, scope => 'col'); |
$out->start_tag ('th', colspan => 7, scope => 'col'); |
321 |
$out->nl_text ('Main document'); |
$out->nl_text ('Main document'); |
322 |
}, |
}, |
323 |
{label => 'Transfer', status => $self->{layers}->{transfer}, |
{label => 'Transfer L.', status => $self->{layers}->{transfer}, |
324 |
target => 'transfer-errors', score_base => 20, |
target => 'transfer-errors', score_base => 20, |
325 |
parent_status => $maindoc_status}, |
parent_status => $maindoc_status}, |
326 |
{label => 'Encode', status => $self->{layers}->{encode}, |
{label => 'Encode L.', status => $self->{layers}->{encode}, |
327 |
score_base => 10, |
target => 'parse-errors', score_base => 10, |
328 |
parent_status => $maindoc_status}, |
parent_status => $maindoc_status}, |
329 |
{label => 'Charset', status => $self->{layers}->{charset}, |
{label => 'Char L.', status => $self->{layers}->{charset}, |
330 |
score_base => 10, |
target => 'parse-errors', score_base => 10, |
331 |
parent_status => $maindoc_status}, |
parent_status => $maindoc_status}, |
332 |
{label => 'Syntax', status => $self->{layers}->{syntax}, |
## TODO: char semantics layer |
333 |
|
{label => 'Syntax L.', status => $self->{layers}->{syntax}, |
334 |
target => 'parse-errors', score_base => 20, |
target => 'parse-errors', score_base => 20, |
335 |
parent_status => $maindoc_status}, |
parent_status => $maindoc_status}, |
336 |
{label => 'Structure', status => $self->{layers}->{structure}, |
{label => 'Structure L.', status => $self->{layers}->{structure}, |
337 |
target => 'document-errors', score_base => 20, |
target => 'document-errors', score_base => 20, |
338 |
parent_status => $maindoc_status}, |
parent_status => $maindoc_status}, |
339 |
{label => 'Semantics', status => $self->{layers}->{semantics}, |
{label => 'Semantics L.', status => $self->{layers}->{semantics}, |
340 |
score_base => 20, |
score_base => 20, |
341 |
parent_status => $maindoc_status}, |
parent_status => $maindoc_status}, |
342 |
); |
); |