4Suite API Documentation

Module amara.saxtools

Classes:
Functions:
Globals:

Classes

class namespace_mixin

Methods

__init__(self)
endPrefixMapping(self, prefix)
name_to_qname(self, name)
startPrefixMapping(self, prefix, uri)
class normalize_text_filter(xml.sax.saxutils.XMLFilterBase, amara.pyxml_standins.LexicalHandler)
SAX filter to ensure that contiguous white space nodes are delivered merged into a single node

Methods

__init__(self, *args)
Overrides: __init__ from class XMLFilterBase
characters(self, text)
Overrides: characters from class XMLFilterBase
comment(self, body)
Overrides: comment from class LexicalHandler
endDocument(self)
Overrides: endDocument from class XMLFilterBase
endElement(self, name)
Overrides: endElement from class XMLFilterBase
endElementNS(self, name, qname)
Overrides: endElementNS from class XMLFilterBase
ignorableWhitespace(self, ws)
Overrides: ignorableWhitespace from class XMLFilterBase
parse(self, source)
# Enhancement suggested by James Kew: # Override XMLFilterBase.parse to connect the LexicalHandler # Can only do this by setting the relevant property # May throw SAXNotSupportedException
Overrides: parse from class XMLFilterBase
processingInstruction(self, target, body)
Overrides: processingInstruction from class XMLFilterBase
resolveEntity(self, publicId, systemId)
#Must be overridden because of a bug in Python 2.0 through 2.4 #And even still in PyXML 0.8.4. Missing "return"
Overrides: resolveEntity from class XMLFilterBase
startDocument(self)
Overrides: startDocument from class XMLFilterBase
startElement(self, name, attrs)
Overrides: startElement from class XMLFilterBase
startElementNS(self, name, qname, attrs)
Overrides: startElementNS from class XMLFilterBase

Methods inherited from class xml.sax.saxutils.XMLFilterBase

endPrefixMapping, error, fatalError, getFeature, getParent, getProperty, notationDecl, setDocumentLocator, setFeature, setLocale, setParent, setProperty, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning

Methods inherited from class xml.sax.xmlreader.XMLReader

getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, setContentHandler, setDTDHandler, setEntityResolver, setErrorHandler

Methods inherited from class amara.pyxml_standins.LexicalHandler

