Whatpm::ContentChecker - DOM Conformance Checker
use Whatpm::ContentChecker; Whatpm::ContentChecker->check_document ($doc, sub { my %arg = @_; warn get_node_path ($arg{node}), ": ", ($arg{level} || "Error"), ": ", $arg{type}, "\n"; }); Whatpm::ContentChecker->check_element ($doc, sub { my %arg = @_; warn get_node_path ($arg{node}), ": ", ($arg{level} || "Error"), ": ", $arg{type}, "\n"; });
The Whatpm::ContentChecker
Perl module contains two methods
to validate DOM tree for its conformance to the markup language
in use.
This module is part of Whatpm, Perl Modules for Web Hypertext Application Technologies, which is a subproject of manakai.
This module contains two static methods:
Checks a document, $document, and its descendant for their
conformance. If there is an error or a warnign, then the
$onerror CODE
is invoked with named arguments same
as ones for the method check_element
.
Checks an element, $element, and its descendant for their conformance.
If there is an error or a warning, then the $onerror CODE
is invoked with named arguments:
undef
)
A string which describes the severity of the error or warning. For the list of the severities, see <http://suika.fam.cx/gate/2005/sw/Whatpm%20Error%20Types>.
The node with which the error is detected.
A string which describes the type of the error or warning. For the list of the errors and warnings, see <http://suika.fam.cx/gate/2005/sw/Whatpm%20Error%20Types>.
This conformance checker is work in progress; it might not be able to detect all the errors in the DOM tree, and it might detect an error for a node that is conforming in fact.
This section is not complete.
This section describes various internal constructions used in the Whatpm::ContentChecker manpage and relevant modules. These data structures are not public interfaces -- they should not be accessed or modified by applications. They are documented here for the convenience of development only.
$self->{flag}
Structure$self->{flag}->{has_label}
This flag is set to a true value if and only if there is a label
element ancestor of the current node.
$self->{flag}->{has_labelable}
This flag is set to 1
if and only if a nearest ancestor label
element has the for
attribute and there is no labelable
form-associated element that is a descendant of the label
element
and precedes the current node in tree order. This flag is set to 2
if and only if there is a labelable form-associated element that is a
descendant of the nearest ancestor label
element of the current
node and precedes the current node in tree order. This flag is
otherwise set to a false value. However, when there is no ancestor
label
element of the current node, i.e. when
$self->{flag}->{has_label}
is false, the value of the
$self->{flag}->{has_labelable}
flag is undefined.
$element_state
Structure$element_state->{has_label_original}
Used to preserve the value of $self->{flag}->{has_label}
at the
time of invocation of the method element_start
for the element
being checked.
$element_state->{has_labelable_original}
Used to preserve the value of $self->{flag}->{has_labelable}
at
the time of invocation of the method element_start
for the element
being checked.
the Whatpm::ContentChecker::Atom manpage
the Whatpm::ContentChecker::HTML manpage
<http://suika.fam.cx/gate/2005/sw/Whatpm%20Error%20Types>
Wakaba <w@suika.fam.cx>
Copyright 2007-2008 Wakaba <w@suika.fam.cx>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.