File: validate.pl

package info (click to toggle)
w3c-markup-validator 1.3%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,048 kB
  • sloc: javascript: 3,362; perl: 2,888; xml: 1,331; python: 427; sh: 216; makefile: 75
file content (31 lines) | stat: -rwxr-xr-x 851 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl
use WebService::Validator::HTML::W3C;
use XML::XPath;

my $v = WebService::Validator::HTML::W3C->new(
    detailed => 1,
    validator_uri => 'http://localhost/w3c-validator/check',
);
my $url = $ARGV[0] || http://www.erfworld.com;

if ($v->validate($url)) {
    if ($v->is_valid) {
        printf "%s is valid\n", $v->uri;
    }
    else {
        printf "%s is not valid\n", $v->uri;
	printf "======= ERRORS ========\n";
        foreach my $error (@{$v->errors}) {
            printf "%s at line %d\n", $error->msg, $error->line;
        }
	printf "======= WARNINGS ========\n";
        foreach my $warning (@{$v->warnings}) {
            printf "%s at line %d\n", $warning->msg, $warning->line;
        }
    }
}
else {
    printf "Failed to validate the website: %s\n", $v->validator_error;
}

# copyright 2003-2008, Struan Donald