| Home | Trees | Index | Help |
|
|---|
| Package bridge :: Package filter |
|
| Submodules | |
|---|---|
| Function Summary | |
|---|---|
yields every direct bridge.Element child of 'element' | |
Returns the first child named 'child_name' with the namespace 'child_ns' | |
Returns the list of children named 'child_name' with the namespace 'child_ns' | |
Looks for an element having the provided 'id' into the children recursively. | |
Perfoms a lookup of an element matching the path provided This path looks like an XPath query but that's where the comparison should stop. | |
next_token(path)
| |
Will recursuvely go through all the elements of a fragment and remove duplicate XML namespace declaration | |
Will recursuvely go through all the elements of a fragment and remove duplicate XML namespace declaration | |
tokenize_path(path)
| |
| Function Details |
|---|
element_children(element)yields every direct bridge.Element child of 'element' |
fetch_child(element, child_name, child_ns)Returns the first child named 'child_name' with the namespace 'child_ns' Use it like this: e = Element.load('<root><id /></root>') child = e.filtrate(fetch_child, child_name='id', child_ns=None) Keyword arguments: element -- parent element to go through child_name -- name of the element to lookup child_ns -- namespace of the element to lookup |
fetch_children(element, child_name, child_ns, recursive=False)Returns the list of children named 'child_name' with the namespace 'child_ns' Use it like this: e = Element.load('<root><node /></node /></root>') children = e.filtrate(fetch_children, child_name='node', child_ns=None) Keyword arguments: element -- parent element to go through child_name -- name of the element to lookup child_ns -- namespace of the element to lookup |
find_by_id(element, id)Looks for an element having the provided 'id' into the children recursively. Returns the found element or None. |
lookup(element, path)Perfoms a lookup of an element matching the path provided This path looks like an XPath query but that's where the comparison should stop. This is not an XPath engine.>>> from bridge import Element as E >>> from bridge.filter import lookup >>> e = E.load('<a:o xmlns:a="ui"><b h="gr"><c/></b></a:o>') >>> e.filtrate(lookup, path=u'/{ui}o/b[@h="gr"]/c') <c element at 0xb7c0c30cL /> >>> e.filtrate(lookup, path=u'{ui}o/b[@h="gr"]/c') <c element at 0xb7c0c30cL /> >>> e.filtrate(lookup, path=u'./{ui}o/b[@h="gr"]/c') <c element at 0xb7c0c30cL /> If the ``path`` starts with a '/' the matching will be applied from the root element otherwise from the current element (like when it starts with './'). If you need to provide a namespace it must be within {} right before the local name. Attribute matching is extremely simple and you can only match one attribute per branch. This ultimately returns the matching element or None. |
remove_duplicate_namespaces_declaration(element, visited_ns=None)Will recursuvely go through all the elements of a fragment and remove duplicate XML namespace declaration Keyword arguments: element -- root element to start from visited_ns -- list of already visited namespace |
remove_useless_namespaces_decalaration(element)Will recursuvely go through all the elements of a fragment and remove duplicate XML namespace declaration Keyword arguments: element -- root element to start from |
| Home | Trees | Index | Help |
|
|---|
| Generated by Epydoc 2.1 on Tue May 22 18:09:00 2007 | http://epydoc.sf.net |