Revision 1006
Added by Aaron Marcuse-Kubitza almost 13 years ago
map | ||
---|---|---|
108 | 108 |
|
109 | 109 |
if in_is_xml: |
110 | 110 |
doc0 = minidom.parse(sys.stdin) |
111 |
if out_label == None: out_label = doc0.documentElement.tagName |
|
111 |
doc0_root = doc0.documentElement |
|
112 |
if out_label == None: out_label = doc0_root.tagName |
|
112 | 113 |
|
113 | 114 |
def process_rows(process_row, rows): |
114 | 115 |
'''Processes input rows |
... | ... | |
139 | 140 |
return process_rows(process_row, rows) |
140 | 141 |
|
141 | 142 |
if map_path == None: |
142 |
iter_ = xml_dom.NodeElemIter(doc0.documentElement)
|
|
143 |
iter_ = xml_dom.NodeElemIter(doc0_root)
|
|
143 | 144 |
util.skip(iter_, xml_dom.is_text) # skip metadata |
144 | 145 |
row_ct = process_rows(lambda row, i: root.appendChild(row), iter_) |
145 | 146 |
elif in_is_db: |
... | ... | |
170 | 171 |
nodes = xpath.get(row, in_, allow_rooted=False) |
171 | 172 |
if nodes != []: return xml_dom.value(nodes[0]) |
172 | 173 |
else: return None |
173 |
rows = xpath.get(doc0.documentElement, in_root, limit=end)
|
|
174 |
rows = xpath.get(doc0_root, in_root, limit=end)
|
|
174 | 175 |
if rows == []: raise SystemExit('Map error: Root "'+in_root |
175 | 176 |
+'" not found in input') |
176 | 177 |
row_ct = map_rows(get_value, rows) |
Also available in: Unified diff
bin/map: Use var doc0_root for quick reference to doc0's root