Project

General

Profile

« Previous | Next » 

Revision 167

map: Use row's index instead of pkey as ID in XML output

View differences:

scripts/test/accepted_output/SALVIAS_db.organisms.VegX.xml
1 1
<?xml version="1.0" ?>
2 2
<VegX>
3 3
    <individualOrganismObservations>
4
        <individualOrganismObservation id="1">
4
        <individualOrganismObservation id="0">
5 5
            <individualOrganismID>0</individualOrganismID>
6 6
            <plotObservationID>0</plotObservationID>
7 7
            <simpleUserdefined>
......
21 21
                <value>1</value>
22 22
            </simpleUserdefined>
23 23
        </individualOrganismObservation>
24
        <individualOrganismObservation id="2">
24
        <individualOrganismObservation id="1">
25 25
            <individualOrganismID>1</individualOrganismID>
26 26
            <plotObservationID>1</plotObservationID>
27 27
            <simpleUserdefined>
scripts/test/accepted_output/SALVIAS_db.organisms.VegBank.xml
1 1
<?xml version="1.0" ?>
2 2
<VegBank>
3
    <taxonObservation id="1">
3
    <taxonObservation id="0">
4 4
        <observation_ID>
5 5
            <observation>
6 6
                <plot_ID>
......
260 260
            </party_ID>
261 261
        </taxonInterpretation>
262 262
    </taxonObservation>
263
    <taxonObservation id="2">
263
    <taxonObservation id="1">
264 264
        <observation_ID>
265 265
            <observation>
266 266
                <plot_ID>
scripts/map
90 90
            
91 91
            in_db = sql.connect(in_db_config)
92 92
            in_pkeys = {}
93
            for row in sql.rows(db_xml.get(in_db, in_root_xml, in_pkeys,
94
                limit)):
95
                row_id, = row
96
                row_id = str(row_id)
93
            for row_idx, row in enumerate(sql.rows(db_xml.get(in_db,
94
                in_root_xml, in_pkeys, limit))):
95
                row_id = str(row_idx)
96
                pkey, = row
97 97
                for in_, out in mappings:
98 98
                    value = metadata_value(in_)
99 99
                    if value == None:
100 100
                        in_ = in_.cloneNode(True) # don't modify orig value!
101
                        xml_dom.set_id(xpath.get(in_, in_root), row_id)
101
                        xml_dom.set_id(xpath.get(in_, in_root), pkey)
102 102
                        value = sql.value_or_none(db_xml.get(in_db, in_,
103 103
                            in_pkeys))
104 104
                    if value != None:

Also available in: Unified diff