Back to index

python3.2  3.2.2
Public Member Functions | Private Attributes
xml.sax.xmlreader.IncrementalParser Class Reference
Inheritance diagram for xml.sax.xmlreader.IncrementalParser:
Inheritance graph
[legend]
Collaboration diagram for xml.sax.xmlreader.IncrementalParser:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def parse
def feed
def prepareParser
def close
def reset
def getContentHandler
def setContentHandler
def getDTDHandler
def setDTDHandler
def getEntityResolver
def setEntityResolver
def getErrorHandler
def setErrorHandler
def setLocale
def getFeature
def setFeature
def getProperty
def setProperty

Private Attributes

 _bufsize

Detailed Description

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.

Definition at line 91 of file xmlreader.py.


Constructor & Destructor Documentation

def xml.sax.xmlreader.IncrementalParser.__init__ (   self,
  bufsize = 2**16 
)

Definition at line 111 of file xmlreader.py.

00111 
00112     def __init__(self, bufsize=2**16):
00113         self._bufsize = bufsize
00114         XMLReader.__init__(self)

Here is the caller graph for this function:


Member Function Documentation

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.

Reimplemented in xml.sax.expatreader.ExpatParser.

Definition at line 141 of file xmlreader.py.

00141 
00142     def close(self):
00143         """This method is called when the entire XML document has been
00144         passed to the parser through the feed method, to notify the
00145         parser that there are no more data. This allows the parser to
00146         do the final checks on the document and empty the internal
00147         data buffer.
00148 
00149         The parser will not be ready to parse another document until
00150         the reset method has been called.
00151 
00152         close may raise SAXException."""
00153         raise NotImplementedError("This method must be implemented!")

Here is the caller graph for this function:

def xml.sax.xmlreader.IncrementalParser.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.

Definition at line 127 of file xmlreader.py.

00127 
00128     def feed(self, data):
00129         """This method gives the raw XML data in the data parameter to
00130         the parser and makes it parse the data, emitting the
00131         corresponding events. It is allowed for XML constructs to be
00132         split across several calls to feed.
00133 
00134         feed may raise SAXException."""
00135         raise NotImplementedError("This method must be implemented!")

Here is the caller graph for this function:

Definition at line 34 of file xmlreader.py.

00034 
00035     def getContentHandler(self):
00036         "Returns the current ContentHandler."
00037         return self._cont_handler

def xml.sax.xmlreader.XMLReader.getDTDHandler (   self) [inherited]

Definition at line 42 of file xmlreader.py.

00042 
00043     def getDTDHandler(self):
00044         "Returns the current DTD handler."
00045         return self._dtd_handler

Definition at line 50 of file xmlreader.py.

00050 
00051     def getEntityResolver(self):
00052         "Returns the current EntityResolver."
00053         return self._ent_handler

def xml.sax.xmlreader.XMLReader.getErrorHandler (   self) [inherited]

Definition at line 58 of file xmlreader.py.

00058 
00059     def getErrorHandler(self):
00060         "Returns the current ErrorHandler."
00061         return self._err_handler

def xml.sax.xmlreader.XMLReader.getFeature (   self,
  name 
) [inherited]

Reimplemented in xml.sax.saxutils.XMLFilterBase, and xml.sax.expatreader.ExpatParser.

Definition at line 75 of file xmlreader.py.

00075 
00076     def getFeature(self, name):
00077         "Looks up and returns the state of a SAX2 feature."
00078         raise SAXNotRecognizedException("Feature '%s' not recognized" % name)

def xml.sax.xmlreader.XMLReader.getProperty (   self,
  name 
) [inherited]

Reimplemented in xml.sax.saxutils.XMLFilterBase, and xml.sax.expatreader.ExpatParser.

Definition at line 83 of file xmlreader.py.

00083 
00084     def getProperty(self, name):
00085         "Looks up and returns the value of a SAX2 property."
00086         raise SAXNotRecognizedException("Property '%s' not recognized" % name)

def xml.sax.xmlreader.IncrementalParser.parse (   self,
  source 
)

Reimplemented from xml.sax.xmlreader.XMLReader.

Reimplemented in xml.sax.expatreader.ExpatParser.

Definition at line 115 of file xmlreader.py.

