Project

General

Profile

metacat / lib / oaipmh / eml200toDublinCore.xsl @ 4943

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.0"
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/knb/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:value-of select="eml:eml/dataset/publisher" />
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" />&#x20;
132
          </xsl:when>
133
        </xsl:choose>
134
        <xsl:value-of select="individualName/surName" />
135
      </xsl:when>
136
      <xsl:when test="organizationName">
137
        <xsl:value-of select="organizationName" />
138
      </xsl:when>
139
    </xsl:choose>
140
  </xsl:template>
141

    
142

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

    
147

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

    
164
  <xsl:template name="type">
165
    <xsl:element name="dc:type">
166
      <xsl:choose>
167
        <xsl:when test="eml:eml/dataset">dataset</xsl:when>
168
        <xsl:when test="eml:eml/citation">citation</xsl:when>
169
        <xsl:when test="eml:eml/software">software</xsl:when>
170
        <xsl:when test="eml:eml/protocol">protocol</xsl:when>
171
      </xsl:choose>
172
    </xsl:element>
173
  </xsl:template>
174

    
175
  <xsl:template name="format">
176
    <xsl:choose>
177
      <xsl:when test="textFormat">text/plain</xsl:when>
178
      <xsl:when test="externallyDefinedFormat"><xsl:value-of select="formatName" /></xsl:when>
179
      <xsl:when test="binaryRasterFormat">binary raster</xsl:when>
180
    </xsl:choose>
181
  </xsl:template>
182

    
183
  <xsl:template name="coverageBoundingCoordinates">
184
    <xsl:text>&#xA;</xsl:text>
185
    <xsl:value-of select="westBoundingCoordinate" /> W
186
    <xsl:value-of select="eastBoundingCoordinate" /> E
187
    <xsl:value-of select="northBoundingCoordinate" /> N
188
    <xsl:value-of select="southBoundingCoordinate" /> S
189
  </xsl:template>
190

    
191
  <xsl:template name="coverageTemporal">
192
    <xsl:choose>
193
      <xsl:when test="singleDateTime">
194
        <xsl:value-of select="singleDateTime/calendarDate" />
195
      </xsl:when>
196
      <xsl:when test="rangeOfDates">
197
        <xsl:value-of select="rangeOfDates/beginDate/calendarDate" />
198
        <xsl:text> to </xsl:text>
199
        <xsl:value-of select="rangeOfDates/endDate/calendarDate" />
200
      </xsl:when>
201
    </xsl:choose>
202
  </xsl:template>
203

    
204
</xsl:stylesheet>