.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "WebService::Validator::HTML::W3C 3pm"
.TH WebService::Validator::HTML::W3C 3pm "2022-06-28" "perl v5.34.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
WebService::Validator::HTML::W3C \- Access the W3Cs online HTML validator
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use WebService::Validator::HTML::W3C;
\&
\& my $v = WebService::Validator::HTML::W3C\->new(
\& detailed => 1
\& );
\&
\& if ( $v\->validate("http://www.example.com/") ) {
\& if ( $v\->is_valid ) {
\& printf ("%s is valid\en", $v\->uri);
\& } else {
\& printf ("%s is not valid\en", $v\->uri);
\& foreach my $error ( @{$v\->errors} ) {
\& printf("%s at line %d\en", $error\->msg,
\& $error\->line);
\& }
\& }
\& } else {
\& printf ("Failed to validate the website: %s\en", $v\->validator_error);
\& }
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
WebService::Validator::HTML::W3C provides access to the W3C's online
Markup validator. As well as reporting on whether a page is valid it
also provides access to a detailed list of the errors and where in
the validated document they occur.
.SH "METHODS"
.IX Header "METHODS"
.SS "new"
.IX Subsection "new"
.Vb 1
\& my $v = WebService::Validator::HTML::W3C\->new();
.Ve
.PP
Returns a new instance of the WebService::Validator::HTML::W3C object.
.PP
There are various options that can be set when creating the Validator
object like so:
.PP
.Vb 1
\& my $v = WebService::Validator::HTML::W3C\->new( http_timeout => 20 );
.Ve
.IP "validator_uri" 4
.IX Item "validator_uri"
The \s-1URI\s0 of the validator to use. By default this accesses the W3Cs validator at http://validator.w3.org/check. If you have a local installation of the validator ( recommended if you wish to do a lot of testing ) or wish to use a validator at another location then you can use this option. Please note that you need to use the full path to the validator cgi.
.IP "ua" 4
.IX Item "ua"
The user agent to use. Should be an LWP::UserAgent object or something that provides the same interface. If this argument is provided, the \f(CW\*(C`http_timeout\*(C'\fR and \f(CW\*(C`proxy\*(C'\fR arguments are ignored.
.IP "http_timeout" 4
.IX Item "http_timeout"
How long (in seconds) to wait for the \s-1HTTP\s0 connection to timeout when
contacting the validator. By default this is 30 seconds.
.IP "detailed" 4
.IX Item "detailed"
This fetches the \s-1XML\s0 response from the validator in order to provide information for the errors method. You should set this to true if you intend to use the errors method.
.IP "proxy" 4
.IX Item "proxy"
An \s-1HTTP\s0 proxy to use when communicating with the validation service.
.IP "output" 4
.IX Item "output"
Controls which output format is used. Can be either xml or soap12.
.Sp
The default is soap12 as the \s-1XML\s0 format is deprecated and is likely to be removed in the future.
.Sp
The default will always work so unless you're using a locally installed Validator you can safely ignore this.
.SS "validate"
.IX Subsection "validate"
.Vb 1
\& $v\->validate( \*(Aqhttp:://www.example.com/\*(Aq );
.Ve
.PP
Validate a \s-1URI.\s0 Returns 0 if the validation fails (e.g if the
validator cannot be reached), otherwise 1.
.SS "validate_file"
.IX Subsection "validate_file"
.Vb 1
\& $v\->validate_file( \*(Aq./file.html\*(Aq );
.Ve
.PP
Validate a file by uploading it to the W3C Validator. \s-1NB\s0 This has only been tested on a Linux box so may not work on non unix machines.
.SS "validate_markup"
.IX Subsection "validate_markup"
.Vb 1
\& $v\->validate_markup( $markup );
.Ve
.PP
Validate a scalar containing \s-1HTML.\s0
.SS "Alternate interface"
.IX Subsection "Alternate interface"
You can also pass a hash in to specify what you wish to validate. This is provided to ensure compatibility with the \s-1CSS\s0 validator module.
.PP
.Vb 3
\& $v\->validate( uri => \*(Aqhttp://example.com/\*(Aq );
\& $v\->validate( string => $markup );
\& $v\->validate( file => \*(Aq./file.html\*(Aq );
.Ve
.SS "is_valid"
.IX Subsection "is_valid"
.Vb 1
\& $v\->is_valid;
.Ve
.PP
Returns true (1) if the \s-1URI\s0 validated otherwise 0.
.SS "uri"
.IX Subsection "uri"
.Vb 1
\& $v\->uri();
.Ve
.PP
Returns the \s-1URI\s0 of the last page on which validation succeeded.
.SS "num_errors"
.IX Subsection "num_errors"
.Vb 1
\& $num_errors = $v\->num_errors();
.Ve
.PP
Returns the number of errors that the validator encountered.
.SS "errorcount"
.IX Subsection "errorcount"
Synonym for num_errors. There to match \s-1CSS\s0 Validator interface.
.SS "warningcount"
.IX Subsection "warningcount"
.Vb 1
\& $num_errors = $v\->warningcount();
.Ve
.PP
Returns the number of warnings that the validator encountered.
.SS "errors"
.IX Subsection "errors"
.Vb 1
\& $errors = $v\->errors();
\&
\& foreach my $err ( @$errors ) {
\& printf("line: %s, col: %s\en\eterror: %s\en",
\& $err\->line, $err\->col, $err\->msg);
\& }
.Ve
.PP
Returns an array ref of WebService::Validator::HTML::W3C::Error objects.
These have line, col and msg methods that return a line number, a column
in that line and the error that occurred at that point.
.PP
Note that you need XML::XPath for this to work and you must have initialised
WebService::Validator::HTML::W3C with the detailed option. If you have not
set the detailed option a warning will be issued, the detailed option will
be set and a second request made to the validator in order to fetch the
required information.
.PP
If there was a problem processing the detailed information then this method
will return 0.
.SS "warnings"
.IX Subsection "warnings"
.Vb 1
\& $warnings = $v\->warnings();
.Ve
.PP
Works exactly the same as errors only returns an array ref of
WebService::Validator::HTML::W3C::Warning objects. In all other respects it's the same.
.SS "validator_error"
.IX Subsection "validator_error"
.Vb 1
\& $error = $v\->validator_error();
.Ve
.PP
Returns a string indicating why validation may not have occurred. This is not
the reason that a webpage was invalid. It is the reason that no meaningful
information about the attempted validation could be obtained. This is most
likely to be an \s-1HTTP\s0 error
.PP
Possible values are:
.IP "You need to supply a \s-1URI\s0 to validate" 4
.IX Item "You need to supply a URI to validate"
You didn't pass a \s-1URI\s0 to the validate method
.IP "You need to supply a \s-1URI\s0 with a scheme" 4
.IX Item "You need to supply a URI with a scheme"
The \s-1URI\s0 you passed to validate didn't have a scheme on the front. The
W3C validator can't handle URIs like www.example.com but instead
needs URIs of the form http://www.example.com/.
.IP "Not a W3C Validator or Bad \s-1URI\s0" 4
.IX Item "Not a W3C Validator or Bad URI"
The \s-1URI\s0 did not return the headers that WebService::Validator::HTML::W3C
relies on so it is likely that there is not a W3C Validator at that \s-1URI.\s0
The other possibility is that it didn't like the \s-1URI\s0 you provided. Sadly
the Validator doesn't give very useful feedback on this at the moment.
.IP "Could not contact validator" 4
.IX Item "Could not contact validator"
WebService::Validator::HTML::W3C could not establish a connection to the \s-1URI.\s0
.IP "Did not get a sensible result from the validator" 4
.IX Item "Did not get a sensible result from the validator"
Should never happen and most likely indicates a problem somewhere but
on the off chance that WebService::Validator::HTML::W3C is unable to make
sense of the response from the validator you'll get this error.
.IP "Result format does not appear to be SOAP|XML" 4
.IX Item "Result format does not appear to be SOAP|XML"
If you've asked for detailed results and the reponse from the validator
isn't in the expected format then you'll get this error. Most likely to
happen if you ask for \s-1SOAP\s0 output from a validator that doesn't
support that format.
.IP "You need to provide a uri, string or file to validate" 4
.IX Item "You need to provide a uri, string or file to validate"
You've passed in a hash ( or in fact more than one argument ) to validate
but the hash does not contain one of the three expected keys.
.SS "validator_uri"
.IX Subsection "validator_uri"
.Vb 2
\& $uri = $v\->validator_uri();
\& $v\->validator_uri(\*(Aqhttp://validator.w3.org/check\*(Aq);
.Ve
.PP
Returns or sets the \s-1URI\s0 of the validator to use. Please note that you need
to use the full path to the validator cgi.
.SS "http_timeout"
.IX Subsection "http_timeout"
.Vb 2
\& $timeout = $v\->http_timeout();
\& $v\->http_timeout(10);
.Ve
.PP
Returns or sets the timeout for the \s-1HTTP\s0 request.
.SH "OTHER MODULES"
.IX Header "OTHER MODULES"
Please note that there is also an official W3C module that is part of the
W3C::LogValidator distribution. However that module is not very useful outside
the constraints of that package. WebService::Validator::HTML::W3C is meant as a more general way to access the W3C Validator.
.PP
HTML::Validator uses nsgmls to validate against
the W3Cs DTDs. You have to fetch the relevant DTDs and so on.
.PP
There is also the HTML::Parser based HTML::Lint which mostly checks for
known tags rather than \s-1XML/HTML\s0 validity.
.PP
WebService::Validator::CSS::W3C provides the same functionality as this module
for the W3C's \s-1CSS\s0 validator.
.SH "IMPORTANT"
.IX Header "IMPORTANT"
This module is not in any way associated with the W3C so please do not
report any problems with this module to them. Also please remember that
the online Validator is a shared resource so do not abuse it. This means
sleeping between requests. If you want to do a lot of testing against it
then please consider downloading and installing the Validator software
which is available from the W3C. Debian testing users will also find that
it is available via apt-get.
.SH "BUGS"
.IX Header "BUGS"
While the interface to the Validator is fairly stable it may be
updated. I will endeavour to track any changes with this module so please
check on \s-1CPAN\s0 for new versions if you find things break. Also note that this
module is only guaranteed to work with the currently stable version of the
validator. It will most likely work with any Beta versions but don't rely
on it.
.PP
If in doubt please try and run the test suite before reporting bugs. Note
that in order to run tests against the validator service you will need to
have a connection to the internet and also set an environment variable called
\&\s-1TEST_AUTHOR.\s0
.PP
That said I'm very happy to hear about bugs. All the more so if they come
with patches ;).
.PP
Please use for filing bug reports, and indeed feature
requests. The code can also be found on github .
.SH "THANKS"
.IX Header "THANKS"
To the various people on the code review ladder mailing list who
provided useful suggestions.
.PP
Carl Vincent provided a patch to allow for proxy support.
.PP
Chris Dolan provided a patch to allow for custom user agents.
.PP
Matt Ryder provided a patch for support of the explanations in the \s-1SOAP\s0 output.
.SH "SUPPORT"
.IX Header "SUPPORT"
author email or via .
.SH "AUTHOR"
.IX Header "AUTHOR"
Struan Donald
.PP
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
Copyright (C) 2003\-2008 Struan Donald. All rights reserved.
.SH "LICENSE"
.IX Header "LICENSE"
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fBperl\fR\|(1).