/
eml2tonbii.xsl
3401 lines (3313 loc) · 163 KB
/
eml2tonbii.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0"?>
<!--
* This is a newer revision for the eml2nbii stylesheet. See log of changes respect to revision 1.21 below. Inigo
* The following info, from previous version 1.21, until where says "Log of Changes".
*
* '$RCSfile: eml2tonbii.xsl,v $'
* Authors: Dan Higgins
* Copyright: 2000 Regents of the University of California and the
* National Center for Ecological Analysis and Synthesis
* For Details: http://www.nceas.ucsb.edu/
*
* '$Author: jones $'
* '$Date: 2007-03-01 17:00:22 $'
* '$Revision: 1.23 $'
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* This is an XSLT (http://www.w3.org/TR/xslt) stylesheet designed to
* convert an XML file in eml2 format to nbii fromat
*
*
*
**** Log of Changes, January 19, 2010. Jing Tao. ***
** Summary:
* The modification makes the style sheet work with eml-2.0.0, eml-2.0.1 and eml-2.1.0.
*
** Itemized list of changes.
* 1. Use "/*[local-name() = 'eml']" to replace "/eml:eml/" in xpath throught out the entire file.
* 2. Line 1384, 1386 and 1391, use "or" condition to handle "/eml/dataset/access" or "/eml/access".
* 3. Line 1938 and 1940, use "or" condition to hanlde "//measurmentScale/datetime" or "//measurmentScale/dateTime"
* 4. Line 1392, using "Deny" to replace "Allow".
* 5 Line 3149, use "Ecological Metadata Langualge 2.x " to replace "Ecological Metadata Langualge 2.0".
* 5. Line 3152, use "Ecological Metadata Language 2.x" to repalce "Ecological Metadata Language 2.0.1".
************************************************************************************************************************
**** Log of Changes, September 2005. Inigo San Gil.****
*
** Summary
*
* There are about 50 issues (some critical metadata loss) solved in this revision. Mostly are
* metadata sections that were not completely mapped from the EML to the BDP standard.
*
* Additionally, there are a few other improvements in the mapping.
* This revision, 3000+ lines, previous 1600.
*
** Itemized list of changes. NOTE, line numbers refer to the previous version (revision 1.21) of "eml2nbii.xsl"
*
* line 51: Make all possible metadata transformations, that is, set the variable $show_optional to true (1)
* line 141: Loop over all entities in EML; Previosuly, only dataTable, spatialRaster and spatialVector considered. "view", "storedProcedure" and "otherEntity" added.
* hard coded content values changed to english (dataTable to tabular digital data, etc)
* line 148: BDP "Sername" (series) contents not mapped. Added EML"series" content, if populated in the EML instance.
* line 158: BDP "pubPlace" contents not mapped. Added EML "pubPlace" content when used.
* line 161: BDP "publish" contents not mapped. Added EML "publisher" individual and org. name when used.
* line 172: BDP "onlink" contents not mapped. Added EML "distribution/online/url" when used.
* line 178: Odd hard coded value removed. It is possible that the author meant some action.
* line 196: BDP "purpose" contents not mapped. Added EML "purpose"
* line 200: BDP "supplinf" contents not mapped. Added EML "additionalInfo"
* line 243: Handling multiple single data time elements addressed (for each..), gelogical Scale / Alternatetimescale, etc. About 300+ lines of code replace about 120 of them
* line 333: Currentness element hard coded to "as it was when data was compiled" added
* line 330: Comment change
* line 335: Added all possible EML maintenance contents to map into BDP's update field. Also, there was a bug in the conditional statement.
* line 367: Added bounding altitudes mapping to the geographic coverage mapping (Not considered before)
* line 369: Added the G-poligon mapping.
* line 539: Added taxonomic keywords, previously forced to NONE.
* line 562: Added the case of optional classification system elements and other taxonomic-related metadata groups (230 lines of code)
* line 607, 620: Access element code group duplicated for use and access constraints elements in BDP. Not quite accurate granularity. Removed duplicate code
* line 607: Access element incomplete, the EML intellectual Rights section is relevant here. Add code.
* line 633: Added EML contact info. Need handle refs.
* line 641: Added in "datacred" (credit) info from EML "associated parties" and "funding" agency.
* line 663: Addition of metadata: Attemting to use section 2 of BDP: Data Quality Info. Some sections from EML methods can be used here. quite a bit of code added
* sections 3 and 4 of BDP skipped for now.
* line 791: Misleading/Obsolete comments refined.
* line 792: Include all EML dataset entities; add storedProcedure, view and otherEntity types.
* line 794: Not sure about the loop logic. Need testing.
* line 886: Textdomain from attribute type nominal or ordinal mapped correctly as is to "unrepresentable domain"
* line 911: Unit type added to BDPs "range domain" from EML's attributes of type interval or ratio.
* line 915: EMLs date time attribute type mapped correctly to unrepresentable domain.
* line 921: THIS MAY NEED A CHANGE. accuracy missing. It is not exactly the precision, but if EMLs attr. precision exists, it is mapped to BDPs attr. accuracy for the sake of preserving metadata.
* line 931: This conditional is out of place: there is no need of a EML physical element to populate this element. All you need is a "publisher" or a "contact". An distribution/online element helps.
* line 936: Distribution element. The distributor should be the publisher. If the publisher is not specified, it could default to the contact. Options included
* line 960: Contact org mapped.
* line 972: Contact person mapped
* line 984: Contact person mapped
* line 1058: Phone mapped better
* line 1072: Fax mapped
* line 1078: Email mapped
* line 1102: In the previous version, the BDP element distribution info is only mapped if the EML physical element is populated. We consider the case where the EML "distribution" exists,
* this opens a new case (lots of code)
* line 1122: Sometimes the "data format " -geoform- is placed depending on the entity we have in EML (data table, spatial vector, etc)
* line 1257: Clarification added to the hard coded text.
* line 1338: In practice, both metadata and data have the same publication date (pubDate), therefore pubdate of EML data mapped to pub date of BDP metadata
* line 1351: Try to map the metadataprovider as the metadta creator, otherwise (metadata provider not present in EML) default to the EML contact
* line 1386: add contact organization or contact person name even though we placed already one or the other.
* line 1475: map better the phone
* line 1490: map the fax
* line 1495: most importantly, map the email.
*
***
* Contact Info for <origin> (eml:<creator>) ((the person who gathered the data)) added to the <othercit> BDP in element (there is no room for that info otherwise).
*** Things to consider.
* The BDP elements spatial data organization info and spatial ref. info were not revised in this version.
* line 1099: statement about distribution liability
* line 921: THIS MAY NEED A CHANGE. accuracy missing. It is not exactly the precision, but if EMLs attr. precision exists, it is mapped to BDPs attr. accuracy for the sake of preserving metadata.
* Some references are not handled yet
* substitute the "xalan" namespace (work out the code) to make this stylesheet more portable - xalan independent-
*
*
* Thanks to Wade Sheldon, Mark Servilla, George Lienkaemper, Viv Hutchison and Matt Jones
***
*** Added, March 2006
***
*** Chris Lindsley found a critical bug on <spdoinfo> tree nodes. Some node xsl oeprations are not permitted on temporary subtree nodes (from variables). Changes made around line 1705.
***
** October 2006
**
** inline data tweaked: transformation was faulty there were distribution references in a <physical> group. Now it is contemplated well for all three options of EML distribution.
** TODOs: multiple tables in one EML.
** taxonomic keywords not mapped correctly.
***
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:eml="eml://ecoinformatics.org/eml-2.0.1"
xmlns:xalan="http://xml.apache.org/xalan"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:output encoding="ISO-8859-1"/>
<xsl:strip-space elements="*"/>
<!-- mapping of eml2 geometry types to fgdc; multi... types very uncertain! -->
<!-- March 2006, group is obsolete -->
<!--xsl:variable name="geometryTypeMap">
<geomtype name="LineString" sdtstype="String"/>
<geomtype name="LinearRing" sdtstype="Area chain"/>
<geomtype name="Polygon" sdtstype="G-polygon"/>
<geomtype name="Point" sdtstype="Point"/>
<geomtype name="MultiPoint" sdtstype="Point"/>
<geomtype name="MultiLineString" sdtstype="Ring composed of strings"/>
<geomtype name="MultiPolygon" sdtstype="G-polygon"/>
<geomtype name="MultiGeometry" sdtstype="Node, network"/>
</xsl:variable-->
<xsl:variable name="show_optional" select="1"/>
<!-- create a variable that contains all the elements that have an 'id'
attribute. Do this so that the the search for such elements only has
to be carried out once.
-->
<xsl:variable name="ids" select="//*[@id != '']"/>
<xsl:template match="/">
<xsl:element name="metadata">
<!-- only the 'idinfo' and 'metainfo' elements are required -->
<!-- start the 'idinfo' branch -->
<xsl:variable name="packageID">
<xsl:value-of select="/*[local-name() = 'eml']/@packageId"/>
</xsl:variable>
<xsl:element name="idinfo">
<xsl:element name="citation">
<xsl:element name="citeinfo">
<xsl:for-each select="/*[local-name() = 'eml']/dataset/creator">
<!-- This is a loop over all the dataset 'creator' elements
Note that dataset itself might be 'referenced' rather
than exist 'in-place'. More likely, however, is that
the creator element may have a 'references' child rather
than inline children! -->
<xsl:variable name="cc">
<xsl:choose>
<xsl:when test="./references != ''">
<xsl:variable name="ref_id" select="./references"/>
<!-- current element just references its contents
There should only be a single node with an id attribute
which matches the value of the references element -->
<xsl:copy-of select="$ids[@id=$ref_id]"/>
</xsl:when>
<xsl:otherwise>
<!-- no references tag, thus use the current node -->
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="origin">
<!-- 'origin' should correspond to the name of the 'creator' RP in eml2 -->
<xsl:choose>
<xsl:when test="xalan:nodeset($cc)//individualName/surName != ''">
<xsl:value-of select="xalan:nodeset($cc)//individualName/surName"/>
<xsl:value-of select="', '"/><xsl:value-of select="xalan:nodeset($cc)//individualName/givenName"/>
</xsl:when>
<xsl:when test="xalan:nodeset($cc)//organizationName != ''">
<xsl:value-of select="xalan:nodeset($cc)//organizationName"/>
</xsl:when>
<xsl:when test="xalan:nodeset($cc)//positionName != ''">
<xsl:value-of select="xalan:nodeset($cc)//positionName"/>
</xsl:when>
</xsl:choose>
</xsl:element>
</xsl:for-each>
<xsl:element name="pubdate">
<!-- pubdate is optional in eml2 -->
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/pubDate != ''">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/pubDate"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'N/A'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<xsl:if test="$show_optional">
<xsl:element name="pubtime">
<xsl:value-of select="'N/A'"/>
</xsl:element>
</xsl:if>
<xsl:element name="title">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/title"/>
</xsl:element>
<xsl:if test="$show_optional">
<xsl:element name="edition">
<xsl:value-of select="'N/A'"/>
</xsl:element>
</xsl:if>
<xsl:element name="geoform">
<!-- Geospatial Data Presentation Form - the mode in which the
geospatial data are represented. -->
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/dataTable != ''">
<xsl:value-of select="'tabular digital data'"/>
</xsl:when>
<xsl:when test="/*[local-name() = 'eml']/dataset/spatialRaster != ''">
<xsl:value-of select="'raster digital data'"/>
</xsl:when>
<xsl:when test="/*[local-name() = 'eml']/dataset/spatialVector != ''">
<xsl:value-of select="'spatial vector data'"/>
</xsl:when>
<xsl:when test="/*[local-name() = 'eml']/dataset/storedProcedure != ''">
<xsl:value-of select="'procedure'"/>
</xsl:when>
<xsl:when test="/*[local-name() = 'eml']/dataset/view != ''">
<xsl:value-of select="'view'"/>
</xsl:when>
<xsl:when test="/*[local-name() = 'eml']/dataset/otherEntity != ''">
<xsl:value-of select="'entity'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'unknown'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<!-- Only include series information if it's available in EML to avoid validity errors. -->
<xsl:if test="$show_optional">
<xsl:if test="/*[local-name() = 'eml']/dataset/series != ''">
<xsl:element name="serinfo">
<xsl:element name="sername">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/series" />
</xsl:element>
<xsl:element name="issue">
<xsl:value-of select="'N/A'" />
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:if>
<!-- Only include publication information if it's available in EML to avoid validity errors. -->
<xsl:if test="$show_optional">
<xsl:element name="pubinfo">
<xsl:element name="pubplace">
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/pubPlace != ''">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/pubPlace" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'N/A'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<xsl:element name="publish">
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/publisher/individualName/surName != ''">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/publisher/individualName/surName" /><xsl:value-of select="', '"/>
<xsl:value-of select="/*[local-name() = 'eml']/dataset/publisher/individualName/givenName" />
</xsl:when>
<xsl:when test="/*[local-name() = 'eml']/dataset/publisher/organizationName != ''">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/publisher/organizationName" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'N/A'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:element>
</xsl:if>
<xsl:if test="$show_optional">
<xsl:element name="othercit">
<!-- 'origin' corresponds to the name of the 'creator' in eml2, but <origin> cannot accept contact info. we put it here. -->
<xsl:for-each select="/*[local-name() = 'eml']/dataset/creator">
<!-- Need to capture info into $cc again -->
<xsl:variable name="cc">
<xsl:choose>
<xsl:when test="./references != ''">
<xsl:variable name="ref_id" select="./references"/>
<!-- current element just references its contents There should only be a single node with an id attribute which matches the value of the references element -->
<xsl:copy-of select="$ids[@id=$ref_id]"/>
</xsl:when>
<xsl:otherwise>
<!-- no references tag, thus use the current node -->
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="xalan:nodeset($cc)//address != ''">
<xsl:value-of select="' Contact info for data set originator: '"/>
<xsl:choose>
<xsl:when test="xalan:nodeset($cc)//individualName/surName != ''">
<xsl:value-of select="xalan:nodeset($cc)//individualName/surName"/>
<xsl:value-of select="', '"/><xsl:value-of select="xalan:nodeset($cc)//individualName/givenName"/>
<xsl:value-of select="' Address:'"/>
<xsl:value-of select="xalan:nodeset($cc)//deliveryPoint"/>
<xsl:value-of select="' '"/>
<xsl:value-of select="xalan:nodeset($cc)//city"/>
<xsl:value-of select="', '"/>
<xsl:value-of select="xalan:nodeset($cc)//administrativeArea"/>
<xsl:value-of select="' '"/>
<xsl:value-of select="xalan:nodeset($cc)//postalCode"/>
<xsl:value-of select="' '"/>
<xsl:value-of select="xalan:nodeset($cc)//country"/>
<xsl:value-of select="' '"/>
</xsl:when>
<xsl:when test="xalan:nodeset($cc)//organizationName != ''">
<xsl:value-of select="xalan:nodeset($cc)//organizationName"/>
<xsl:value-of select="' Address:'"/>
<xsl:value-of select="xalan:nodeset($cc)//address"/>
</xsl:when>
</xsl:choose>
</xsl:if>
<xsl:if test="xalan:nodeset($cc)//phone != ''">
<xsl:value-of select="' Phone:'"/><xsl:value-of select="xalan:nodeset($cc)//phone"/>
</xsl:if>
<xsl:if test="xalan:nodeset($cc)//electronicMailAddress != ''">
<xsl:value-of select="' Email address:'"/><xsl:value-of select="xalan:nodeset($cc)//electronicMailAddress"/>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:if>
<!-- Only include online link information if it's available in EML to avoid validity errors. -->
<xsl:if test="$show_optional">
<xsl:if test="/*[local-name() = 'eml']/dataset/distribution/online/url != ''">
<xsl:element name="onlink">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/distribution/online/url" />
</xsl:element>
</xsl:if>
</xsl:if>
<!-- Commenting this out since adding an empty Citation_Information element causes validation errors CSJ
<xsl:if test="$show_optional">
<xsl:element name="lworkcit">
</xsl:element>
</xsl:if>
-->
</xsl:element>
</xsl:element>
<xsl:element name="descript">
<xsl:element name="abstract">
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/abstract != ''">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/abstract"/>
<!-- abstract can be complex element in eml2; this useage will simply concatenate text -->
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'N/A'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<xsl:element name="purpose">
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/purpose != ''">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/purpose" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'N/A'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<!-- Only include supplimentary information if it's available in EML to avoid validity errors. -->
<xsl:if test="$show_optional">
<xsl:if test="/*[local-name() = 'eml']/dataset/additionalInfo != ''">
<xsl:element name="supplinf">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/additionalInfo" />
</xsl:element>
</xsl:if>
</xsl:if>
</xsl:element>
<xsl:element name="timeperd">
<xsl:element name="timeinfo">
<xsl:variable name="singledates"> <!-- store here the number of single date times used in the EML instance -->
<xsl:value-of select="count(/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime)" />
</xsl:variable>
<xsl:choose>
<xsl:when test="$singledates=1"> <!-- Case: A single date -->
<xsl:element name="sngdate">
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/calendarDate != ''"> <!-- a single date, standard date -->
<xsl:element name="caldate">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/calendarDate"/>
</xsl:element>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/time != ''"> <!-- add time, if there is any specified -->
<xsl:element name="time">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/time"/>
</xsl:element>
</xsl:if>
</xsl:when>
<xsl:when test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleName != ''">
<xsl:element name="geolage">
<xsl:element name="geolscal">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleName"/>
</xsl:element>
<xsl:element name="geolest">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleAgeEstimate"/>
</xsl:element>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleAgeUncertainty != ''">
<xsl:element name="geolun">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleAgeUncertainty"/>
</xsl:element>
</xsl:if>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleAgeExplanation != ''">
<xsl:element name="geolexpl">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleAgeExplanation"/>
</xsl:element>
</xsl:if>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleCitation/title != ''">
<xsl:element name="geolcit">
<xsl:element name="citeinfo">
<xsl:element name="origin">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleCitation/creator/individualName/surName"/>
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleCitation/creator/organizationName"/>
</xsl:element>
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleCitation/pubDate != ''">
<xsl:element name="pubdate">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleCitation/pubDate"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="pubdate"><xsl:value-of select="'Unknown'"/></xsl:element>
</xsl:otherwise>
</xsl:choose>
<xsl:element name="title">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleCitation/title"/>
</xsl:element>
<xsl:element name="geoform"><xsl:value-of select="'Standard'"/></xsl:element>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleCitation/series != ''">
<xsl:element name="sername">
<xsl:element name="serinfo">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleCitation/series"/>
</xsl:element>
<xsl:element name="issue"><xsl:value-of select="'Unknown'"/></xsl:element>
</xsl:element>
</xsl:if>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleCitation/distribution/online/url != ''">
<xsl:element name="onlink">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleCitation/distribution/online/url"/>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:element>
</xsl:when> <!-- end of single date case -->
<xsl:when test="$singledates > 1"> <!-- Case: Multiple single dates -->
<xsl:element name="mdattim">
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/calendarDate != ''">
<xsl:for-each select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/calendarDate">
<xsl:element name="sngdate">
<xsl:element name="caldate">
<xsl:value-of select="."/>
</xsl:element> <!-- we are not putting the time of the thing -->
</xsl:element>
</xsl:for-each>
</xsl:when>
<xsl:when test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale/timeScaleName != ''">
<xsl:for-each select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/singleDateTime/alternativeTimeScale">
<xsl:element name="geolage">
<xsl:element name="geolscal">
<xsl:value-of select="timeScaleName"/>
</xsl:element>
<xsl:element name="geolest">
<xsl:value-of select="timeScaleAgeEstimate"/>
</xsl:element>
<xsl:if test="timeScaleAgeUncertainty != ''">
<xsl:element name="geolun">
<xsl:value-of select="timeScaleAgeUncertainty"/>
</xsl:element>
</xsl:if>
<xsl:if test="timeScaleAgeExplanation != ''">
<xsl:element name="geolexpl">
<xsl:value-of select="timeScaleAgeExplanation"/>
</xsl:element>
</xsl:if>
<xsl:if test="timeScaleCitation/title != ''">
<xsl:element name="geolcit">
<xsl:element name="citeinfo">
<xsl:element name="origin">
<xsl:value-of select="timeScaleCitation/creator/individualName/surName"/>
<xsl:value-of select="timeScaleCitation/creator/organizationName"/>
</xsl:element>
<xsl:choose>
<xsl:when test="timeScaleCitation/pubDate != ''">
<xsl:element name="pubdate">
<xsl:value-of select="timeScaleCitation/pubDate"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="pubdate"><xsl:value-of select="'Unknown'"/></xsl:element>
</xsl:otherwise>
</xsl:choose>
<xsl:element name="title">
<xsl:value-of select="timeScaleCitation/title"/>
</xsl:element>
<xsl:if test="timeScaleCitation/series != ''">
<xsl:element name="sername">
<xsl:element name="serinfo">
<xsl:value-of select="timeScaleCitation/series"/>
</xsl:element>
<xsl:element name="issue"><xsl:value-of select="'Unknown'" /></xsl:element>
</xsl:element>
</xsl:if>
<xsl:if test="timeScaleCitation/distribution/online/url != ''">
<xsl:element name="onlink">
<xsl:value-of select="timeScaleCitation/distribution/online/url"/>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</xsl:element>
</xsl:when> <!-- end case multiple single dates. -->
<xsl:when test="$singledates < 1">
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/calendarDate != ''"> <!-- a range of dates, standard date -->
<xsl:element name="rngdates">
<xsl:element name="begdate">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/calendarDate"/>
</xsl:element>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/time != ''">
<xsl:element name="begtime">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/time"/>
</xsl:element>
</xsl:if>
<xsl:element name="enddate">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/calendarDate"/>
</xsl:element>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/time != ''">
<xsl:element name="endtime">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/time"/>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:when>
<xsl:when test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleName != ''"> <!-- a range of dates, alternative date -->
<xsl:element name="rngdates">
<xsl:element name="beggeol">
<xsl:element name="geolage">
<xsl:element name="geolscal">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleName" />
</xsl:element>
<xsl:element name="geolest">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleAgeEstimate"/>
</xsl:element>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleAgeUncertainty != ''">
<xsl:element name="geolun">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleAgeUncertainty"/>
</xsl:element>
</xsl:if>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleAgeExplanation != ''">
<xsl:element name="geolexpl">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleAgeExplanation"/>
</xsl:element>
</xsl:if>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleCitation/title != ''">
<xsl:element name="geolcit">
<xsl:element name="citeinfo">
<xsl:element name="origin">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleCitation/creator/individualName/surName"/>
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleCitation/creator/organizationName"/>
</xsl:element>
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleCitation/pubDate != ''">
<xsl:element name="pubdate">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleCitation/pubDate"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="pubdate"><xsl:value-of select="'Unknown'"/></xsl:element>
</xsl:otherwise>
</xsl:choose>
<xsl:element name="title">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleCitation/title"/>
</xsl:element>
<xsl:element name="geoform">
<xsl:value-of select="'Standard'"/>
</xsl:element>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleCitation/series != ''">
<xsl:element name="serinfo">
<xsl:element name="sername">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleCitation/series"/>
</xsl:element>
<xsl:element name="issue"><xsl:value-of select="'Unknown'"/></xsl:element>
</xsl:element>
</xsl:if>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleCitation/distribution/online/url != ''">
<xsl:element name="onlink">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/beginDate/alternativeTimeScale/timeScaleCitation/distribution/online/url"/>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:element>
<xsl:element name="endgeol">
<xsl:element name="geolage">
<xsl:element name="geolscal">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleName" />
</xsl:element>
<xsl:element name="geolest">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleAgeEstimate"/>
</xsl:element>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleAgeUncertainty != ''">
<xsl:element name="geolun">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleAgeUncertainty"/>
</xsl:element>
</xsl:if>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleAgeExplanation != ''">
<xsl:element name="geolexpl">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleAgeExplanation"/>
</xsl:element>
</xsl:if>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleCitation/title != ''">
<xsl:element name="geolcit">
<xsl:element name="citeinfo">
<xsl:element name="origin">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleCitation/creator/individualName/surName"/>
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleCitation/creator/organizationName"/>
</xsl:element>
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleCitation/pubDate != ''">
<xsl:element name="pubdate">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleCitation/pubDate"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="pubdate"><xsl:value-of select="'Unknown'"/></xsl:element>
</xsl:otherwise>
</xsl:choose>
<xsl:element name="title">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleCitation/title"/>
</xsl:element>
<xsl:element name="geoform">
<xsl:value-of select="'Standard'"/>
</xsl:element>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleCitation/series != ''">
<xsl:element name="serinfo">
<xsl:element name="sername">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleCitation/series"/>
</xsl:element>
<xsl:element name="issue"><xsl:value-of select="'Unknown'"/></xsl:element>
</xsl:element>
</xsl:if>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleCitation/distribution/online/url != ''">
<xsl:element name="onlink">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/temporalCoverage/rangeOfDates/endDate/alternativeTimeScale/timeScaleCitation/distribution/online/url"/>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:when> <!-- end alternative time scale of date range -->
<xsl:otherwise> <!-- well, there is no temporal coverage after all .. -->
<xsl:element name="sngdate">
<xsl:element name="caldate">
<xsl:value-of select="'N/A'"/>
</xsl:element>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:when> <!-- end range of dates (singledates<1) -->
</xsl:choose>
</xsl:element> <!-- end of timeinfo -->
<xsl:element name="current">
<xsl:value-of select="'as it was at time of compilation'"/>
</xsl:element>
</xsl:element> <!-- end of timeper -->
<xsl:element name="status">
<xsl:element name="progress">
<!-- allowed values for progress are 'Complete' 'In work' and 'Planned'. ISG: In EML we consider this document self-contained and complete -->
<xsl:value-of select="'Complete'"/>
</xsl:element>
<xsl:element name="update">
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/maintenance != ''"> <!-- ISG :we should consider all EML maintenance tag, not just the optional frequency. -->
<xsl:value-of select="/*[local-name() = 'eml']/dataset/maintenance"/> <!-- flatten out all element -->
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'Unknown'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:element>
<!-- spatial domain; esp bounding box info goes here -->
<!-- need to handle possible 'references' element here
Also, geographicCoverage is repeatable in eml2, but is NOT repeatable in fgdc;
This implementation just insert data from the first instance -->
<xsl:choose>
<!-- this 'when' test catches the top level geographic coverage element -->
<xsl:when test="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage != ''">
<xsl:element name="spdom">
<xsl:for-each select="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/geographicDescription">
<xsl:element name="descgeog">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:element name="bounding">
<xsl:for-each select="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/boundingCoordinates/westBoundingCoordinate">
<xsl:element name="westbc">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:for-each select="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/boundingCoordinates/eastBoundingCoordinate">
<xsl:element name="eastbc">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:for-each select="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/boundingCoordinates/northBoundingCoordinate">
<xsl:element name="northbc">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:for-each select="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/boundingCoordinates/southBoundingCoordinate">
<xsl:element name="southbc">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:element name="boundalt">
<xsl:for-each select="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/boundingCoordinates/boundingAltitudes/altitudeMinimum">
<xsl:element name="altmin">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:for-each select="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/boundingCoordinates/boundingAltitudes/altitudeMaximum">
<xsl:element name="almax">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:for-each select="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/boundingCoordinates/boundingAltitudes/altitudeUnits">
<xsl:element name="altunits">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:element>
<xsl:if test="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/datasetGPolygon != ''">
<xsl:element name="dsgpoly">
<xsl:element name="dsgpolyo">
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonOuterGRing/gRingPoint/gRingLatitude != ''">
<xsl:for-each select="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonOuterGRing/gRingPoint">
<xsl:element name="grngpoin">
<xsl:element name="gringlat">
<xsl:value-of select="gRingLatitude"/>
</xsl:element>
<xsl:element name="gringlon">
<xsl:value-of select="gRingLongitude"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:when>
<xsl:when test="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonOuterGRing/gRing/gRingLatitude != ''">
<!-- in this case we are dealing with pairs of latitude-longitude pairs that are mapped into gring in the BDP standard -->
<xsl:element name="gring">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonOuterGRing/gRing/gRingLatitude"/>
<xsl:value-of select="','"/>
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonOuterGRing/gRing/gRingLongitude"/>
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:element>
<!-- in EML, the exclusion or Inner ring is optional.. so if it is not existing, make it a zero in bdp -->
<xsl:element name="dsgpolyx">
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonExclusionGRing/gRingPoint/gRingLatitude != ''">
<xsl:for-each select="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonExclusionGRing/gRingPoint">
<xsl:element name="grngpoin">
<xsl:element name="gringlat">
<xsl:value-of select="gRingLatitude"/>
</xsl:element>
<xsl:element name="gringlon">
<xsl:value-of select="gRingLongitude"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:when>
<xsl:when test="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonExclusionGRing/gRing/gRingLatitude != ''">
<!-- in this case we are dealing with pairs of latitude-longitude pairs that are mapped into gring in the BDP standard -->
<!-- as is, it will flatten the contents into the gring. It may need some work to be more accurate -->
<xsl:element name="gring">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonExclusionGRing/gRing/gRingLatitude"/>
<xsl:value-of select="','"/>
<xsl:value-of select="/*[local-name() = 'eml']/dataset/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonExclusionGRing/gRing/gRingLongitude"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="grngpoin">
<xsl:element name="gringlat" />
<xsl:element name="gringlon"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:element><!-- end dspoly el -->
</xsl:if>
</xsl:element>
</xsl:when>
<!-- Use geocoverage if it is part of the first entitiy -->
<xsl:when test="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage != ''">
<xsl:element name="spdom">
<xsl:for-each select="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/geographicDescription">
<xsl:element name="descgeog">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:element name="bounding">
<xsl:for-each select="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/boundingCoordinates/westBoundingCoordinate">
<xsl:element name="westbc">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:for-each select="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/boundingCoordinates/eastBoundingCoordinate">
<xsl:element name="eastbc">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:for-each select="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/boundingCoordinates/northBoundingCoordinate">
<xsl:element name="northbc">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:for-each select="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/boundingCoordinates/southBoundingCoordinate">
<xsl:element name="southbc">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:element name="boundalt">
<xsl:for-each select="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/boundingCoordinates/boundingAltitudes/altitudeMinimum">
<xsl:element name="altmin">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:for-each select="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/boundingCoordinates/boundingAltitudes/altitudeMaximum">
<xsl:element name="almax">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:for-each select="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/boundingCoordinates/boundingAltitudes/altitudeUnits">
<xsl:element name="altunits">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:element>
<xsl:if test="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/datasetGPolygon != ''">
<xsl:element name="dsgpoly">
<xsl:element name="dsgpolyo">
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonOuterGRing/gRingPoint/gRingLatitude != ''">
<xsl:for-each select="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonOuterGRing/gRingPoint">
<xsl:element name="grngpoin">
<xsl:element name="gringlat">
<xsl:value-of select="gRingLatitude"/>
</xsl:element>
<xsl:element name="gringlon">
<xsl:value-of select="gRingLongitude"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:when>
<xsl:when test="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonOuterGRing/gRing/gRingLatitude != ''">
<!-- in this case we are dealing with pairs of latitude-longitude pairs that are mapped into gring in the BDP standard -->
<xsl:element name="gring">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonOuterGRing/gRing/gRingLatitude"/>
<xsl:value-of select="','"/>
<xsl:value-of select="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonOuterGRing/gRing/gRingLongitude"/>
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:element>
<!-- in EML, the exclusion or Inner ring is optional.. so if it is not existing, make it a zero in bdp -->
<xsl:element name="dsgpolyx">
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonExclusionGRing/gRingPoint/gRingLatitude != ''">
<xsl:for-each select="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonExclusionGRing/gRingPoint">
<xsl:element name="grngpoin">
<xsl:element name="gringlat">
<xsl:value-of select="gRingLatitude"/>
</xsl:element>
<xsl:element name="gringlon">
<xsl:value-of select="gRingLongitude"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:when>
<xsl:when test="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonExclusionGRing/gRing/gRingLatitude != ''">
<!-- in this case we are dealing with pairs of latitude-longitude pairs that are mapped into gring in the BDP standard -->
<!-- as is, it will flatten the contents into the gring. It may need some work to be more accurate -->
<xsl:element name="gring">
<xsl:value-of select="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonExclusionGRing/gRing/gRingLatitude"/>
<xsl:value-of select="','"/>
<xsl:value-of select="/*[local-name() = 'eml']/dataset/*/coverage/geographicCoverage/datasetGPolygon/datasetGPolygonExclusionGRing/gRing/gRingLongitude"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="grngpoin">
<xsl:element name="gringlat" />
<xsl:element name="gringlon"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:element><!-- end dspolyg element -->
</xsl:if>
</xsl:element>
</xsl:when>
</xsl:choose>
<xsl:element name="keywords">
<xsl:choose>
<xsl:when test="/*[local-name() = 'eml']/dataset/keywordSet != ''">
<xsl:for-each select="/*[local-name() = 'eml']/dataset/keywordSet">
<xsl:variable name="current_thes" select="/*[local-name() = 'eml']/dataset/keywordSet/keywordThesaurus"/>
<xsl:for-each select="./keyword">
<xsl:choose>
<xsl:when test="./@keywordType='theme'">
<xsl:element name="theme">
<xsl:element name="themekt">
<xsl:choose>
<xsl:when test="$current_thes != ''">
<xsl:value-of select="$current_thes"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'N/A'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<xsl:element name="themekey">
<xsl:value-of select="."/>
</xsl:element>
</xsl:element>
</xsl:when>
<xsl:when test="./@keywordType='place'">
<xsl:element name="place">
<xsl:element name="placekt">
<xsl:choose>
<xsl:when test="$current_thes != ''">
<xsl:value-of select="$current_thes"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'N/A'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<xsl:element name="placekey">
<xsl:value-of select="."/>
</xsl:element>
</xsl:element>
</xsl:when>
<xsl:when test="./@keywordType='stratum'">