Revision 111
Added by Aaron Marcuse-Kubitza about 13 years ago
scripts/test/accepted_output/NYBG.organisms.VegX.xml | ||
---|---|---|
199 | 199 |
</taxonConcepts> |
200 | 200 |
<plotObservations> |
201 | 201 |
<plotObservation id="0"> |
202 |
<obsStartDate>1984-8-20</obsStartDate> |
|
202 |
<obsStartDate>1984-08-20</obsStartDate>
|
|
203 | 203 |
<plotUniqueIdentifierID>0</plotUniqueIdentifierID> |
204 | 204 |
</plotObservation> |
205 | 205 |
<plotObservation id="1"> |
206 |
<obsStartDate>1994-1-17</obsStartDate> |
|
206 |
<obsStartDate>1994-01-17</obsStartDate>
|
|
207 | 207 |
<plotUniqueIdentifierID>1</plotUniqueIdentifierID> |
208 | 208 |
</plotObservation> |
209 | 209 |
</plotObservations> |
scripts/test/accepted_output/SALVIAS.plots.VegX.xml | ||
---|---|---|
8 | 8 |
<name>plotMethodology</name> |
9 | 9 |
<value>1 ha, stems >= 10 cm dbh</value> |
10 | 10 |
</simpleUserdefined> |
11 |
<obsStartDate>1990.874</obsStartDate>
|
|
11 |
<obsStartDate>1990-11-16</obsStartDate>
|
|
12 | 12 |
</plotObservation> |
13 | 13 |
<plotObservation id="1"> |
14 | 14 |
<projectID>1</projectID> |
... | ... | |
17 | 17 |
<name>plotMethodology</name> |
18 | 18 |
<value>1 ha, stems >= 10 cm dbh</value> |
19 | 19 |
</simpleUserdefined> |
20 |
<obsStartDate>1990.874</obsStartDate>
|
|
20 |
<obsStartDate>1990-11-16</obsStartDate>
|
|
21 | 21 |
</plotObservation> |
22 | 22 |
</plotObservations> |
23 | 23 |
<projects> |
scripts/test/accepted_output/SALVIAS.organisms.VegX.xml | ||
---|---|---|
75 | 75 |
<plotObservations> |
76 | 76 |
<plotObservation id="0"> |
77 | 77 |
<plotUniqueIdentifierID>0</plotUniqueIdentifierID> |
78 |
<obsStartDate>2001</obsStartDate> |
|
78 |
<obsStartDate>2001-01-01</obsStartDate>
|
|
79 | 79 |
</plotObservation> |
80 | 80 |
<plotObservation id="1"> |
81 | 81 |
<plotUniqueIdentifierID>2</plotUniqueIdentifierID> |
82 |
<obsStartDate>2001</obsStartDate> |
|
82 |
<obsStartDate>2001-01-01</obsStartDate>
|
|
83 | 83 |
</plotObservation> |
84 | 84 |
</plotObservations> |
85 | 85 |
<plots> |
scripts/test/accepted_output/NYBG.organisms.VegBank.xml | ||
---|---|---|
275 | 275 |
</taxonImportance> |
276 | 276 |
<observation_ID> |
277 | 277 |
<observation> |
278 |
<obsStartDate>1984-8-20</obsStartDate> |
|
278 |
<obsStartDate>1984-08-20</obsStartDate>
|
|
279 | 279 |
<plot_ID> |
280 | 280 |
<plot> |
281 | 281 |
<place> |
... | ... | |
492 | 492 |
</taxonImportance> |
493 | 493 |
<observation_ID> |
494 | 494 |
<observation> |
495 |
<obsStartDate>1994-1-17</obsStartDate> |
|
495 |
<obsStartDate>1994-01-17</obsStartDate>
|
|
496 | 496 |
<plot_ID> |
497 | 497 |
<plot> |
498 | 498 |
<place> |
scripts/test/accepted_output/SALVIAS.plots.VegBank.xml | ||
---|---|---|
43 | 43 |
</plot> |
44 | 44 |
</plot_ID> |
45 | 45 |
<methodNarrative>1 ha, stems >= 10 cm dbh</methodNarrative> |
46 |
<obsStartDate>1990.874</obsStartDate>
|
|
46 |
<obsStartDate>1990-11-16</obsStartDate>
|
|
47 | 47 |
</observation> |
48 | 48 |
<observation id="1"> |
49 | 49 |
<project_ID> |
... | ... | |
88 | 88 |
</plot> |
89 | 89 |
</plot_ID> |
90 | 90 |
<methodNarrative>1 ha, stems >= 10 cm dbh</methodNarrative> |
91 |
<obsStartDate>1990.874</obsStartDate>
|
|
91 |
<obsStartDate>1990-11-16</obsStartDate>
|
|
92 | 92 |
</observation> |
93 | 93 |
</VegBank> |
scripts/test/accepted_output/SALVIAS.organisms.VegBank.xml | ||
---|---|---|
16 | 16 |
<authorPlotCode>1</authorPlotCode> |
17 | 17 |
</plot> |
18 | 18 |
</plot_ID> |
19 |
<obsStartDate>2001</obsStartDate> |
|
19 |
<obsStartDate>2001-01-01</obsStartDate>
|
|
20 | 20 |
<authorObsCode>1</authorObsCode> |
21 | 21 |
</observation> |
22 | 22 |
</observation_ID> |
... | ... | |
271 | 271 |
<authorPlotCode>4</authorPlotCode> |
272 | 272 |
</plot> |
273 | 273 |
</plot_ID> |
274 |
<obsStartDate>2001</obsStartDate> |
|
274 |
<obsStartDate>2001-01-01</obsStartDate>
|
|
275 | 275 |
<authorObsCode>4</authorObsCode> |
276 | 276 |
</observation> |
277 | 277 |
</observation_ID> |
scripts/lib/xml_func.py | ||
---|---|---|
1 | 1 |
# XML "function" nodes that evaluate their contents to text |
2 | 2 |
|
3 |
import datetime |
|
4 |
|
|
3 | 5 |
import xml_dom |
4 | 6 |
|
5 | 7 |
def map_items(func, items): |
... | ... | |
19 | 21 |
|
20 | 22 |
def date(items): |
21 | 23 |
items = dict(items) |
22 |
return '-'.join([items['year'], items.get('month', '1'), |
|
23 |
items.get('day', '1')]) |
|
24 |
year = float(items['year']) |
|
25 |
date = datetime.date(int(year), int(items.get('month', '1')), |
|
26 |
int(items.get('day', '1'))) + datetime.timedelta(round((year % 1.)*365)) |
|
27 |
return date.strftime('%Y-%m-%d') |
|
24 | 28 |
|
25 | 29 |
def name(items): |
26 | 30 |
items = dict(items) |
mappings/VegX-VegBank.organisms.csv | ||
---|---|---|
73 | 73 |
"/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/slopeGradient","/*_ID/observation/*_ID/plot/slopeGradient" |
74 | 74 |
"/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/state","/*_ID/observation/*_ID/plot/place(/*_ID/namedPlace[placeSystem=""Geographic Name""])/placeName" |
75 | 75 |
"/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/state","/*_ID/observation/*_ID/plot/place(/*_ID/namedPlace[placeSystem=""region|state|province""])/placeName" |
76 |
"/*ID->/*s/plotObservation/obsEndDate","/*_ID/observation/obsEndDate" |
|
77 |
"/*ID->/*s/plotObservation/obsStartDate","/*_ID/observation/obsStartDate" |
|
76 |
"/*ID->/*s/plotObservation/obsEndDate/_date/year","/*_ID/observation/obsEndDate/_date/year" |
|
78 | 77 |
"/*ID->/*s/plotObservation/obsStartDate/_date/day","/*_ID/observation/obsStartDate/_date/day" |
79 | 78 |
"/*ID->/*s/plotObservation/obsStartDate/_date/month","/*_ID/observation/obsStartDate/_date/month" |
80 | 79 |
"/*ID->/*s/plotObservation/obsStartDate/_date/year","/*_ID/observation/obsStartDate/_date/year" |
mappings/SALVIAS-VegX.plots.csv | ||
---|---|---|
39 | 39 |
"plot_methodology","/simpleUserdefined[name=plotMethodology]/value" |
40 | 40 |
"plot_area_ha","/*UniqueIdentifierID->/*s/plot/area" |
41 | 41 |
"recensused", |
42 |
"date_start","/obsStartDate" |
|
43 |
"date_finish","/obsEndDate" |
|
42 |
"date_start","/obsStartDate/_date/year" |
|
43 |
"date_finish","/obsEndDate/_date/year" |
mappings/SALVIAS-VegX.organisms.csv | ||
---|---|---|
3 | 3 |
"PLOT_ID", |
4 | 4 |
"plot_code","/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/relatedSpatialItem/relatedItem[relationshipType=parentPlot]/relatedItemID->/*s/plot/plotUniqueIdentifier" |
5 | 5 |
"census_no","/simpleUserdefined[name=censusNo]/value" |
6 |
"census_date","/*ID->/*s/plotObservation/obsStartDate" |
|
6 |
"census_date","/*ID->/*s/plotObservation/obsStartDate/_date/year"
|
|
7 | 7 |
"subplot","/*ID->/*s/plotObservation/*UniqueIdentifierID->/*s/plot/plotUniqueIdentifier" |
8 | 8 |
"individual_code","/simpleUserdefined[name=individualCode]/value" |
9 | 9 |
"ind_id", |
mappings/SALVIAS-VegBank.plots.csv | ||
---|---|---|
36 | 36 |
life_zone_code,/commClass/commInterpretation/commconcept_ID/*_ID/observation/commClass/commInterpretation/*_ID/commConcept/*_ID/*/commName |
37 | 37 |
plot_methodology,/methodNarrative |
38 | 38 |
plot_area_ha,/*_ID/plot/area |
39 |
date_start,/obsStartDate |
|
40 |
date_finish,/obsEndDate |
|
39 |
date_start,/obsStartDate/_date/year |
|
40 |
date_finish,/obsEndDate/_date/year |
mappings/SALVIAS-VegBank.organisms.csv | ||
---|---|---|
2 | 2 |
OBSERVATION_ID,"/{taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]:[interpretationType=Author,originalInterpretation=true,currentInterpretation=false,interpretationDate=epoch,*_ID/plantConcept,*_ID/party]/museumAccessionNumber,*_ID/observation/*_ID/plot:[confidentialityStatus=0]/authorPlotCode}" |
3 | 3 |
plot_code,/*_ID/observation/*_ID/plot/PARENT_ID/plot:[confidentialityStatus=0]/authorPlotCode |
4 | 4 |
census_no,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/definedValue[*_ID/userDefined[tableName=taxonInterpretation,userDefinedName=censusNo]:[userDefinedType=varchar]]:[@fkey=tableRecord_ID]/definedValue" |
5 |
census_date,/*_ID/observation/obsStartDate |
|
5 |
census_date,/*_ID/observation/obsStartDate/_date/year
|
|
6 | 6 |
subplot,"/*_ID/observation/{*_ID/plot:[confidentialityStatus=0]/authorPlotCode,authorObsCode}" |
7 | 7 |
individual_code,"/taxonImportance/stemCount/stemLocation/taxonInterpretation[ROLE_ID/aux_Role/roleCode=collector]/definedValue[*_ID/userDefined[tableName=taxonInterpretation,userDefinedName=individualCode]:[userDefinedType=varchar]]:[@fkey=tableRecord_ID]/definedValue" |
8 | 8 |
tag1,/taxonImportance/stemCount/stemLocation/stemCode |
mappings/VegX-VegBank.plots.csv | ||
---|---|---|
41 | 41 |
/*UniqueIdentifierID->/*s/plot/slopeGradient,/*_ID/plot/slopeGradient |
42 | 42 |
/*UniqueIdentifierID->/*s/plot/state,"/*_ID/plot/place(/*_ID/namedPlace[placeSystem=""Geographic Name""])/placeName" |
43 | 43 |
/*UniqueIdentifierID->/*s/plot/state,"/*_ID/plot/place(/*_ID/namedPlace[placeSystem=""region|state|province""])/placeName" |
44 |
/obsEndDate,/obsEndDate |
|
45 |
/obsStartDate,/obsStartDate |
|
44 |
/obsEndDate/_date/year,/obsEndDate/_date/year |
|
46 | 45 |
/obsStartDate/_date/day,/obsStartDate/_date/day |
47 | 46 |
/obsStartDate/_date/month,/obsStartDate/_date/month |
48 | 47 |
/obsStartDate/_date/year,/obsStartDate/_date/year |
Also available in: Unified diff
xml_func.py: Added support for decimal years (with day as the fraction)