Package pyxb :: Package utils :: Module saxutils |
[hide private]
[frames] | no frames]

# Module saxutils

source code

This module contains support for processing XML using a SAX parser.

In particular, it provides a base content handler class that maintains namespace context and element state in a stack; and a base element state class which records the location of the element in the stream. These classes are extended for specific parsing needs (e.g., pyxb.binding.saxer).

Classes | [hide private]
TracingSAXHandler A SAX handler class which prints each method invocation.
_NoopSAXHandler A SAX handler class which doesn't do anything.
SAXInformationItem Class used to capture an item discovered in the body of an element.
SAXElementState State corresponding to processing a given element with the SAX model.
BaseSAXHandler A SAX handler class that maintains a stack of enclosing elements and manages namespace declarations.
_EntityResolver Dummy used to prevent the SAX parser from crashing when it sees processing instructions that we don't care about.
Handler A SAX handler class that maintains a stack of enclosing elements and manages namespace declarations.

Functions | [hide private]
SetCreateParserModules(create_parser_modules) Provide list of modules to be used when creating parsers. | source code
make_parser(**kw) Extend `xml.sax.make_parser` to configure the parser the way we need it: | source code

Variables | [hide private]
| _log = `logging.getLogger(__name__)`
| _CreateParserModules = ``[``]``
| xml_file = `sys.argv [1]`
| xmld = `open(xml_file, 'rb').read()`
| dt1 = `time.time()`
| dt2 = `time.time()`
| dom = `xml.dom.minidom.parse(io.BytesIO(xmld))`
| dt3 = `time.time()`
| snt1 = `time.time()`
| snt2 = `time.time()`
| snt3 = `time.time()`
| sbt1 = `time.time()`
| saxer = `make_parser(content_handler= BaseSAXHandler())`
| sbt2 = `time.time()`
| sbt3 = `time.time()`
| pdt1 = `time.time()`
| sdomer = `make_parser(content_handler_constructor= saxdom._DOMS`...``
| h = `sdomer.getContentHandler()`
| pdt2 = `time.time()`
| pdt3 = `time.time()`
| lst1 = `time.time()`
| lst2 = `time.time()`
| lsh = `Handler()`
| lst3 = `time.time()`
| ldt1 = `time.time()`
| tree = `lxml.etree.fromstring(xmld)`
| ldt2 = `time.time()`
| ldh = `xml.dom.pulldom.SAX2DOM()`
| ldt3 = `time.time()`
| __package__ = ``'``pyxb.utils``'``

Function Details | [hide private]

### SetCreateParserModules(create_parser_modules) | source code
Provide list of modules to be used when creating parsers. `xml.sax.make_parser()` takes as a parameter an optional list of modules which allow customization of the parser to be used. Certain parsers have better support for Unicode than others. As an example, providing `["drv_libxml2"]` causes the libxml2 parser to be used. The default behavior if this function is not called, or if it is called with an empty list or `None`, is to provide no specific modules, which will result in the system default parser (probably expat). Parameters: `create_parser_modules` - an iterable list of names of modules that provide a `create_parser` function. Pass `None` to reset to the system default.

### make_parser(**kw) | source code
Extend `xml.sax.make_parser` to configure the parser the way we need it: `feature_namespaces` is set to `True` so we process xmlns directives properly `feature_namespace_prefixes` is set to `False` so we don't get prefixes encoded into our names (probably redundant with the above but still...) All keywords not documented here (and `fallback_namespace`, which is) are passed to the `content_handler_constructor` if that must be invoked. Parameters: `content_handler` (`xml.sax.handler.ContentHandler`) - The content handler instance for the parser to use. If not provided, an instance of `content_handler_constructor` is created and used. `content_handler_constructor` - A callable which produces an appropriate instance of (a subclass of) BaseSAXHandler. The default is BaseSAXHandler. `fallback_namespace` (pyxb.namespace.Namespace) - The namespace to use for lookups of unqualified names in absent namespaces; see pyxb.namespace.ExpandedName. This keyword is not used by this function, but is passed to the `content_handler_constructor`.

Variables Details | [hide private]

  ### sdomer Value:
      make_parser(content_handler_constructor= saxdom._DOMSAXHandler)