Project

General

Profile

« Previous | Next » 

Revision 85

Changed VegBank mappings to use XML functions (not implemented yet) to calculate averages and ranges

View differences:

scripts/lib/xpath.py
41 41
    
42 42
    def _path():
43 43
        tree = []
44
        trailing_slash = False
45 44
        while True:
46 45
            # Split path
47 46
            if parser.str_('{'):
......
58 57
            
59 58
            # Attrs
60 59
            if parser.str_('['):
61
                elem.attrs = []
62 60
                while True:
63
                    path = _path()
64
                    if parser.str_('='):
65
                        set_value(path, parser.re(r'[\w.|]*'))
66
                    elem.attrs.append(path)
61
                    elem.attrs.append(_path())
67 62
                    if not parser.str_(','): break
68 63
                parser.str_(']', required=True)
69 64
            
......
80 75
            
81 76
            if not parser.str_('/'): break
82 77
        
78
        if parser.str_('='): set_value(tree, parser.re(r'[\w.|]*'))
79
        
83 80
        # Expand * abbrs
84 81
        for i in reversed(xrange(len(tree))):
85 82
            elem = tree[i]
......
185 182
        parent = node
186 183
    return parent
187 184

  
188
def put_obj(doc, xpath, id_, has_types, value):
185
def put_obj(doc, xpath, id_, has_types, value=None):
189 186
    xpath = copy.deepcopy(xpath) # don't modify input!
190 187
    set_id(xpath, id_, has_types)
191
    set_value(xpath, value)
188
    if value != None: set_value(xpath, value)
192 189
    get(doc, xpath, True)
mappings/VegX-VegBank.organisms.csv
60 60
"/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/geospatial/DecimalLongitude","/*_ID/observation/*_ID/plot/realLongitude"
61 61
"/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/geospatial/FootprintWKT","/*_ID/observation/*_ID/plot/dsgpoly"
62 62
"/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/geospatial/maximumDepthInMeters","/*_ID/observation/waterDepth/max"
63
"/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/geospatial/maximumElevationInMeters","/*_ID/observation/*_ID/plot/{elevation/max,elevationRange/to}"
63
"/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/geospatial/maximumElevationInMeters","/*_ID/observation/*_ID/plot/{elevation/_avg/max,elevationRange/_range/to}"
64 64
"/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/geospatial/minimumDepthInMeters","/*_ID/observation/waterDepth/min"
65
"/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/geospatial/minimumElevationInMeters","/*_ID/observation/*_ID/plot/{elevation/min,elevationRange/from}"
65
"/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/geospatial/minimumElevationInMeters","/*_ID/observation/*_ID/plot/{elevation/_avg/min,elevationRange/_range/from}"
66 66
"/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/geospatial/verbatimElevation","/*_ID/observation/*_ID/plot/elevation"
67 67
"/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/plotUniqueIdentifier","/*_ID/observation/*_ID/plot/authorPlotCode"
68 68
"/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/plotUniqueIdentifier","/*_ID/observation/{*_ID/plot/authorPlotCode,authorObsCode}"
mappings/joins/NYBG-VegBank.organisms.csv
29 29
Latitude,/*_ID/observation/*_ID/plot/realLatitude
30 30
CoordinatePrecision,/*_ID/observation/*_ID/plot/locationAccuracy
31 31
BoundingBox,/*_ID/observation/*_ID/plot/dsgpoly
32
MinimumElevation,"/*_ID/observation/*_ID/plot/{elevation/min,elevationRange/from}"
33
MaximumElevation,"/*_ID/observation/*_ID/plot/{elevation/max,elevationRange/to}"
32
MinimumElevation,"/*_ID/observation/*_ID/plot/{elevation/_avg/min,elevationRange/_range/from}"
33
MaximumElevation,"/*_ID/observation/*_ID/plot/{elevation/_avg/max,elevationRange/_range/to}"
34 34
MinimumDepth,/*_ID/observation/waterDepth/min
35 35
MaximumDepth,/*_ID/observation/waterDepth/max
36 36
Sex,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[PLANTCONCEPT_ID=]/definedValue[@fkey=tableRecord_ID,userDefined[tableName=taxonInterpretation,userDefinedName=sex]]/definedValue"
mappings/joins/SALVIAS-VegBank.plots.csv
9 9
lat_decimal,/*_ID/plot/realLatitude
10 10
long_decimal,/*_ID/plot/realLongitude
11 11
elev_m,/*_ID/plot/elevation
12
elev_max_m,"/*_ID/plot/{elevation/max,elevationRange/to}"
13
elev_min_m,"/*_ID/plot/{elevation/min,elevationRange/from}"
12
elev_max_m,"/*_ID/plot/{elevation/_avg/max,elevationRange/_range/to}"
13
elev_min_m,"/*_ID/plot/{elevation/_avg/min,elevationRange/_range/from}"
14 14
temp_c,"/definedValue[@fkey=tableRecord_ID,userDefined[tableName=observation,userDefinedName=temperatureC]]/definedValue"
15 15
precip_mm,"/definedValue[@fkey=tableRecord_ID,userDefined[tableName=observation,userDefinedName=precipitationMm]]/definedValue"
16 16
slope_aspect,/*_ID/plot/slopeAspect
mappings/VegX-VegBank.plots.csv
28 28
/*UniqueIdentifierID->/*s/plot/geospatial/DecimalLongitude,/*_ID/plot/realLongitude
29 29
/*UniqueIdentifierID->/*s/plot/geospatial/FootprintWKT,/*_ID/plot/dsgpoly
30 30
/*UniqueIdentifierID->/*s/plot/geospatial/maximumDepthInMeters,/waterDepth/max
31
/*UniqueIdentifierID->/*s/plot/geospatial/maximumElevationInMeters,"/*_ID/plot/{elevation/max,elevationRange/to}"
31
/*UniqueIdentifierID->/*s/plot/geospatial/maximumElevationInMeters,"/*_ID/plot/{elevation/_avg/max,elevationRange/_range/to}"
32 32
/*UniqueIdentifierID->/*s/plot/geospatial/minimumDepthInMeters,/waterDepth/min
33
/*UniqueIdentifierID->/*s/plot/geospatial/minimumElevationInMeters,"/*_ID/plot/{elevation/min,elevationRange/from}"
33
/*UniqueIdentifierID->/*s/plot/geospatial/minimumElevationInMeters,"/*_ID/plot/{elevation/_avg/min,elevationRange/_range/from}"
34 34
/*UniqueIdentifierID->/*s/plot/geospatial/verbatimElevation,/*_ID/plot/elevation
35 35
/*UniqueIdentifierID->/*s/plot/plotUniqueIdentifier,/*_ID/plot/authorPlotCode
36 36
/*UniqueIdentifierID->/*s/plot/plotUniqueIdentifier,"/{*_ID/plot/authorPlotCode,authorObsCode}"

Also available in: Unified diff