giga-2-xmlbundle.xslt 13.9 KB
Newer Older
Steinberg, Jan's avatar
Steinberg, Jan committed
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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
 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:ddb="http://www.d-nb.de/standards/ddb/"
 xmlns:dini="http://www.d-nb.de/standards/xmetadissplus/type/"
 xmlns:doi="http://www.d-nb.de/standards/doi/"
 xmlns:hdl="http://www.d-nb.de/standards/hdl/"
 xmlns:mml="http://www.w3.org/1998/Math/MathML"
 xmlns:nlm="http://dtd.nlm.nih.gov/publishing/2.3"
 xmlns:oai="http://www.openarchives.org/OAI/2.0/"
 xmlns:oai_marc="http://www.openarchives.org/OAI/1.1/oai_marc"
 xmlns:pc="http://www.d-nb.de/standards/pc/"
 xmlns:thesis="http://www.ndltd.org/standards/metadata/etdms/1.0/"
 xmlns:urn="http://www.d-nb.de/standards/urn/"
 xmlns:xlink="http://www.w3.org/1999/xlink"
 xmlns:xMetaDiss="http://www.d-nb.de/standards/xmetadissplus/"
 xmlns:xoai="http://www.lyncode.com/xoai"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
 
  <xsl:output indent="yes" exclude-result-prefixes="#all"/>
  <xsl:strip-space elements="*"/>
  <!-- <xsl:message terminate="no">here is the tree at the current node <xsl:copy-of select="."/>  </xsl:message> -->
  <!-- <xsl:message terminate="no">here is some message for stderr, e.g. <xsl:value-of select='text()' /> </xsl:message> -->
  <!-- 
       <xsl:for-each select="./*">
         <xsl:message terminate="no">a child=<xsl:value-of select="name()"/></xsl:message>
       </xsl:for-each>
     -->
  
  <!-- override default template -->
  <xsl:template match="*" />
  
  <xsl:template match="/article">
    <xsl:element name="bundles">
    <xsl:element name="bundle">
      <xsl:element name="metadata">
        <xsl:variable name="ddaReference" select="concat(front/journal-meta/journal-id[@journal-id-type='publisher-id'], '@@', front/article-meta/article-id[@pub-id-type='publisher-id'])" />
          <xsl:call-template name="new-metadatum">
              <xsl:with-param name="key" select="'internal.dda.reference'"/>
              <xsl:with-param name="language" select="''"/>
              <xsl:with-param name="value" select="$ddaReference"/>
          </xsl:call-template>
        
        <xsl:apply-templates select="front/journal-meta" />
        <xsl:apply-templates select="front/article-meta" />
        
        <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.language'"/>
          <xsl:with-param name="language" select="''"/>
          <xsl:with-param name="value" select="'en'"/>
        </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.rights.licence'"/>
          <xsl:with-param name="language" select="''"/>
          <xsl:with-param name="value" select="'2'"/>
        </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>
        
        <xsl:call-template name="new-metadatum">
          <xsl:with-param name="key" select="'dc.publisher.country'"/>
          <xsl:with-param name="language" select="''"/>
          <xsl:with-param name="value" select="'DEU'"/>
        </xsl:call-template>
        
        <xsl:call-template name="new-metadatum">
          <xsl:with-param name="key" select="'ssoar.urn.registration'"/>
          <xsl:with-param name="language" select="''"/>
          <xsl:with-param name="value" select="'false'"/>
        </xsl:call-template>
        
        <xsl:call-template name="new-metadatum">
          <xsl:with-param name="key" select="'internal.status'"/>
          <xsl:with-param name="language" select="''"/>
          <xsl:with-param name="value" select="'formal und inhaltlich fertig erschlossen'"/>
        </xsl:call-template>
        <xsl:choose>
          <xsl:when test="/article/@article-type ='research-article'">
            <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:element>
    </xsl:element>
    <xsl:element name="bundle">
      <xsl:element name="metadata">
        <xsl:variable name="ddaReference" select="concat(front/journal-meta/journal-id[@journal-id-type='publisher-id'], '@@', front/article-meta/article-id[@pub-id-type='publisher-id'])" />
        <xsl:call-template name="new-metadatum">
          <xsl:with-param name="key" select="'internal.dda.reference'"/>
          <xsl:with-param name="language" select="''"/>
          <xsl:with-param name="value" select="$ddaReference"/>
        </xsl:call-template>
      </xsl:element>
    </xsl:element>
  </xsl:element>
  </xsl:template>
  
  <xsl:template match="front/journal-meta">
    <xsl:apply-templates select="journal-title-group/journal-title"/>
  </xsl:template>
  
  <xsl:template match="front/article-meta">
    <xsl:apply-templates select="article-id[@pub-id-type='doi']"/>
    <xsl:apply-templates select="title-group/article-title"/>
    <xsl:apply-templates select="title-group/trans-title-group/trans-title"/>
    <xsl:apply-templates select="contrib-group/contrib[@contrib-type='author']"/>
    <xsl:apply-templates select="abstract"/>
    <xsl:apply-templates select="trans-abstract"/>
    <xsl:apply-templates select="kwd-group[@xml:lang='de']/kwd"/>
    <xsl:apply-templates select="kwd-group[@xml:lang!='de']/kwd"/>
    <xsl:apply-templates select="volume"/>
    <xsl:apply-templates select="issue"/>
    <xsl:apply-templates select="fpage"/>
    <xsl:apply-templates select="pub-date[@pub-type='epub-ppub']"/>
  </xsl:template>
    
  <xsl:template match="article-id[@pub-id-type='doi']">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.identifier.doi'"/>
      <xsl:with-param name="language" select="''"/>
      <xsl:with-param name="value" select="concat('https://doi.org/', text())"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="title-group/article-title">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.title'"/>
      <xsl:with-param name="language" select="'en'"/>
      <xsl:with-param name="value" select="normalize-space(text())"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="title-group/trans-title-group/trans-title">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.title.alternative'"/>
      <xsl:with-param name="language" select="../@xml:lang"/>
      <xsl:with-param name="value" select="normalize-space(text())"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="contrib-group/contrib[@contrib-type='author']">
    <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="concat(name/surname, ', ', name/given-names)"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="abstract">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.description.abstract'"/>
      <xsl:with-param name="language" select="'en'"/>
      <xsl:with-param name="value" select="normalize-space(.)"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="trans-abstract">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.description.abstract'"/>
      <xsl:with-param name="language" select="@xml:lang"/>
      <xsl:with-param name="value" select="normalize-space(.)"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="kwd-group[@xml:lang='de']/kwd">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.subject.other'"/>
      <xsl:with-param name="language" select="'de'"/>
      <xsl:with-param name="value" select="text()"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="kwd-group[@xml:lang!='de']/kwd">
    <xsl:choose>
    <xsl:when test="../kwd-group[@xml:lang='de']/kwd">
      <xsl:call-template name="new-metadatum">
        <xsl:with-param name="key" select="'dc.subject.other'"/>
        <xsl:with-param name="language" select="'de'"/>
        <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.subject.other'"/>
          <xsl:with-param name="language" select="'en'"/>
          <xsl:with-param name="value" select="text()"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template match="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="."/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="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="."/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="fpage">
    <xsl:call-template name="new-metadatum">
      <xsl:with-param name="key" select="'dc.source.pageinfo'"/>
      <xsl:with-param name="language" select="''"/>
      <xsl:with-param name="value" select="concat(., '-', ../lpage)"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="pub-date[@pub-type='epub-ppub']">
    <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="year/text()"/>
    </xsl:call-template>
  </xsl:template>
  
    
  <xsl:template match="journal-title-group/journal-title">
    <xsl:choose>
      <xsl:when test="text() = 'Africa Spectrum'">
        <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="'10'"/>
        </xsl:call-template>
        <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="'1868-6869'"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="text() = 'Journal of Current Chinese Affairs'">
        <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="'192'"/>
        </xsl:call-template>
        <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="'1868-4874'"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="text() = 'Journal of Politics in Latin America'">
        <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="'202'"/>
        </xsl:call-template>
        <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="'1868-4890'"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="text() = 'Journal of Current Southeast Asian Affairs'">
        <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="'193'"/>
        </xsl:call-template>
        <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="'1868-4882'"/>
        </xsl:call-template>
      </xsl:when>
    </xsl:choose>  
  </xsl:template>
    
  <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:element name="language">
       <xsl:value-of select="$language" />
     </xsl:element>
     
     <xsl:element name="value">
       <xsl:value-of select="$value" />
     </xsl:element>
     
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>