Project

General

Profile

metacat / lib / oaipmh / eml201toDublinCore.xsl @ 8265

1
<?xml version="1.0" encoding="UTF-8"?>
2

    
3
<xsl:stylesheet version="2.0" 
4
    xmlns:dc="http://purl.org/dc/elements/1.1/" 
5
    xmlns:eml="eml://ecoinformatics.org/eml-2.0.1"
6
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
7
    xmlns:fo="http://www.w3.org/1999/XSL/Format" 
8
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
9
    xmlns:fn="http://www.w3.org/2005/xpath-functions"
10
>
11
  
12
  <xsl:output method="xml"
13
              omit-xml-declaration="yes"
14
              encoding="utf-8"/>
15
  <xsl:strip-space elements="*"/>
16

    
17
  
18
  <!-- create a variable that contains all the elements that have an 'id' 
19
       attribute. Do this so that the the search for such elements only has
20
       to be carried out once.
21
    -->     
22
  <xsl:variable name="ids" select="//*[@id!='']"/>
23
  <xsl:variable name="metacat-server">http://metacat.lternet.edu/metacat/metacat</xsl:variable>
24

    
25
  <xsl:template match="/">
26
    <oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" 
27
               xmlns:dc="http://purl.org/dc/elements/1.1/" 
28
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
29
               xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
30
    <xsl:text>&#xA;</xsl:text>
31
     
32
    <xsl:variable name="packageId">
33
	  <xsl:value-of select="eml:eml/@packageId" />
34
	</xsl:variable>
35

    
36
    <xsl:for-each select="eml:eml/dataset/title">
37
      <xsl:element name="dc:title">
38
        <xsl:call-template name="title"></xsl:call-template>
39
      </xsl:element>
40
    </xsl:for-each>
41

    
42
    <xsl:for-each select="eml:eml/dataset/creator">
43
      <xsl:element name="dc:creator">
44
        <xsl:call-template name="creator"></xsl:call-template>
45
      </xsl:element>
46
    </xsl:for-each>
47

    
48
    <xsl:for-each select="eml:eml/dataset/keywordSet/keyword">
49
      <xsl:element name="dc:subject">
50
        <xsl:call-template name="subject"></xsl:call-template>
51
      </xsl:element>
52
    </xsl:for-each>
53

    
54
    <xsl:if test="eml:eml/dataset/abstract">
55
      <xsl:element name="dc:description">
56
        <xsl:value-of select="eml:eml/dataset/abstract" />
57
      </xsl:element>
58
    </xsl:if>
59

    
60
    <xsl:if test="eml:eml/dataset/publisher">
61
      <xsl:element name="dc:publisher">
62
        <xsl:call-template name="publisher"></xsl:call-template>
63
      </xsl:element>
64
    </xsl:if>
65

    
66
    <xsl:for-each select="eml:eml/dataset//associatedParty">
67
      <xsl:element name="dc:contributor">
68
        <xsl:call-template name="contributor"></xsl:call-template>
69
      </xsl:element>
70
    </xsl:for-each>
71

    
72
    <xsl:if test="eml:eml/dataset/pubDate">
73
      <xsl:element name="dc:date">
74
        <xsl:value-of select="eml:eml/dataset/pubDate" />
75
      </xsl:element>
76
    </xsl:if>
77
    
78
    <xsl:call-template name="type"></xsl:call-template>
79

    
80
    <xsl:for-each select="eml:eml/dataset//physical/dataFormat">
81
      <xsl:element name="dc:format">
82
        <xsl:call-template name="format"></xsl:call-template>
83
      </xsl:element>
84
    </xsl:for-each>
85

    
86
    <xsl:element name="dc:identifier"><xsl:value-of select="$metacat-server" />/<xsl:value-of select="$packageId" />/xml</xsl:element>
87

    
88
    <xsl:element name="dc:identifier">
89
      <xsl:value-of select="$packageId"/>
90
    </xsl:element>
91

    
92
    <xsl:for-each select="eml:eml/dataset//geographicCoverage/geographicDescription">
93
      <xsl:element name="dc:coverage">
94
        <xsl:value-of select="."/>
95
      </xsl:element>
96
    </xsl:for-each>
97

    
98
    <xsl:for-each select="eml:eml/dataset//geographicCoverage/boundingCoordinates">
99
      <xsl:element name="dc:coverage">
100
        <xsl:call-template name="coverageBoundingCoordinates"></xsl:call-template>
101
      </xsl:element>
102
    </xsl:for-each>
103

    
104
    <xsl:for-each select="eml:eml/dataset//temporalCoverage">
105
      <xsl:element name="dc:coverage">
106
        <xsl:call-template name="coverageTemporal"></xsl:call-template>
107
      </xsl:element>
108
    </xsl:for-each>
109

    
110
    <xsl:if test="eml:eml/dataset/intellectualRights">
