Revision 4228
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/xml_func.py | ||
---|---|---|
83 | 83 |
merge_tagged(node) |
84 | 84 |
|
85 | 85 |
name = node.tagName |
86 |
children = list(xml_dom.NodeElemIter(node)) |
|
87 | 86 |
|
88 | 87 |
# Pass-through optimizations |
89 |
if is_func_name(name) and len(children) == 1: # single arg function |
|
90 |
func = name |
|
91 |
param_node = children[0] |
|
92 |
param = param_node.tagName |
|
93 |
value = param_node.firstChild |
|
94 |
|
|
95 |
is_agg_func = param.isdigit() or func == '_name' |
|
96 |
is_if_no_cond = func = '_if' # no if condition means False |
|
97 |
if is_agg_func or (is_if_no_cond and param == 'else'): |
|
98 |
xml_dom.replace(node, value) |
|
99 |
elif is_if_no_cond and param == 'then': xml_dom.remove(node) |
|
88 |
if is_func_name(name): |
|
89 |
children = list(xml_dom.NodeElemIter(node)) |
|
90 |
if len(children) == 1: # single arg function |
|
91 |
func = name |
|
92 |
param_node = children[0] |
|
93 |
param = param_node.tagName |
|
94 |
value = param_node.firstChild |
|
95 |
|
|
96 |
is_agg_func = param.isdigit() or func == '_name' |
|
97 |
is_if_no_cond = func = '_if' # no if condition means False |
|
98 |
if is_agg_func or (is_if_no_cond and param == 'else'): |
|
99 |
xml_dom.replace(node, value) |
|
100 |
elif is_if_no_cond and param == 'then': xml_dom.remove(node) |
|
100 | 101 |
|
101 | 102 |
def process(node, on_error=exc.reraise, is_rel_func=None, db=None): |
102 | 103 |
'''Evaluates the XML functions in an XML tree. |
Also available in: Unified diff
xml_func.py: simplify(): Only generate children list if node is a function