.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "XML::DOM::ValParser 3pm" .TH XML::DOM::ValParser 3pm "2021-01-03" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" XML::DOM::ValParser \- an XML::DOM::Parser that validates at parse time .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use XML::DOM::ValParser; \& \& my %expat_options = (KeepCDATA => 1, \& Handlers => [ Unparsed => \e&my_Unparsed_handler ]); \& my $parser = new XML::DOM::ValParser (%expat_options); \& \& eval { \& local $XML::Checker::FAIL = \e&my_fail; \& my $doc = $parser\->parsefile ("fail.xml"); \& ... XML::DOM::Document was created successfully ... \& }; \& 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\*(Aqt 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, @_); \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Use XML::DOM::ValParser wherever you would use XML::DOM::Parser and your \s-1XML\s0 will be checked using XML::Checker at parse time. .PP See \s-1XML::DOM\s0 for details on XML::DOM::Parser options. See XML::Checker for details on setting the fail handler (my_fail.) .PP 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. .SH "XML::DOM::ValParser" .IX Header "XML::DOM::ValParser" XML::DOM::ValParser extends from XML::Checker::Parser. It creates an XML::Checker object and routes all event handlers through the checker, before processing the events to create the XML::DOM::Document. .PP Just like XML::Checker::Parser, the checker object can be retrieved with the \fBgetChecker()\fR method and can be reused later on (provided that the \s-1DOCTYPE\s0 section of the XML::DOM::Document did not change in the mean time.) .PP You can control which errors are fatal (and therefore should stop creation of the XML::DOM::Document) by filtering the appropriate error codes in the global \f(CW$XML::Checker::FAIL\fR handler (see \*(L"\s-1ERROR_HANDLING\*(R"\s0 in XML::Checker) and calling \fIdie\fR or \fIcroak\fR appropriately. .PP Just like XML::Checker::Parser, XML::DOM::ValParser supports the SkipExternalDTD and SkipInsignifWS options. See XML::Checker::Parser for details. .SH "AUTHOR" .IX Header "AUTHOR" Enno Derksen is the original author. .PP Send bug reports, hints, tips, suggestions to T.J. Mather at <\fItjmather@tjmather.com\fR>. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\s-1XML::DOM\s0, XML::Checker (\*(L"\s-1SEE_ALSO\*(R"\s0 in XML::Checker)