Fred Drake | 014f0e3 | 2000-10-12 20:05:09 +0000 | [diff] [blame] | 1 | \section{\module{xml.sax.saxutils} --- |
| 2 | SAX Utilities} |
| 3 | |
| 4 | \declaremodule{standard}{xml.sax.saxutils} |
| 5 | \modulesynopsis{Convenience functions and classes for use with SAX.} |
| 6 | \sectionauthor{Martin v. L\"owis}{loewis@informatik.hu-berlin.de} |
| 7 | \moduleauthor{Lars Marius Garshol}{larsga@garshol.priv.no} |
| 8 | |
| 9 | \versionadded{2.0} |
| 10 | |
| 11 | |
| 12 | The module \module{xml.sax.saxutils} contains a number of classes and |
| 13 | functions that are commonly useful when creating SAX applications, |
| 14 | either in direct use, or as base classes. |
| 15 | |
| 16 | \begin{funcdesc}{escape}{data\optional{, entities}} |
| 17 | Escape \&, <, and > in a string of data. |
| 18 | |
| 19 | You can escape other strings of data by passing a dictionary as the |
| 20 | optional entities parameter. The keys and values must all be |
| 21 | strings; each key will be replaced with its corresponding value. |
| 22 | \end{funcdesc} |
| 23 | |
| 24 | \begin{classdesc}{XMLGenerator}{\optional{out\optional{, encoding}}} |
| 25 | This class implements the \class{ContentHandler} interface by |
| 26 | writing SAX events back into an XML document. In other words, using |
| 27 | an \class{XMLGenerator} as the content handler will reproduce the |
| 28 | original document being parsed. \var{out} should be a file-like |
| 29 | object which will default to \var{sys.stdout}. \var{encoding} is the |
| 30 | encoding of the output stream which defaults to \code{'iso-8859-1'}. |
| 31 | \end{classdesc} |
| 32 | |
| 33 | \begin{classdesc}{XMLFilterBase}{base} |
| 34 | This class is designed to sit between an \class{XMLReader} and the |
| 35 | client application's event handlers. By default, it does nothing |
| 36 | but pass requests up to the reader and events on to the handlers |
| 37 | unmodified, but subclasses can override specific methods to modify |
| 38 | the event stream or the configuration requests as they pass through. |
| 39 | \end{classdesc} |
| 40 | |
| 41 | \begin{funcdesc}{prepare_input_source}{source\optional{, base}} |
| 42 | This function takes an input source and an optional base URL and |
| 43 | returns a fully resolved \class{InputSource} object ready for |
| 44 | reading. The input source can be given as a string, a file-like |
| 45 | object, or an \class{InputSource} object; parsers will use this |
| 46 | function to implement the polymorphic \var{source} argument to their |
| 47 | \method{parse()} method. |
| 48 | \end{funcdesc} |