2004-10-12 22:39:57

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/

A simple state machine specialized for DOM chunking from SAX A state is "live" when it represents the successful completion of a path. This is generally a signal to the handler using this state machine to start creating the DOM fragment from the subset of SAX events until we transit to a non-live state

Register an event and effect ant state transitions found in the state table

1 if the curent state is considered live, else 0

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.

#Overridden LexicalHandler methods

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

#Overridden DocumentHandler methods

u'dummy'
None
0
-1
'http://www.w3.org/2000/xmlns/'
'http://www.w3.org/XML/1998/namespace'