Package xml :: Package sax :: Module xmlreader :: Class IncrementalParser
[hide private]
[frames] | no frames]

_ClassType IncrementalParser

XMLReader --+
            |
           IncrementalParser
Known Subclasses:

This interface adds three extra methods to the XMLReader interface that allow XML parsers to support incremental parsing. Support for this interface is optional, since not all underlying XML parsers support this functionality.

When the parser is instantiated it is ready to begin accepting data from the feed method immediately. After parsing has been finished with a call to close the reset method must be called to make the parser ready to accept new data, either from feed or using the parse method.

Note that these methods must _not_ be called during parsing, that is, after parse has been called and before it returns.

By default, the class also implements the parse method of the XMLReader interface using the feed, close and reset methods of the IncrementalParser interface as a convenience to SAX 2.0 driver writers.

Instance Methods [hide private]
 
__init__(self, bufsize=65536)
 
parse(self, source)
Parse an XML document from a system identifier or an InputSource.
 
feed(self, data)
This method gives the raw XML data in the data parameter to the parser and makes it parse the data, emitting the corresponding events.
 
prepareParser(self, source)
This method is called by the parse implementation to allow the SAX 2.0 driver to prepare itself for parsing.
 
close(self)
This method is called when the entire XML document has been passed to the parser through the feed method, to notify the parser that there are no more data.
 
reset(self)
This method is called after close has been called to reset the parser so that it is ready to parse new documents.

Inherited from XMLReader: getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getProperty, setContentHandler, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setLocale, setProperty

Method Details [hide private]

__init__(self, bufsize=65536)
(Constructor)

 
Overrides: XMLReader.__init__

parse(self, source)

 

Parse an XML document from a system identifier or an InputSource.

Overrides: XMLReader.parse
(inherited documentation)

feed(self, data)

 

This method gives the raw XML data in the data parameter to the parser and makes it parse the data, emitting the corresponding events. It is allowed for XML constructs to be split across several calls to feed.

feed may raise SAXException.

close(self)

 

This method is called when the entire XML document has been passed to the parser through the feed method, to notify the parser that there are no more data. This allows the parser to do the final checks on the document and empty the internal data buffer.

The parser will not be ready to parse another document until the reset method has been called.

close may raise SAXException.

reset(self)

 

This method is called after close has been called to reset the parser so that it is ready to parse new documents. The results of calling parse or feed after close without calling reset are undefined.