- From: Mercurial notifier <nobody@w3.org>
- Date: Sun, 04 Jul 2010 08:31:26 +0000
- To: markup-validator updates <www-validator-cvs@w3.org>
changeset: 3115:237e5cb768d9
tag: tip
user: Ville Skyttä <ville.skytta@iki.fi>
date: Sun Jul 04 11:31:14 2010 +0300
files: htdocs/whatsnew.html httpd/cgi-bin/check share/templates/en_US/error_loop.tmpl share/templates/en_US/error_loop_grouped.tmpl
description:
Improve error location info to include URI for non-doc resources.
http://www.w3.org/Bugs/Public/show_bug.cgi?id=9933
diff -r 1e4cf1d7ea99 -r 237e5cb768d9 htdocs/whatsnew.html
--- a/htdocs/whatsnew.html Sun Jul 04 11:11:29 2010 +0300
+++ b/htdocs/whatsnew.html Sun Jul 04 11:31:14 2010 +0300
@@ -42,6 +42,12 @@
</li>
<li>
Enhancement: improved error output performance.
+ </li>
+ <li>
+ Enhancement: error/warning location information now
+ <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=9933">makes
+ it clearer</a> whether the error occurred in the validated
+ document or an external resource related to it.
</li>
</ul>
</dd>
diff -r 1e4cf1d7ea99 -r 237e5cb768d9 httpd/cgi-bin/check
--- a/httpd/cgi-bin/check Sun Jul 04 11:11:29 2010 +0300
+++ b/httpd/cgi-bin/check Sun Jul 04 11:31:14 2010 +0300
@@ -1144,7 +1144,9 @@
elsif ($attribute->name eq "last-line") {
$err->{line} = $attribute->getValue();
}
-
+ elsif ($attribute->name eq "url") {
+ $err->{uri} = $attribute->getValue();
+ }
}
}
my @child_nodes = $message_node->childNodes;
@@ -1291,6 +1293,7 @@
my $err_obj = $@;
while ($err_obj) {
my $err;
+ $err->{uri} = $err_obj->file();
$err->{src} = '...'; # do this with show_open_entities()?
$err->{line} = $err_obj->line();
$err->{char} = $err_obj->column();
@@ -1391,6 +1394,7 @@
# formatting the error message for output
my $err;
+ # TODO: $err->{uri} (need test case)
$err->{src} = '...'; # do this with show_open_entities()?
$err->{line} = $xmlwf_error_line;
$err->{char} = $xmlwf_error_col;
@@ -2327,6 +2331,30 @@
foreach my $err (@{$File->{Errors}}) {
my $line;
my $col = 0;
+
+ # We want errors in the doc that was validated to appear without
+ # $err->{uri}, and non-doc errors with it pointing to the external
+ # entity or the like where the error is. This usually works as
+ # long as we're passing docs to parsers as strings, but S::P::O
+ # (at least as of 0.994) seems to give us "3" as the FileName in
+ # those cases so we try to filter out everything that doesn't look
+ # like a useful URI.
+ if ($err->{uri}) {
+ if ($err->{uri} !~ m|/|) {
+ delete $err->{uri};
+ }
+ else {
+ # Mask local file paths
+ my $uri = URI->new($err->{uri});
+ if (!$uri->scheme() || $uri->scheme() eq 'file') {
+ $err->{uri_is_file} = TRUE;
+ $err->{uri} = ($uri->path_segments())[-1];
+ }
+ else {
+ $err->{uri} = $uri->canonical();
+ }
+ }
+ }
# avoid truncating lines that do not exist
if (defined($err->{line}) && $File->{Content}->[$err->{line} - 1])
@@ -3430,6 +3458,7 @@
# but not present
my $err;
my $location = $self->{_parser}->get_location();
+ $err->{uri} = $location->{FileName};
$err->{src} = '...'; # do this with show_open_entities()?
$err->{line} = $location->{LineNumber};
$err->{char} = $location->{ColumnNumber};
@@ -3451,6 +3480,7 @@
# whine if root xmlns element is not the one specificed by the spec
my $err;
my $location = $self->{_parser}->get_location();
+ $err->{uri} = $location->{FileName};
$err->{src} = '...'; # do this with show_open_entities()?
$err->{line} = $location->{LineNumber};
$err->{char} = $location->{ColumnNumber};
@@ -3479,10 +3509,9 @@
}
my $File = $self->{_file};
- # TODO: this does not filter out errors in DTDs.
-
my $err;
+ $err->{uri} = $self->{_parser}->get_location()->{FileName};
$err->{src} = '...'; # do this with show_open_entities()?
$err->{line} = $mess->{primary_message}{LineNumber};
$err->{char} = $mess->{primary_message}{ColumnNumber} + 1;
diff -r 1e4cf1d7ea99 -r 237e5cb768d9 share/templates/en_US/error_loop.tmpl
--- a/share/templates/en_US/error_loop.tmpl Sun Jul 04 11:11:29 2010 +0300
+++ b/share/templates/en_US/error_loop.tmpl Sun Jul 04 11:31:14 2010 +0300
@@ -2,7 +2,8 @@
<TMPL_LOOP NAME="file_errors">
<li<TMPL_IF NAME="class"> class="<TMPL_VAR NAME="class">"</TMPL_IF>>
<span class="err_type"><TMPL_IF NAME="err_type_info"><img src="images/info_icons/info.png" alt="Info" title="Info" /></TMPL_IF><TMPL_IF NAME="err_type_warn"><img src="images/info_icons/warning.png" alt="Warning" title="Warning" /></TMPL_IF><TMPL_IF NAME="err_type_err"><img src="images/info_icons/error.png" alt="Error" title="Error" /></TMPL_IF></span>
- <TMPL_IF NAME="line"><em>Line <TMPL_IF NAME="opt_show_source"><a href="#line-<TMPL_VAR NAME="line" ESCAPE="HTML">"></TMPL_IF><TMPL_VAR NAME="line" ESCAPE="HTML"><TMPL_IF NAME="opt_show_source"></a></TMPL_IF><TMPL_IF NAME="char">,
+ <TMPL_IF NAME="uri">(<TMPL_IF NAME="uri_is_file">Validator local file "<TMPL_VAR NAME="uri" ESCAPE="HTML">"<TMPL_ELSE><a href="<TMPL_VAR NAME="uri" ESCAPE="HTML">"><TMPL_VAR NAME="uri" ESCAPE="HTML"></a></TMPL_IF>)</TMPL_IF>
+ <TMPL_IF NAME="line"><em>Line <TMPL_IF NAME="opt_show_source"><TMPL_UNLESS NAME="uri"><a href="#line-<TMPL_VAR NAME="line" ESCAPE="HTML">"></TMPL_UNLESS></TMPL_IF><TMPL_VAR NAME="line" ESCAPE="HTML"><TMPL_IF NAME="opt_show_source"><TMPL_UNLESS NAME="uri"></a></TMPL_UNLESS></TMPL_IF><TMPL_IF NAME="char">,
Column <TMPL_VAR NAME="char" ESCAPE="HTML"></TMPL_IF></em>:</TMPL_IF>
<span class="msg"><TMPL_VAR NAME="msg" ESCAPE="HTML"></span>
<TMPL_IF NAME="src"><pre><code class="input"><TMPL_VAR NAME="src"></code></pre></TMPL_IF>
diff -r 1e4cf1d7ea99 -r 237e5cb768d9 share/templates/en_US/error_loop_grouped.tmpl
--- a/share/templates/en_US/error_loop_grouped.tmpl Sun Jul 04 11:11:29 2010 +0300
+++ b/share/templates/en_US/error_loop_grouped.tmpl Sun Jul 04 11:31:14 2010 +0300
@@ -9,8 +9,9 @@
<ul>
<TMPL_LOOP NAME="instances">
<li>
- <em>Line <TMPL_IF NAME="opt_show_source"><a href="#line-<TMPL_VAR NAME="line"
- ESCAPE="HTML">"></TMPL_IF><TMPL_VAR NAME="line" ESCAPE="HTML"><TMPL_IF NAME="opt_show_source"></a></TMPL_IF>,
+ <TMPL_IF NAME="uri">(<TMPL_IF NAME="uri_is_file">Validator local file "<TMPL_VAR NAME="uri" ESCAPE="HTML">"<TMPL_ELSE><a href="<TMPL_VAR NAME="uri" ESCAPE="HTML">"><TMPL_VAR NAME="uri" ESCAPE="HTML"></a></TMPL_IF>)</TMPL_IF>
+ <em>Line <TMPL_IF NAME="opt_show_source"><TMPL_UNLESS NAME="uri"><a href="#line-<TMPL_VAR NAME="line"
+ ESCAPE="HTML">"></TMPL_UNLESS></TMPL_IF><TMPL_VAR NAME="line" ESCAPE="HTML"><TMPL_IF NAME="opt_show_source"><TMPL_UNLESS NAME="uri"></a></TMPL_UNLESS></TMPL_IF>,
column <TMPL_VAR NAME="char" ESCAPE="HTML"></em>:
<span><TMPL_VAR NAME="msg" ESCAPE="HTML"></span>
<TMPL_IF NAME="src"><pre><code class="input"><TMPL_VAR NAME="src"></code></pre></TMPL_IF>
Received on Sunday, 4 July 2010 08:31:28 UTC