africaspectrum-xmetadissplus-2-xmlbundle.xslt 11.5 KB
Newer Older
Gerrit Hübbers's avatar
WIP  
Gerrit Hübbers committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:oai="http://www.openarchives.org/OAI/2.0/"
 xmlns:xoai="http://www.lyncode.com/xoai"
 xmlns:xMetaDiss="http://www.d-nb.de/standards/xmetadissplus/"
 xmlns:cc="http://www.d-nb.de/standards/cc/"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:dcmitype="http://purl.org/dc/dcmitype/"
 xmlns:dcterms="http://purl.org/dc/terms/"
 xmlns:pc="http://www.d-nb.de/standards/pc/"
 xmlns:urn="http://www.d-nb.de/standards/urn/"
 xmlns:hdl="http://www.d-nb.de/standards/hdl/"
 xmlns:doi="http://www.d-nb.de/standards/doi/"
 xmlns:thesis="http://www.ndltd.org/standards/metadata/etdms/1.0/"
 xmlns:ddb="http://www.d-nb.de/standards/ddb/"
 xmlns:dini="http://www.d-nb.de/standards/xmetadissplus/type/"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:zoai="http://git.gesis.org/dda/zoai">
 
  <xsl:output indent="yes"/>
  <xsl:strip-space elements="*"/>
23
24
25
  <!-- <xsl:copy-of select="."/>  -->
  <!-- <xsl:message terminate="no">here is some message for stderr, e.g. <xsl:value-of select='text()' /> </xsl:message> -->
  
Gerrit Hübbers's avatar
WIP  
Gerrit Hübbers committed
26
27
28
29
30
31
32
33
34
35
36
37
  
  <!-- override default template -->
  <xsl:template match="*" />

  <!--
  dc.source.pageinfo and dc.source.issuetopic may or may not exist in oai_dc's dc:source ...
  see e.g. http://journals.sub.uni-hamburg.de/giga/afsp/oai?verb=GetRecord&metadataPrefix=oai_dc&identifier=oai:hup.sub.uni-hamburg.de.giga:article/29
  see e.g. http://journals.sub.uni-hamburg.de/giga/afsp/oai?verb=GetRecord&metadataPrefix=oai_dc&identifier=oai:hup.sub.uni-hamburg.de.giga:article/990
   -->
  <xsl:template match="/">
    <xsl:element name="bundle">
      <xsl:element name="metadata">
38
        
Gerrit Hübbers's avatar
WIP  
Gerrit Hübbers committed
39
        <xsl:apply-templates select="oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/xMetaDiss:xMetaDiss" />
40
        <xsl:apply-templates select="oai:OAI-PMH/oai:GetRecord/oai:record/oai:header" />
Gerrit Hübbers's avatar
WIP  
Gerrit Hübbers committed
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
        
        <xsl:call-template name="new-metadatum">
          <xsl:with-param name="key" select="'dc.type.stock'"/>
          <xsl:with-param name="language" select="''"/>
          <xsl:with-param name="value" select="'article'"/>
        </xsl:call-template>
        
        <xsl:call-template name="new-metadatum">
          <xsl:with-param name="key" select="'dc.type.document'"/>
          <xsl:with-param name="language" select="''"/>
          <xsl:with-param name="value" select="'32'"/>
        </xsl:call-template>
        
        <xsl:call-template name="new-metadatum">
          <xsl:with-param name="key" select="'dc.source.journal'"/>
          <xsl:with-param name="language" select="''"/>
          <xsl:with-param name="value" select="'Africa Spectrum'"/>
        </xsl:call-template>
        
        <xsl:call-template name="new-metadatum">
          <xsl:with-param name="key" select="'dc.rights.licence'"/>
          <xsl:with-param name="language" select="''"/>
          <xsl:with-param name="value" select="'27'"/>
        </xsl:call-template>
        
        <xsl:call-template name="new-metadatum">
          <xsl:with-param name="key" select="'dc.description.pubstatus'"/>
          <xsl:with-param name="language" select="''"/>
          <xsl:with-param name="value" select="'1'"/>
        </xsl:call-template>
        
