NAME
WebService::Validator::Feed::W3C - Interface to the W3C Feed Validation service
SYNOPSIS
use WebService::Validator::Feed::W3C;
my $feed_url = "http://www.example.com";
my $val = WebService::Validator::CSS::W3C->new;
my $ok = $val->validate(url => $feed_url);
if ($ok and !$val->is_valid) {
print "Errors:\n";
printf " * %s\n", $_->{message}
foreach $val->errors
}
DESCRIPTION
This module is an interface to the W3C Feed Validation online service http://validator.w3.org/feed/, based on its SOAP 1.2 support. It helps to find errors in RSS or Atom feeds.
The following methods are available:
- my $val = WebService::Validator::Feed::W3C->new
- my $val = WebService::Validator::Feed::W3C->new($ua)
- my $val = WebService::Validator::Feed::W3C->new($ua, $url)
-
Creates a new WebService::Validator::Feed::W3C object. A custom LWP::UserAgent object can be supplied which is then used for HTTP communication with the W3C Feed Validation service. $url is the URL of the Feed Validator,
http://validator.w3.org/feed/check.cgi
by default. - my $success = $val->validate(%params)
-
Validate a feed takes
%params
as defined below. Eitherstring
oruri
must be supplied. Returns a true value if the validation succeeded (regardless of whether the style sheet contains errors).- string => $feed_string
-
An atom or RSS feed, as a string. It is currently unlikely that validation will work if the string is not a legal UTF-8 string. If a string is specified, the
uri
parameter will be ignored. Note thatGET
will be used to pass the string to the Validator, it might not work with overly long strings. - uri => $feed_uri
-
The location of a style sheet or a RSS/Atom feed containing or referencing style sheets.
- my $success = $val->success
-
Same as the return value of
validate()
. - my $is_valid = $val->is_valid
-
Returns a true value if the last attempt to
validate()
succeeded and the validator reported no errors in the style sheet. - my @errors = $val->errors
-
Returns a list with information about the errors found for the style sheet. An error is a hash reference; the example in the synopsis would currently return something like
( { context => 'p', property => 'color', expression => { start => '', end => 'not-a-color' } errortype => 'parse-error', message => 'not-a-color is not a color value', line => 0, } )
- my @warnings = $val->warnings
-
Returns a list with information about the warnings found for the style sheet. This is currently of limited use as it is broken, see http://www.w3.org/Bugs/Public/show_bug.cgi?id=771 for details.
@@example
- my $ua = $val->user_agent
- my $ua = $val->user_agent($new_ua)
-
The LWP::UserAgent object you supplied to the constructor or a custom object created at construction time you can manipulate.
# set timeout to 30 seconds $val->user_agent->timeout(30);
You can also supply a new object to replace the old one.
- my $uri = $val->validator_uri
- my $uri = $val->validator_uri($validator_uri)
-
Gets or sets the URI of the validator. If you did not specify a custom URI,
http://jigsaw.w3.org/css-validator/validator
by default. - my $response = $val->response
-
The HTTP::Response object returned from the last request. This is useful to determine why validation might have failed.
if (!$val->validate(string => $feed_string)) { if (!$val->response->is_success) { print $val->response->message, "\n" } }
- my $uri = $val->request_uri
-
The URI object used for the last request.
- my $som = $val->som
-
The SOAP::SOM object for the last successful deserialization, check the return value of
validate()
orsuccess()
before using the object.
NOTE
Please remember that the Feed Validation service is a shared resource, so do not abuse it: you should make your scripts sleep between requests.
AUTHOR
olivier Thereaux <ot@w3.org>
Based on the WebService::Validator::CSS::W3C module by Bjoern Hoehrmann <bjoern@hoehrmann.de> et.al.
This module is licensed under the same terms as Perl itself.