Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

xml::dom::valparser(3pm) [debian man page]

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

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 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 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::Document 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 SkipInsignifWS options. See XML::Checker::Parser for details. AUTHOR
Enno Derksen is the original author. Send bug reports, hints, tips, suggestions to T.J. Mather at <tjmather@tjmather.com>. SEE ALSO
XML::DOM, XML::Checker ("SEE_ALSO" in XML::Checker) perl v5.10.0 2001-08-26 XML::DOM::ValParser(3pm)

Check Out this Related Man Page

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

NAME
XML::DOM::Document - An XML document node in XML::DOM DESCRIPTION
XML::DOM::Document extends XML::DOM::Node. It is the main root of the XML document structure as returned by XML::DOM::Parser::parse and XML::DOM::Parser::parsefile. Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a Document, the Document interface also contains the factory methods needed to create these objects. The Node objects created have a getOwnerDocument method which associates them with the Document within whose context they were created. METHODS getDocumentElement This is a convenience method that allows direct access to the child node that is the root Element of the document. getDoctype The Document Type Declaration (see DocumentType) associated with this document. For HTML documents as well as XML documents without a document type declaration this returns undef. The DOM Level 1 does not support editing the Document Type Declaration. Not In DOM Spec: This implementation allows editing the doctype. See XML::DOM::ignoreReadOnly for details. getImplementation The DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations. createElement (tagName) Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object. DOMExceptions: o INVALID_CHARACTER_ERR Raised if the tagName does not conform to the XML spec. createTextNode (data) Creates a Text node given the specified string. createComment (data) Creates a Comment node given the specified string. createCDATASection (data) Creates a CDATASection node given the specified string. createAttribute (name [, value [, specified ]]) Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttribute method. Not In DOM Spec: The DOM Spec does not allow passing the value or the specified property in this method. In this implementation they are optional. Parameters: value The attribute's value. See Attr::setValue for details. If the value is not supplied, the specified property is set to 0. specified Whether the attribute value was specified or whether the default value was used. If not supplied, it's assumed to be 1. DOMExceptions: o INVALID_CHARACTER_ERR Raised if the name does not conform to the XML spec. createProcessingInstruction (target, data) Creates a ProcessingInstruction node given the specified name and data strings. Parameters: target The target part of the processing instruction. data The data for the node. DOMExceptions: o INVALID_CHARACTER_ERR Raised if the target does not conform to the XML spec. createDocumentFragment Creates an empty DocumentFragment object. createEntityReference (name) Creates an EntityReference object. Additional methods not in the DOM Spec getXMLDecl and setXMLDecl (xmlDecl) Returns the XMLDecl for this Document or undef if none was specified. Note that XMLDecl is not part of the list of child nodes. setDoctype (doctype) Sets or replaces the DocumentType. NOTE: Don't use appendChild or insertBefore to set the DocumentType. Even though doctype will be part of the list of child nodes, it is handled specially. getDefaultAttrValue (elem, attr) Returns the default attribute value as a string or undef, if none is available. Parameters: elem The element tagName. attr The attribute name. getEntity (name) Returns the Entity with the specified name. createXMLDecl (version, encoding, standalone) Creates an XMLDecl object. All parameters may be undefined. createDocumentType (name, sysId, pubId) Creates a DocumentType object. SysId and pubId may be undefined. createNotation (name, base, sysId, pubId) Creates a new Notation object. Consider using XML::DOM::DocumentType::addNotation! createEntity (parameter, notationName, value, sysId, pubId, ndata) Creates an Entity object. Consider using XML::DOM::DocumentType::addEntity! createElementDecl (name, model) Creates an ElementDecl object. DOMExceptions: o INVALID_CHARACTER_ERR Raised if the element name (tagName) does not conform to the XML spec. createAttlistDecl (name) Creates an AttlistDecl object. DOMExceptions: o INVALID_CHARACTER_ERR Raised if the element name (tagName) does not conform to the XML spec. expandEntity (entity [, parameter]) Expands the specified entity or parameter entity (if parameter=1) and returns its value as a string, or undef if the entity does not exist. (The entity name should not contain the '%', '&' or ';' delimiters.) check ( [$checker] ) Uses the specified XML::Checker to validate the document. If no XML::Checker is supplied, a new XML::Checker is created. See XML::Checker for details. check_sax ( [$checker] ) Similar to check() except it uses the SAX interface to XML::Checker instead of the expat interface. This method may disappear or replace check() at some time. createChecker () Creates an XML::Checker based on the document's DTD. The $checker can be reused to check any elements within the document. Create a new XML::Checker whenever the DOCTYPE section of the document is altered! perl v5.12.1 2001-08-26 XML::DOM::Document(3)
Man Page