- class element_skeleton_rule(xpattern_rule_base)
-
An Amara bindery rule. Bindery rules allow developers to customize how
XML documents are translated to Python objects.
This rule is pattern based. Elements that match the pattern and their
children will be bound as elements only, with no child character data
preserved. Use this when you only care about the element structure and
want to save resources by not loading the character data.
The default pattern is '*', meaning all elements.
Methods
- __init__(self, xpatterns=None)
- Overrides: __init__ from class xpattern_rule_base
- apply(self, binder)
Methods inherited from class object
__delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__
Members
- event_type = 3
- priority = 20
Members inherited from class object
__class__
- class omit_element_rule(xpattern_rule_base)
-
An Amara bindery rule. Bindery rules allow developers to customize how
XML documents are translated to Python objects.
This rule is pattern based. Elements that match the pattern will
be ignored and not bound to any object at all, saving memory.
There is no default pattern. You must specify one.
Methods
- apply(self, binder)
Methods inherited from class object
__delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__
Members
- event_type = 3
- priority = -40
Members inherited from class object
__class__
- class saxbind_chunker(amara.bindery.binder, amara.saxtools.sax2dom_chunker)
-
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 XSLT Patterns. 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.
prefixes - a dictionary of prefix -> namespace name mappings used to
interpret XPatterns
chunk_consumer - a callable object taking an XML root object. It will be
invoked as each chunk is prepared.
Methods
- __init__(self, xpatterns=None, prefixes=None, chunk_consumer=None, rules=None, event_hook=None)
- Overrides: __init__ from class binder
- characters(self, chars)
- Overrides: characters from class binder
- endDocument(self)
- Overrides: endDocument from class binder
- endElementNS(self, (ns, local), qname)
- Overrides: endElementNS from class binder
- startDocument(self)
-
#Overridden ContentHandler methods
- Overrides: startDocument from class binder
- startElementNS(self, (ns, local), qname, attribs)
- Overrides: startElementNS from class binder
Methods inherited from class object
__delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__
Methods inherited from class xml.sax.handler.ContentHandler
endElement, endPrefixMapping, ignorableWhitespace, setDocumentLocator, skippedEntity, startElement
Members inherited from class object
__class__
- class simple_string_element_rule(xpattern_rule_base)
-
An Amara bindery rule. Bindery rules allow developers to customize how
XML documents are translated to Python objects.
This rule is pattern based. Elements that match the pattern will
be bound as simple Python unicode objects, rather than full
element objects, saving memory.
There is no default pattern. You must specify one.
Methods
- apply(self, binder)
Methods inherited from class object
__delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__
Members
- event_type = 3
- priority = -30
Members inherited from class object
__class__
- class type_inference(xpattern_rule_base)
-
An Amara bindery rule. Bindery rules allow developers to customize how
XML documents are translated to Python objects.
This rule is pattern based. Children of elements that match
the pattern are checked to see if they could be a more specialized
type, such as int, float or date
The default pattern is '*', meaning all elements.
Methods
- __init__(self, xpatterns=None)
- Overrides: __init__ from class xpattern_rule_base
- apply(self, binder)
Methods inherited from class object
__delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__
Members
- event_type = 3
- priority = 30
Members inherited from class object
__class__
- class ws_strip_element_rule(xpattern_rule_base, amara.bindery.default_element_rule)
-
An Amara bindery rule. Bindery rules allow developers to customize how
XML documents are translated to Python objects.
This rule is pattern based. Elements that match the pattern and
descendants will have text children stripped if they are pure whitespace.
In other words
<a> <b/> <c/> </a>
will end up with the same binding as
<a> <b/> <c/> </a>
but not
<a> <b/> x <c/> </a> <!-- ' x ' is not pure whitespace -->
Stripping whitespace saves memory and can simplify resulting bindings,
but be sure the whitespace doesn't have a significant meeaning in the
document.
The default pattern is '*', meaning all elements.
Methods
- __init__(self, xpatterns=None)
- Overrides: __init__ from class xpattern_rule_base
- apply(self, binder)
- Overrides: apply from class default_element_rule
Methods inherited from class object
__delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__
Members
- event_type = 3
- priority = -20
Members inherited from class object
__class__
- class xpattern_rule_base(object)
-
Methods
- __init__(self, xpatterns)
- Overrides: __init__ from class object
- add_rule_hook(self, binder)
- dom_match(self, node, binder)
- match(self, binder)
Methods inherited from class object
__delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__
Members
- __dict__ = <attribute '__dict__' of 'xpattern_rule_base' objects>
- __weakref__ = <attribute '__weakref__' of 'xpattern_rule_base' objects>
Members inherited from class object
__class__