Sami Itkonen > HTML-Validator-0.13 > HTML::Validator

Download:
HTML-Validator-0.13.tar.gz

Dependencies

Annotate this POD

Related Modules

HTML::Parser
HTML::Lint
HTML::TokeParser
HTML::SimpleParse
Regexp::Common
more...
By perlmonks.org

CPAN RT

New  1
Open  0
View Bugs
Report a bug
Module Version: 1   Source  

NAME ^

HTML::Validator - HTML validation by using nsgmls

SYNOPSIS ^

 use HTML::Validator;
 $doc = new HTML::Validator($file);
 $doc->validate;
 print "Document is valid\n" if $doc->is_valid;

DESCRIPTION ^

This module can be used to validate HTML (or SGML) documents. For the validation itself, it uses nsgmls and a set of document type definition files (aka DTDs).

HTML::Validator uses libwww-perl to validate remote files.

$doc->open($file)

The file or url will be used as the document to validate. This method will be called implicitely if the constructor is called with an argument.

$doc->doctype

Returns the document type.

The return value is undefined if no filename has been passed to the object via the constructor or the open method.

If the file has not been retrieved yet, it will be done.

If you want to replace the document type, you must do so with the first call to this method. The document types are defined in $doc->{dtdmap}.

$doc->checkdtd

Finds out the actual name of document type definition file that is used. The return value is the name of the file, or undefined if the document type is not defined.

$doc->validate

Validates the document. The return value is a reference to an array containing the modified output from nsgmls.

$doc->get_file

Internal method to get the file and process the doctype information.

$doc->substitute_dtd_url

If there is an URL in the doctype, it will be replaced to support nsgmls binaries that do not support URLs

$doc->replace_dtd

Replaces the document type definition on the file. The new dtd is the first argument, or the default dtd if no argument is supplied.

$doc->errors

Returns an error from nsgmls error output queue.

$doc->parse_errors

Internal method to parse the raw nsgmsl output to a more readable form. If you want to call this method more than once per object, purge the error output queue with $doc->errors first.

This method will call a parser method to do the actual parsing, which is $doc->parser() by default. It can overriden by setting $doc->{parser}.

$doc->parser

The default nsgmls output parser. This is called from parse_errors. If the return value is undef, then to parser is assumed to have found no errors. Otherwise the parser will return a reference to an array containing the errors.

$doc->is_valid

Returns 1 if document is valid, 0 if document is invalid and undef if document hasn't been validated yet.

$doc->source

Contains the source of the HTML file as a scalar.

$doc->message

Contains the message queue. If called with an argument, places a new message to the queue, without an argument a message (if any) is removed.

If the argument is '-1', the last message on the queue is returned.

$doc->reset

Resets the object to original state so we can reuse it

VARIABLES ^

$doc->{nsgmls}

The used nsgmls binary

$doc->{catalog}

The used catalog file

$doc->{message}

Array of messages

$doc->{maxerr}

The maximum number of errors. This is passed to nsgmls with the -E option

$doc->{doctype}

The document type for the document

$doc->{defaultdtd}

The default type for the document. By default this is 'html4'.

$doc->{dtdfile}

The dtd used for the document

$doc->{dtdmap}

The mapping for document types and the explicit document type definition strings

$doc->{parser}

The custom parser to use. See the information for the parser method.

REQUIREMENTS ^

  HTML::Validator requires that

SEE ALSO ^

LWP, nsgmls

ACKNOWLEDGEMENTS ^

Thanks go to:

 - Heikki Kantola <hezu@iki.fi>, for his help in the early testing
   phases and his excellent knowledge about HTML standards.

AVAILABILITY ^

The latest version of HTML::Validator can be found from http://www.iki.fi/si/HTML-Validator/.

It is also available from CPAN (http://www.perl.com/CPAN/).

COPYRIGHT ^

HTML::Validator is (c) 1997-1999 Sami Itkonen <si@iki.fi>

HTML::Validator is distributed under the GNU General Public License.