Back to index

python3.2  3.2.2
Namespaces | Functions | Variables
xml.sax Namespace Reference

Namespaces

namespace  _exceptions
namespace  expatreader
namespace  handler
namespace  saxutils
namespace  xmlreader

Functions

def parse
def parseString
def make_parser
def _create_parser

Variables

list default_parser_list = ["xml.sax.expatreader"]
int _false = 0
string _key = "python.xml.sax.parser"

Detailed Description

Simple API for XML (SAX) implementation for Python.

This module provides an implementation of the SAX 2 interface;
information about the Java version of the interface can be found at
http://www.megginson.com/SAX/.  The Python version of the interface is
documented at <...>.

This package contains the following modules:

handler -- Base classes and constants which define the SAX 2 API for
           the 'client-side' of SAX for Python.

saxutils -- Implementation of the convenience classes commonly used to
work with SAX.

xmlreader -- Base classes and constants which define the SAX 2 API for
 the parsers used with SAX for Python.

expatreader -- Driver that allows use of the Expat parser with SAX.

Function Documentation

def xml.sax._create_parser (   parser_name) [private]

Definition at line 95 of file __init__.py.

00095 
00096     def _create_parser(parser_name):
00097         from org.python.core import imp
00098         drv_module = imp.importName(parser_name, 0, globals())
00099         return drv_module.create_parser()
00100 
else:

Here is the call graph for this function:

Here is the caller graph for this function:

def xml.sax.make_parser (   parser_list = [])
Creates and returns a SAX parser.

Creates the first parser it is able to instantiate of the ones
given in the list created by doing parser_list +
default_parser_list.  The lists must contain the names of Python
modules containing both a SAX parser and a create_parser function.

Definition at line 68 of file __init__.py.

00068 
00069 def make_parser(parser_list = []):
00070     """Creates and returns a SAX parser.
00071 
00072     Creates the first parser it is able to instantiate of the ones
00073     given in the list created by doing parser_list +
00074     default_parser_list.  The lists must contain the names of Python
00075     modules containing both a SAX parser and a create_parser function."""
00076 
00077     for parser_name in parser_list + default_parser_list:
00078         try:
00079             return _create_parser(parser_name)
00080         except ImportError as e:
00081             import sys
00082             if parser_name in sys.modules:
00083                 # The parser module was found, but importing it
00084                 # failed unexpectedly, pass this exception through
00085                 raise
00086         except SAXReaderNotAvailable:
00087             # The parser module detected that it won't work properly,
00088             # so try the next one
00089             pass
00090 
00091     raise SAXReaderNotAvailable("No parsers found", None)
00092 
00093 # --- Internal utility methods used by make_parser

Here is the call graph for this function:

Here is the caller graph for this function:

def xml.sax.parse (   source,
  handler,
  errorHandler = ErrorHandler() 
)

Definition at line 29 of file __init__.py.

00029 
00030 def parse(source, handler, errorHandler=ErrorHandler()):
00031     parser = make_parser()
00032     parser.setContentHandler(handler)
00033     parser.setErrorHandler(errorHandler)
00034     parser.parse(source)

Here is the call graph for this function:

def xml.sax.parseString (   string,
  handler,
  errorHandler = ErrorHandler() 
)

Definition at line 35 of file __init__.py.

00035 
00036 def parseString(string, handler, errorHandler=ErrorHandler()):
00037     from io import BytesIO
00038 
00039     if errorHandler is None:
00040         errorHandler = ErrorHandler()
00041     parser = make_parser()
00042     parser.setContentHandler(handler)
00043     parser.setErrorHandler(errorHandler)
00044 
00045     inpsrc = InputSource()
00046     inpsrc.setByteStream(BytesIO(string))
00047     parser.parse(inpsrc)
00048 
00049 # this is the parser list used by the make_parser function if no
00050 # alternatives are given as parameters to the function

Here is the call graph for this function:


Variable Documentation

Definition at line 54 of file __init__.py.

string xml.sax._key = "python.xml.sax.parser"

Definition at line 63 of file __init__.py.

tuple xml.sax.default_parser_list = ["xml.sax.expatreader"]

Definition at line 51 of file __init__.py.