Project

General

Profile

« Previous | Next » 

Revision 135

map: Implemented DB input support for querying a single table

View differences:

xml_dom.py
19 19

  
20 20
def set_id(node, id_): node.setAttribute('id', id_)
21 21

  
22
def is_empty(node): return node.firstChild == None
23

  
22 24
class NodeElemIter:
23 25
    def __init__(self, node): self.child = node.firstChild
24 26
    
......
99 101
        self.iter_.next()
100 102
        return entry
101 103

  
104
def set_child(node, name, value):
105
    '''Note: does not remove any existing child of the same name'''
106
    child = node.ownerDocument.createElement(name)
107
    set_value(node.ownerDocument, child, value)
108
    node.appendChild(child)
109

  
102 110
def replace(old_node, new_node):
103 111
    old_node.parentNode.replaceChild(new_node, old_node) # note order reversed
104 112

  
105 113
def replace_with_text(doc, node, str_): replace(node, doc.createTextNode(str_))
106 114

  
107 115
def by_tag_name(node, name, last_only=False):
108
    # last_only optimization returns last (most recently inserted) matching node
116
    '''last_only optimization returns last matching node'''
109 117
    children = []
110 118
    for child in NodeElemReverseIter(node):
111 119
        if child.tagName == name:
......
117 125
    return xml.dom.minidom.getDOMImplementation().createDocument(None, root,
118 126
        None)
119 127

  
128
def writexml(writer, node): node.writexml(writer, addindent='    ', newl='\n')
129

  
120 130
# xml.dom.minidom modifications
121 131

  
122 132
def _write_data(writer, data): writer.write(escape(data))

Also available in: Unified diff