XML::Checker::Parser 1.02 review

Download
by rbytes.net on

XML::Checker::Parser is an XML::Parser that validates at parse time. SYNOPSIS use XML::Checker::Parser; my %expat_options

License: Perl Artistic License
File size: 360K
Developer: Enno Derksen
0 stars award from rbytes.net

XML::Checker::Parser is an XML::Parser that validates at parse time.

SYNOPSIS

use XML::Checker::Parser;

my %expat_options = (KeepCDATA => 1,
Handlers => [ Unparsed => &my_Unparsed_handler ]);
my $parser = new XML::Checker::Parser (%expat_options);

eval {
local $XML::Checker::FAIL = &my_fail;
$parser->parsefile ("fail.xml");
};
if ($@) {
# Either XML::Parser (expat) threw an exception or my_fail() died.
... your error handling code here ...
}

# Throws an exception (with die) when an error is encountered, this
# will stop the parsing process.
# Don't die if a warning or info message is encountered, just print a message.
sub my_fail {
my $code = shift;
die XML::Checker::error_string ($code, @_) if $code < 200;
XML::Checker::print_error ($code, @_);
}

XML::Checker::Parser extends XML::Parser

I hope the example in the SYNOPSIS says it all, just use XML::Checker::Parser as if it were an XML::Parser. See XML::Parser for the supported (expat) options.

You can also derive your parser from XML::Checker::Parser instead of from XML::Parser. All you should have to do is replace:

package MyParser;
@ISA = qw( XML::Parser );
with:
package MyParser;
@ISA = qw( XML::Checker::Parser );

Requirements:
Perl

XML::Checker::Parser 1.02 keywords