Project

General

Profile

« Previous | Next » 

Revision 3333

xml_func.py: process(): Recombining pieces of nodes that were split apart in the mappings: Only combine nodes that are explicitly marked as mergeable, to avoid unwanted merges. Refactored to use new xml_dom.merge_by_name().

View differences:

lib/xml_func.py
77 77
          This is used in column-based mode to remove XML-only functions.
78 78
        * If != None: Relational functions are evaluated directly. This is used
79 79
          in row-based mode to combine relational and XML functions.
80
    @return The new node
81 80
    '''
82 81
    has_rel_funcs = rel_funcs != None
83 82
    assert db == None or has_rel_funcs # rel_funcs required if db set
84 83
    
85
    changed = []
86
    for child in list(xml_dom.NodeElemIter(node)):
87
        new = process(child, on_error, rel_funcs, db)
88
        if new != None and new is not child and xml_dom.is_elem(new):
89
            changed.append(new)
84
    for child in xml_dom.NodeElemIter(node):
85
        process(child, on_error, rel_funcs, db)
86
    
87
    # Recombine pieces of nodes that were split apart in the mappings
90 88
    # Do after iterating over the children to avoid invalidating the iterator
91
    for child in changed: xml_dom.merge_same_name(child)
89
    for name in set((c.tagName for c in xpath.get(node, '*[@merge=1]'))):
90
        xml_dom.merge_by_name(node, name)
92 91
    
93 92
    name = node.tagName
94 93
    if not is_func_name(name): return node # not any kind of function
......
124 123
            on_error(e)
125 124
            return # in case on_error() returns
126 125
    
127
    return xml_dom.replace_with_text(node, value)
126
    xml_dom.replace_with_text(node, value)
128 127

  
129 128
##### XML functions
130 129

  

Also available in: Unified diff