00115 
00116     def parse(self, source):
00117         from . import saxutils
00118         source = saxutils.prepare_input_source(source)
00119 
00120         self.prepareParser(source)
00121         file = source.getByteStream()
00122         buffer = file.read(self._bufsize)
00123         while buffer:
00124             self.feed(buffer)
00125             buffer = file.read(self._bufsize)
00126         self.close()

Here is the caller graph for this function:

This method is called by the parse implementation to allow
the SAX 2.0 driver to prepare itself for parsing.

Reimplemented in xml.sax.expatreader.ExpatParser.

Definition at line 136 of file xmlreader.py.

00136 
00137     def prepareParser(self, source):
00138         """This method is called by the parse implementation to allow
00139         the SAX 2.0 driver to prepare itself for parsing."""
00140         raise NotImplementedError("prepareParser must be overridden!")

Here is the caller graph for this function:

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.

Reimplemented in xml.sax.expatreader.ExpatParser.

Definition at line 154 of file xmlreader.py.

00154 
00155     def reset(self):
00156         """This method is called after close has been called to reset
00157         the parser so that it is ready to parse new documents. The
00158         results of calling parse or feed after close without calling
00159         reset are undefined."""
00160         raise NotImplementedError("This method must be implemented!")
00161 
00162 # ===== LOCATOR =====

Here is the caller graph for this function:

def xml.sax.xmlreader.XMLReader.setContentHandler (   self,
  handler 
) [inherited]

Reimplemented in xml.sax.expatreader.ExpatParser.

Definition at line 38 of file xmlreader.py.

00038 
00039     def setContentHandler(self, handler):
00040         "Registers a new object to receive document content events."
00041         self._cont_handler = handler

def xml.sax.xmlreader.XMLReader.setDTDHandler (   self,
  handler 
) [inherited]

Definition at line 46 of file xmlreader.py.

00046 
00047     def setDTDHandler(self, handler):
00048         "Register an object to receive basic DTD-related events."
00049         self._dtd_handler = handler

def xml.sax.xmlreader.XMLReader.setEntityResolver (   self,
  resolver 
) [inherited]

Definition at line 54 of file xmlreader.py.

00054 
00055     def setEntityResolver(self, resolver):
00056         "Register an object to resolve external entities."
00057         self._ent_handler = resolver

def xml.sax.xmlreader.XMLReader.setErrorHandler (   self,
  handler 
) [inherited]

Definition at line 62 of file xmlreader.py.

00062 
00063     def setErrorHandler(self, handler):
00064         "Register an object to receive error-message events."
00065         self._err_handler = handler

def xml.sax.xmlreader.XMLReader.setFeature (   self,
  name,
  state 
) [inherited]

Reimplemented in xml.sax.saxutils.XMLFilterBase, and xml.sax.expatreader.ExpatParser.

Definition at line 79 of file xmlreader.py.

00079 
00080     def setFeature(self, name, state):
00081         "Sets the state of a SAX2 feature."
00082         raise SAXNotRecognizedException("Feature '%s' not recognized" % name)

def xml.sax.xmlreader.XMLReader.setLocale (   self,
  locale 
) [inherited]
Allow an application to set the locale for errors and warnings.

SAX parsers are not required to provide localization for errors
and warnings; if they cannot support the requested locale,
however, they must throw a SAX exception. Applications may
request a locale change in the middle of a parse.

Reimplemented in xml.sax.saxutils.XMLFilterBase.

Definition at line 66 of file xmlreader.py.

00066 
00067     def setLocale(self, locale):
00068         """Allow an application to set the locale for errors and warnings.
00069 
00070         SAX parsers are not required to provide localization for errors
00071         and warnings; if they cannot support the requested locale,
00072         however, they must throw a SAX exception. Applications may
00073         request a locale change in the middle of a parse."""
00074         raise SAXNotSupportedException("Locale support not implemented")

def xml.sax.xmlreader.XMLReader.setProperty (   self,
  name,
  value 
) [inherited]

Reimplemented in xml.sax.saxutils.XMLFilterBase, and xml.sax.expatreader.ExpatParser.

Definition at line 87 of file xmlreader.py.

00087 
00088     def setProperty(self, name, value):
00089         "Sets the value of a SAX2 property."
00090         raise SAXNotRecognizedException("Property '%s' not recognized" % name)


Member Data Documentation

Definition at line 112 of file xmlreader.py.


The documentation for this class was generated from the following file: