MAN page from Old RedHat 6.X perl-libxml-enno-1.00-6.i386.rpm
lib::XML::DOM::ValParser
Section: User Contributed Perl Documentation (3)
Updated: perl 5.005, patch 03
Index NAME
XML::DOM::ValParser - an XML::DOM::Parser that validates at parse time
SYNOPSIS
use XML::DOM::ValParser;
my %expat_options = (KeepCDATA => 1, Handlers => [ Unparsed => \&my_Unparsed_handler ]); my $parser = new XML::DOM::ValParser (%expat_options);
eval { local $XML::Checker::FAIL = \&my_fail; my $doc = $parser->parsefile ("fail.xml"); ... XML::DOM::Document was created sucessfully ... }; if ($@) { # Either XML::Parser (expat) threw an exception or my_fail() died. ... your error handling code here ... # Note that the XML::DOM::Document is automatically disposed off and # will be garbage collected } # 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, @_); } DESCRIPTION
Use XML::DOM::ValParser wherever you would use the
XML::DOM::Parser manpage andyour XML will be checked using the
XML::Checker manpage at parse time.
See the XML::DOM manpage for details on XML::DOM::Parser options.See the XML::Checker manpage for details on setting the fail handler (my_fail.)
The following handlers are currently supported, just like XML::DOM::Parser:Init, Final, Char, Start, End, Default, Doctype, CdataStart, CdataEnd, XMLDecl, Entity, Notation, Proc, Default, Comment, Attlist, Element, Unparsed.
XML::DOM::ValParser
XML::DOM::ValParser extends from the
XML::Checker::Parser manpage. It creates anthe
XML::Checker manpage object and routes all event handlers through the checker,before processing the events to create the XML::DOM::Document.
Just like the XML::Checker::Parser manpage, the checker object can be retrieved withthe getChecker() method and can be reused later on (provided that the DOCTYPEsection of the XML::DOM::Document did not change in the mean time.)
You can control which errors are fatal (and therefore should stop creationof the XML::DOM::Document) by filtering the appropriate error codes inthe global $XML::Checker::FAIL handler (see the ERROR_HANDLING entry in the XML::Checker manpage) and calling die or croak appropriately.
Just like XML::Checker::Parser, XML::DOM::ValParser supports the SkipExternalDTD and SkipInsignifWS options. See the XML::Checker::Parser manpagefor details.
AUTHOR
Send bug reports, hints, tips, suggestions to Enno Derksen at<
ennoAATTatt.com>.
SEE ALSO
the
XML::DOM manpage, the
XML::Checker manpage (the
SEE_ALSO entry in the
XML::Checker manpage)
Index
- NAME
- SYNOPSIS
- DESCRIPTION
- XML::DOM::ValParser
- AUTHOR
- SEE ALSO
This document was created byman2html,using the manual pages.