111
      <xsl:element name="dc:rights">
112
        <xsl:value-of select="eml:eml/dataset/intellectualRights"/>
113
      </xsl:element>
114
    </xsl:if>
115

    
116
    <xsl:text>&#xA;</xsl:text>
117
    </oai_dc:dc>
118
  </xsl:template>
119

    
120

    
121
  <xsl:template name="title">
122
    <xsl:value-of select="." />
123
  </xsl:template>
124

    
125

    
126
  <xsl:template name="creator">
127
    <xsl:choose>
128
      <xsl:when test="individualName/surName">
129
        <xsl:choose>
130
          <xsl:when test="individualName/givenName">
131
            <xsl:value-of select="individualName/givenName" />
132
            <xsl:text>&#x20;</xsl:text>
133
          </xsl:when>
134
        </xsl:choose>
135
        <xsl:value-of select="individualName/surName" />
136
      </xsl:when>
137
      <xsl:when test="organizationName">
138
        <xsl:value-of select="organizationName" />
139
      </xsl:when>
140
    </xsl:choose>
141
  </xsl:template>
142

    
143

    
144
  <xsl:template name="subject">
145
    <xsl:value-of select="." />
146
  </xsl:template>
147

    
148

    
149
  <xsl:template name="contributor">
150
    <xsl:choose>
151
      <xsl:when test="individualName/surName">
152
        <xsl:choose>
153
          <xsl:when test="individualName/givenName">
154
            <xsl:value-of select="individualName/givenName" />
155
            <xsl:text>&#x20;</xsl:text>
156
          </xsl:when>
157
        </xsl:choose>
158
        <xsl:value-of select="individualName/surName" />
159
      </xsl:when>
160
      <xsl:when test="organizationName">
161
        <xsl:value-of select="organizationName" />
162
      </xsl:when>
163
    </xsl:choose>
164
  </xsl:template>
165

    
166
  <xsl:template name="publisher">
167
    <xsl:choose>
168
      <xsl:when test="eml:eml/dataset/publisher/individualName/surName">
169
        <xsl:choose>
170
          <xsl:when test="eml:eml/dataset/publisher/individualName/givenName">
171
            <xsl:value-of select="eml:eml/dataset/publisher/individualName/givenName" />
172
            <xsl:text>&#x20;</xsl:text>
173
          </xsl:when>
174
        </xsl:choose>
175
        <xsl:value-of select="eml:eml/dataset/publisher/individualName/surName" />
176
      </xsl:when>
177
      <xsl:when test="eml:eml/dataset/publisher/organizationName">
178
        <xsl:value-of select="eml:eml/dataset/publisher/organizationName" />
179
      </xsl:when>
180
      <xsl:when test="eml:eml/dataset/publisher/positionName">
181
        <xsl:value-of select="eml:eml/dataset/publisher/positionName" />
182
      </xsl:when>
183
    </xsl:choose>
184
  </xsl:template>
185

    
186
  <xsl:template name="type">
187
    <xsl:element name="dc:type">
188
      <xsl:choose>
189
        <xsl:when test="eml:eml/dataset">dataset</xsl:when>
190
        <xsl:when test="eml:eml/citation">citation</xsl:when>
191
        <xsl:when test="eml:eml/software">software</xsl:when>
192
        <xsl:when test="eml:eml/protocol">protocol</xsl:when>
193
      </xsl:choose>
194
    </xsl:element>
195
  </xsl:template>
196

    
197
  <xsl:template name="format">
198
    <xsl:choose>
199
      <xsl:when test="textFormat">text/plain</xsl:when>
200
      <xsl:when test="externallyDefinedFormat"><xsl:value-of select="formatName" /></xsl:when>
201
      <xsl:when test="binaryRasterFormat">binary raster</xsl:when>
202
    </xsl:choose>
203
  </xsl:template>
204

    
205
  <xsl:template name="coverageBoundingCoordinates">
206
    <xsl:text>&#xA;</xsl:text>
207
    <xsl:value-of select="westBoundingCoordinate" /> W
208
    <xsl:value-of select="eastBoundingCoordinate" /> E
209
    <xsl:value-of select="northBoundingCoordinate" /> N
210
    <xsl:value-of select="southBoundingCoordinate" /> S
211
  </xsl:template>
212

    
213
  <xsl:template name="coverageTemporal">
214
    <xsl:choose>
215
      <xsl:when test="singleDateTime">
216
        <xsl:value-of select="singleDateTime/calendarDate" />
217
      </xsl:when>
218
      <xsl:when test="rangeOfDates">
219
        <xsl:value-of select="rangeOfDates/beginDate/calendarDate" />
220
        <xsl:text> to </xsl:text>
221
        <xsl:value-of select="rangeOfDates/endDate/calendarDate" />
222
      </xsl:when>
223
    </xsl:choose>
224
  </xsl:template>
225

    
226
</xsl:stylesheet>