Revision 3335
Added by Aaron Marcuse-Kubitza over 12 years ago
xml_func.py | ||
---|---|---|
50 | 50 |
if name != None and last[0] != name: return None # input is empty |
51 | 51 |
return last[1] |
52 | 52 |
|
53 |
def merge_tagged(root): |
|
54 |
'''Merges siblings in root that are marked as mergeable. |
|
55 |
Used to recombine pieces of nodes that were split apart in the mappings. |
|
56 |
''' |
|
57 |
for name in set((c.tagName for c in xpath.get(root, '*[@merge=1]'))): |
|
58 |
xml_dom.merge_by_name(root, name) |
|
59 |
|
|
60 |
# Recurse |
|
61 |
for child in xml_dom.NodeElemIter(root): merge_tagged(child) |
|
62 |
|
|
53 | 63 |
funcs = {} |
54 | 64 |
|
55 | 65 |
structural_funcs = set() |
... | ... | |
83 | 93 |
|
84 | 94 |
for child in xml_dom.NodeElemIter(node): |
85 | 95 |
process(child, on_error, rel_funcs, db) |
96 |
merge_tagged(node) |
|
86 | 97 |
|
87 |
# Recombine pieces of nodes that were split apart in the mappings |
|
88 |
# Do after iterating over the children to avoid invalidating the iterator |
|
89 |
for name in set((c.tagName for c in xpath.get(node, '*[@merge=1]'))): |
|
90 |
xml_dom.merge_by_name(node, name) |
|
91 |
|
|
92 | 98 |
name = node.tagName |
93 | 99 |
if not is_func_name(name): return node # not any kind of function |
94 | 100 |
|
Also available in: Unified diff
xml_func.py: process(): Merge mergeable siblings recursively so that newly-mergeable children are also merged