Web::XML::DTDValidator
An XML DTD validator
SYNOPSIS
use Web::XML::DTDValidator;
$validator = Web::XML::DTDValidator->new;
$validator->onerror (sub {
my %error = @_;
...
});
$validator->validate_document ($doc);
DESCRIPTION
The Web::XML::DTDValidator
module is an XML DTD validator, which can be used in combination with Web::XML::Parser.
This module implements validation of DOM Document
against its DTD. For example, it checks whether elements in the document conform to the content models in the DTD, and whether the attribute values in the document conform to the attribute definitions in the DTD. It can't check syntactical or physical constraints of XML (e.g. how XML entities are used in the document) as the Document
does not preserve physical structures of the document.
To validate an XML document, including both physical and logical constraints, streaming API of the parser module Web::XML::Parser, the strict-checker module Web::XML::Parser::XML1Checker for the parser, and an entity resolution implementation onextentref
handler for the parser, must be used to create a Document
input to this module.
This module is also invoked as part of Web::HTML::Validator validation process.
METHODS
Following methods are available:
$validator = Web::XML::DTDValidator->new
-
Create a new validator.
$code = $validator->onerror
$validator->onerror ($new_code)
-
Get or set the error handler for the validator. Any parse error, as well as warning and additional processing information, is reported to the handler. See
<https://github.com/manakai/data-errors/blob/master/doc/onerror.txt>
for details of error handling.The code is not expected to throw any exception.
The value should not be set while the validator is running. If the value is changed, the result is undefined.
$validator->validate_document ($doc)
-
Validate the document.
The input must be a DOM
Document
object. See<https://github.com/manakai/perl-web-markup#dependency>
for the requirements on theDocument
object.Any validity or other error is reported through the
onerror
handler. If no error with levelm
has been reported, the document has no violation to the validity constraints supported by this module. (However, not all errors with levelm
are violation to the validity constraints. There are other kinds of errors specified in relevant specifications.)
SPECIFICATIONS
- XML
-
Extensible Markup Language (XML) 1.0 (Fifth Edition)
<http://www.w3.org/TR/xml/>
. - XMLNS
-
Namespaces in XML 1.0 (Third Edition)
<http://www.w3.org/TR/xml-names/>
. - DOMDTDEF
-
XML processing and DOM Document Type Definitions
<http://suika.suikawiki.org/www/markup/xml/domdtdef/domdtdef-work>
.
XML 1.1 is not supported.
Unless otherwise specified, a document MUST NOT be in error.
A conformance checker MUST validate an XML document against its DTD when the document contains the DOCTYPE declaration. Otherwise, it MAY validate the document (but a document without the DOCTYPE declaration is always invalid by definition).
SEE ALSO
AUTHOR
Wakaba <wakaba@suikawiki.org>.
LICENSE
Copyright 2003-2015 Wakaba <wakaba@suikawiki.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.