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.
  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 dont' care about.
  Handler
A SAX handler class that maintains a stack of enclosing elements and manages namespace declarations.
Functions [hide private]
 
make_parser(*args, **kw)
Extend xml.sax.make_parser to configure the parser the way we need it:
source code
Variables [hide private]
  xml_file = sys.argv [1]
  xmls = open(xml_file).read()
  dt1 = time.time()
  dt2 = time.time()
  dom = xml.dom.minidom.parseString(xmls)
  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(xmls)
  ldt2 = time.time()
  ldh = xml.dom.pulldom.SAX2DOM()
  ldt3 = time.time()
  __package__ = 'pyxb.utils'
Function Details [hide private]

make_parser(*args, **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 arguments not documented here are passed to xml.sax.make_parser.

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)