class sax2dom_chunker(xml.sax.handler.ContentHandler)
Note: Ignores nodes prior to the document element, such as PIs and text nodes. Collapses CDATA sections into plain text Only designed to work if you set the feature sax.handler.feature_namespaces to 1 on the parser you use.
xpatterns - list of XPatterns.  Only portions of the
    tree within these patterns will be instantiated as DOM (as
    chunks fed to chunk_consumer in sequence)
    If None (the default, a DOM node will be created representing
    the entire tree.

nss - a dictionary of prefix -> namespace name mappings used to
    interpret XPatterns

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, xpatterns=None, nss=None, chunk_consumer=None, domimpl=<DOMImplementation at 0xb7dee460>, owner_doc=None)
Overrides: __init__ from class ContentHandler
characters(self, chars)
Overrides: characters from class ContentHandler
comment(self, text)
#Overridden LexicalHandler methods
endDocument(self)
Overrides: endDocument from class ContentHandler
endElementNS(self, (ns, local), 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
startDocument(self)
#Overridden ContentHandler methods
Overrides: startDocument from class ContentHandler
startElementNS(self, (ns, local), qname, attribs)
Overrides: startElementNS from class ContentHandler

Methods inherited from class xml.sax.handler.ContentHandler

endElement, endPrefixMapping, ignorableWhitespace, setDocumentLocator, skippedEntity, startElement, startPrefixMapping
class tenorsax(namespace_mixin, xml.sax.handler.ContentHandler)

Methods

__init__(self, consumer)
Overrides: __init__ from class namespace_mixin
characters(self, text)
Overrides: characters from class ContentHandler
check_for_delegate(...)
staticmethod(function) -> method
Convert a function to be a static method.

A static method does not receive an implicit first argument.
To declare a static method, use this idiom:

     class C:
         def f(arg1, arg2, ...): ...
         f = staticmethod(f)

It can be called either on the class (e.g. C.f()) or on an instance
(e.g. C().f()).  The instance is ignored except for its class.

Static methods in Python are similar to those found in Java or C++.
For a more advanced concept, see the classmethod builtin.
endElementNS(self, name, qname)
Overrides: endElementNS from class ContentHandler
event_loop_body(...)
staticmethod(function) -> method
Convert a function to be a static method.

A static method does not receive an implicit first argument.
To declare a static method, use this idiom:

     class C:
         def f(arg1, arg2, ...): ...
         f = staticmethod(f)

It can be called either on the class (e.g. C.f()) or on an instance
(e.g. C().f()).  The instance is ignored except for its class.

Static methods in Python are similar to those found in Java or C++.
For a more advanced concept, see the classmethod builtin.
execute_delegate(...)
staticmethod(function) -> method
Convert a function to be a static method.

A static method does not receive an implicit first argument.
To declare a static method, use this idiom:

     class C:
         def f(arg1, arg2, ...): ...
         f = staticmethod(f)

It can be called either on the class (e.g. C.f()) or on an instance
(e.g. C().f()).  The instance is ignored except for its class.

Static methods in Python are similar to those found in Java or C++.
For a more advanced concept, see the classmethod builtin.
startElementNS(self, name, qname, attributes)
Overrides: startElementNS from class ContentHandler

Methods inherited from class namespace_mixin

Methods inherited from class xml.sax.handler.ContentHandler

endDocument, endElement, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement
class xpattern_state_machine
A simple state machine that interprets XPatterns A state is "live" when it represents the successful completion of an XPattern.

Methods

__init__(self, repr_xp, xp, nss)
event(self, is_start, ns, local)
Register an event and effect any state transitions found in the state table
status(self)
1 if currently within an XPattern, 0 if not Calling code might also want to just check self.current_xpatterns directly

Members

PARSER = <Ft.Xml.Xslt.XPatternParser object at 0xb7748bcc>
class xpattern_state_manager
And aggregation of multiple state machines, one for each registered pattern

Methods

__init__(self, xpatterns, nss)
event(self, is_start, ns, local)
status(self)
1 if currently within an XPattern, 0 if not Calling code might also want to just check self.current_xpatterns directly

Members

PARSER = <Ft.Xml.Xslt.XPatternParser object at 0xb77f862c>

Functions

sniff_namespace(source)

Globals

ANY = '?'
CHARACTER_DATA = 10
COMMENT = 11
DUMMY_DOCELEM = u'dummy'
END_DOCUMENT = 2
END_ELEMENT = 4
EXPLICIT = True
IMPLICIT = False
NULL_NAMESPACE = None
NULL_PREFIX = None
PI = 12
START_DOCUMENT = 1
START_ELEMENT = 3
START_STATE = 0
TOP = -1
XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'
XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'
all_features = ['http://xml.org/sax/features/namespaces', 'http://xml.org/sax/features/namespace-prefixes', 'http://xml.org/sax/features/string-interning', 'http://xml.org/sax/features/validation', 'http://xml.org/sax/features/external-general-entities', 'http://xml.org/sax/features/external-parameter-entities']
all_properties = ['http://xml.org/sax/properties/lexical-handler', 'http://xml.org/sax/properties/dom-node', 'http://xml.org/sax/properties/declaration-handler', 'http://xml.org/sax/properties/xml-string', 'http://www.python.org/sax/properties/encoding', 'http://www.python.org/sax/properties/interning-dict']
feature_external_ges = 'http://xml.org/sax/features/external-general-entities'
feature_external_pes = 'http://xml.org/sax/features/external-parameter-entities'
feature_namespace_prefixes = 'http://xml.org/sax/features/namespace-prefixes'
feature_namespaces = 'http://xml.org/sax/features/namespaces'
feature_string_interning = 'http://xml.org/sax/features/string-interning'
feature_validation = 'http://xml.org/sax/features/validation'
property_declaration_handler = 'http://xml.org/sax/properties/declaration-handler'
property_dom_node = 'http://xml.org/sax/properties/dom-node'
property_encoding = 'http://www.python.org/sax/properties/encoding'
property_interning_dict = 'http://www.python.org/sax/properties/interning-dict'
property_lexical_handler = 'http://xml.org/sax/properties/lexical-handler'
property_xml_string = 'http://xml.org/sax/properties/xml-string'