72
        <!-- 
Gerrit Hübbers's avatar
WIP  
Gerrit Hübbers committed
73
74
75
76
77
        <xsl:call-template name="new-metadatum">
          <xsl:with-param name="key" select="'dc.description.review'"/>
          <xsl:with-param name="language" select="''"/>
          <xsl:with-param name="value" select="'1'"/>
        </xsl:call-template>
78
79
         -->
         
Gerrit Hübbers's avatar
WIP  
Gerrit Hübbers committed
80
81
82
83
84
85
86
87
      </xsl:element>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match="oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/xMetaDiss:xMetaDiss">
    <xsl:apply-templates></xsl:apply-templates>
  </xsl:template>
  
88
89
90
91
  <xsl:template match="oai:OAI-PMH/oai:GetRecord/oai:record/oai:header">
    <xsl:apply-templates></xsl:apply-templates>
  </xsl:template>
  
Gerrit Hübbers's avatar
WIP  
Gerrit Hübbers committed
92
  <xsl:template match="dc:title">
93
    <xsl:variable name="publicationLanguage" select="/oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/xMetaDiss:xMetaDiss/dc:language[@xsi:type='dcterms:ISO639-2']" />
Gerrit Hübbers's avatar
WIP  
Gerrit Hübbers committed
94
    <xsl:variable name="language" select="@lang" />
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
    
    <!-- <xsl:message terminate="no">language is <xsl:value-of select='$language' /> ... and publicationLanguage is <xsl:value-of select='$publicationLanguage' /> </xsl:message> -->
    
    <!-- dc.title and dc.title.alternative may exist. Iff dc.language equals some source-dc.title, then this is the result-dc.title ... otherwise (iff they don't equal) it is taken as dc.title.alternative -->
    <xsl:choose>
      <xsl:when test="$language = $publicationLanguage">
        <xsl:call-template name="new-metadatum">
          <xsl:with-param name="key" select="'dc.title'"/>
          <xsl:with-param name="language" select="$language"/>
          <xsl:with-param name="value" select="text()"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="new-metadatum">
          <xsl:with-param name="key" select="'dc.title.alternative'"/>
          <xsl:with-param name="language" select="$language"/>
          <xsl:with-param name="value" select="text()"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
    
Gerrit Hübbers's avatar
WIP  
Gerrit Hübbers committed
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
  </xsl:template>
  
  <xsl:template match="dc:creator">
    <xsl:variable name="fullName" select="concat( pc:person/pc:name/pc:surName, ', ', pc:person/pc:name/pc:foreName )"  />
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.contributor.author'"/>
      <xsl:with-param name="language" select="''"/>
      <xsl:with-param name="value" select="$fullName"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="dc:subject[@xsi:type='dcterms:DDC']">
    <!-- e.g., here text() evaluates to '300, 303, 320, 324' -->
    <xsl:for-each select="tokenize(text(), ', ')" >
          <xsl:call-template name="new-metadatum">
            <xsl:with-param name="key" select="'internal.identifier.ddc'"/>
            <xsl:with-param name="language" select="''"/>
            <xsl:with-param name="value" select="normalize-space(.)"/>
          </xsl:call-template>
    </xsl:for-each>
  </xsl:template>
  
  <xsl:template match="dc:subject[@xsi:type='xMetaDiss:noScheme']">
    <!-- querying for metadataPrefix=oai_dc provides language keys -->
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.subject.other'"/>
      <xsl:with-param name="language" select="''"/>
      <xsl:with-param name="value" select="text()"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="dcterms:abstract">
    <xsl:variable name="language" select="@lang" />
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.description.abstract'"/>
      <xsl:with-param name="language" select="$language"/>
      <xsl:with-param name="value" select="text()"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="dcterms:issued">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.date.issued'"/>
      <xsl:with-param name="language" select="''"/>
      <xsl:with-param name="value" select="substring( text(), 1, 4)"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="dc:identifier[@xsi:type='urn:nbn']">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.identifier.urn'"/>
      <xsl:with-param name="language" select="''"/>
      <xsl:with-param name="value" select="text()"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="dc:language[@xsi:type='dcterms:ISO639-2']">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.language'"/>
      <xsl:with-param name="language" select="''"/>
      <xsl:with-param name="value" select="zoai:sanitizeLanguage( text() )"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="dcterms:isPartOf[@xsi:type='ddb:ZSTitelID']">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.identifier.issn'"/>
      <xsl:with-param name="language" select="''"/>
      <xsl:with-param name="value" select="text()"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="dcterms:isPartOf[@xsi:type='ddb:ZS-Volume']">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.source.volume'"/>
      <xsl:with-param name="language" select="''"/>
      <xsl:with-param name="value" select="text()"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="dcterms:isPartOf[@xsi:type='ddb:ZS-Issue']">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.source.issue'"/>
      <xsl:with-param name="language" select="''"/>
      <xsl:with-param name="value" select="text()"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="ddb:transfer[@ddb:type='dcterms:URI']">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.identifier.uri'"/>
      <xsl:with-param name="language" select="''"/>
      <xsl:with-param name="value" select="text()"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="ddb:identifier[@ddb:type='URL']">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.identifier.url'"/>
      <xsl:with-param name="language" select="''"/>
      <xsl:with-param name="value" select="text()"/>
    </xsl:call-template>
  </xsl:template>
  
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
  
  <xsl:template match="/oai:OAI-PMH/oai:GetRecord/oai:record/oai:header/oai:setSpec">
        <!-- the following rules are based on https://journals.sub.uni-hamburg.de/giga/afsp/about/editorialPolicies#peerReviewProcess -->
        
        <xsl:choose>
          <xsl:when test="text() = 'afsp:RESART'">
            <xsl:call-template name="new-metadatum">
              <xsl:with-param name="key" select="'dc.description.review'"/>
              <xsl:with-param name="language" select="''"/>
              <xsl:with-param name="value" select="'1'"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:call-template name="new-metadatum">
              <xsl:with-param name="key" select="'dc.description.review'"/>
              <xsl:with-param name="language" select="''"/>
              <xsl:with-param name="value" select="'2'"/>
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
  </xsl:template>
  
Gerrit Hübbers's avatar
WIP  
Gerrit Hübbers committed
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
  <xsl:template name="new-metadatum">
    <xsl:param name="key" />
    <xsl:param name="language" />
    <xsl:param name="value" />
   <xsl:element name="metadatum">
     
     <xsl:element name="key">
       <xsl:value-of select="$key" />
     </xsl:element>
     
     <xsl:if test="$language != ''">
       <xsl:variable name="sanitizedLanguage" select="zoai:sanitizeLanguage($language)" />
       
       <xsl:element name="language">
         <xsl:value-of select="$sanitizedLanguage" />
       </xsl:element>
     </xsl:if>
     
     <xsl:element name="value">
       <xsl:value-of select="$value" />
     </xsl:element>
     
    </xsl:element>
  </xsl:template>
  
  <xsl:function name="zoai:sanitizeLanguage">
    <xsl:param name="inputLanguage" />
         <xsl:choose>
           <xsl:when test="$inputLanguage = 'ger'">
             <xsl:value-of select="'de'" />
           </xsl:when>
           <xsl:when test="$inputLanguage = 'eng'">
             <xsl:value-of select="'en'" />
           </xsl:when>
           <xsl:otherwise>
             <xsl:value-of select="$inputLanguage" />
           </xsl:otherwise>
         </xsl:choose>
  </xsl:function>
</xsl:stylesheet>