4Suite™ API Documentation

# ► Module Ft.Xml.ThirdParty.Xvif.sax2dom_chunker

sax2dom_chunker.py version 1.1

    A SAX handler that takes a set of element paths and
    creates a series of DOM chunks matching the element paths
    for individual processing.  Designed for Python 2.2. or greater.

    Copyright 2004 Fourthought Inc, USA.
    This work is licensed under Creative Commons Attribution 1.0
    For details: http://creativecommons.org/licenses/by/1.0/

Classes: sax2dom_chunker |  |  |  | Globals: DUMMY_DOCELEM, EMPTY_NAMESPACE, START_STATE, TOP, XMLNS_NAMESPACE, XML_NAMESPACE

## Classes

class sax2dom_chunker(xml.sax.handler.ContentHandler)
  Note: ignores nodes prior to the document element, such as PIs and text nodes This filter is only designed to work if you set features sax.handler.feature_namespaces and sax.handler.feature_namespace_prefixes to 1 on the parser you use. It will not work on drivers that do not support these features. The default drv_expat works fine in this case, but of course has but very limited DTD processing. It also collapses CDATA sections into plain text

      trim_to_paths - a list of lists of tuples.  Each tuple is of
          the form (namespace, local-name), providing one segment
          in a path of contained elements
          [
            [ (None, u'monty'), (None, u'python') ],
            [ (None, u'monty'), (None, u'spam'), ('urn:dummy', u'eggs') ]
          ]
          If None (the default, a DOM node will be created representing
          the entire tree.

      chunk_consumer - a callable object taking a DOM node.  It will be
          invoked as each DOM chunk is prepared.

      domimpl - DOM implemention to build, e.g. mindom (the default)
          or cDomlette or pxdom (if you have the right third-party
          packages installed).

      owner_doc - for advanced uses, if you want to use an existing
          DOM document object as the owner of all created nodes.

  ### Methods

  __init__(self, trim_to_paths=None, chunk_consumer=None, domimpl=<xml.dom.minidom.DOMImplementation instance at 0xb75f2f0c>, owner_doc=None)
    Overrides: __init__ from class ContentHandler
  characters(self, chars)
    Overrides: characters from class ContentHandler
  comment(self, text)
    #Overridden LexicalHandler methods
  endElementNS(self, name, qname)
    Overrides: endElementNS from class ContentHandler
  get_root_node(self)
    Only useful if the user does not register trim paths If so, then after SAX processing the user can call this method to retrieve resulting DOm representing the entire document
  processingInstruction(self, target, data)
    Overrides: processingInstruction from class ContentHandler
  startElementNS(self, name, qname, attribs)
    #Overridden DocumentHandler methods
    Overrides: startElementNS from class ContentHandler

  ### Methods inherited from class xml.sax.handler.ContentHandler

  endDocument, endElement, endPrefixMapping, ignorableWhitespace, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping

## Globals

DUMMY_DOCELEM = u'dummy'
EMPTY_NAMESPACE = None
START_STATE = 0
TOP = -1
XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'
XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'