Project

General

Profile

« Previous | Next » 

Revision 1676

bin/map: Added prefixes support for XML inputs

View differences:

map
226 226
            
227 227
            in_db.close()
228 228
        elif in_is_xml:
229
            if prefixes != []: prefix = './{'+(','.join(['.']+prefixes))+'}/'
230
                # also lookup with no prefix
231
            else: prefix = ''
232
            
233
            rows = xpath.get(doc0_root, in_root, limit=end)
234
            if rows == []: raise SystemExit('Map error: Root "'+in_root
235
                +'" not found in input')
229 236
            def get_value(in_, row):
230
                nodes = xpath.get(row, in_, allow_rooted=False)
237
                nodes = xpath.get(row, prefix+in_, allow_rooted=False)
231 238
                if nodes != []: return xml_dom.value(nodes[0])
232 239
                else: return None
233
            rows = xpath.get(doc0_root, in_root, limit=end)
234
            if rows == []: raise SystemExit('Map error: Root "'+in_root
235
                +'" not found in input')
236 240
            row_ct = map_rows(get_value, rows)
237 241
        else: # input is CSV
238 242
            map_ = dict(mappings)

Also available in: Unified diff