Project

General

Profile

« Previous | Next » 

Revision 1013

xpath.py: get(): Fixed bug where it would try to create a node named . or .. if . or .. didn't have matching attributes. Now it will just reuse the current or parent node, but create any needed attrs if create is True.

View differences:

lib/xpath.py
192 192
    elif is_self(elem): children = [root]
193 193
    elif is_parent(elem):
194 194
        parent = xml_dom.parent(root)
195
        if parent != None: children = [parent]
196
        else: return [] # don't try to create the document root's parent
195
        if parent == None: return [] # don't try to create doc root's parent
196
        root = parent
197
        children = [root]
197 198
    else:
198 199
        children = xml_dom.by_tag_name(root, elem.name,
199
        last_only and (elem.keys == [] or is_instance(elem)))
200
            last_only and (elem.keys == [] or is_instance(elem)))
200 201
    
201 202
    # Retrieve elem value
202 203
    value_ = elem.value
......
227 228
        if elem.is_attr:
228 229
            root.setAttribute(elem.name, '')
229 230
            node = root.getAttributeNode(elem.name)
231
        elif util.list_eq_is(children, [root]): node = root
230 232
        else: node = root.appendChild(doc.createElement(elem.name))
231 233
        if value_ != None: xml_dom.set_value(node, value_)
232 234
        nodes.append(node)

Also available in: Unified diff