Unix/Linux Go Back    

RedHat 9 (Linux i386) - man page for xml::dom::valparser (redhat section 3)

Linux & Unix Commands - Search Man Pages
Man Page or Keyword Search:   man
Select Man Page Set:       apropos Keyword Search (sections above)

XML::DOM::ValParser(3)	       User Contributed Perl Documentation	   XML::DOM::ValParser(3)

       XML::DOM::ValParser - an XML::DOM::Parser that validates at parse time

	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, @_);

       Use XML::DOM::ValParser wherever you would use XML::DOM::Parser and your XML will be
       checked using XML::Checker at parse time.

       See XML::DOM for details on XML::DOM::Parser options.  See XML::Checker 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 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.

       Just like XML::Checker::Parser, the checker object can be retrieved with the getChecker()
       method and can be reused later on (provided that the DOCTYPE section of the XML::DOM::Doc-
       ument did not change in the mean time.)

       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
       $XML::Checker::FAIL handler (see "ERROR_HANDLING" in XML::Checker) and calling die or
       croak appropriately.

       Just like XML::Checker::Parser, XML::DOM::ValParser supports the SkipExternalDTD and Skip-
       InsignifWS options. See XML::Checker::Parser for details.

       Send bug reports, hints, tips, suggestions to Enno Derksen at <enno@att.com>.

       XML::DOM, XML::Checker ("SEE_ALSO" in XML::Checker)

perl v5.8.0				    2000-01-31			   XML::DOM::ValParser(3)
Unix & Linux Commands & Man Pages : ©2000 - 2018 Unix and Linux Forums

All times are GMT -4. The time now is 06:28 PM.