transform.xslt 17 KB
Newer Older
Silvia Witzig's avatar
Silvia Witzig committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fn="http://www.w3.org/2005/xpath-functions"
                version="2.0"
                xmlns:ns2="http://purl.org/dc/elements/1.1/"
                xmlns:foxml="info:fedora/fedora-system:def/foxml#"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:audit="info:fedora/fedora-system:def/audit#"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
                xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
                xmlns:fedora="info:fedora/fedora-system:def/relations-external#"
                xmlns:fedora-model="info:fedora/fedora-system:def/model#"
Silvia Witzig's avatar
Silvia Witzig committed
15
                xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
16
                xmlns:core="urn:ebu:metadata-schema:ebuCore_2012"
Silvia Witzig's avatar
Silvia Witzig committed
17
                xpath-default-namespace="urn:ebu:metadata-schema:ebuCore_2012">
Silvia Witzig's avatar
Silvia Witzig committed
18
19
20
21
22
23
24
25
26
27

    <xsl:output
            indent="yes"
            method="xml"
    />

    <!--<xsl:template match="/digitalObject/datastream/datastreamVersion/xmlContent/ebuCoreMain/coreMetadata">
        <xsl:copy-of select="."/>
    </xsl:template>-->

28
29
30
31
    <xsl:template match="@*|node()">
        <xsl:apply-templates select="@*|node()"/>
    </xsl:template>

Silvia Witzig's avatar
Silvia Witzig committed
32

33
    <xsl:template match="core:coreMetadata">
Silvia Witzig's avatar
Silvia Witzig committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
        <xsl:element name="record">
            <!--<xsl:apply-templates select="test"/>
            <xsl:apply-templates select="title, ns2:title, alternativeTitle, subject, description, format/essenceLocator, format/medium, type/*, references"/>-->
            <xsl:apply-templates />
        </xsl:element>
    </xsl:template>

    <!-- content of child node is copied to parent node -->
    <xsl:template match="title | format/essenceLocator | format/duration | format/start | language | references | coverage/spatial/location">
        <xsl:element name="{local-name()}">
            <xsl:value-of select="child::*"/>
        </xsl:element>
    </xsl:template>

    <!-- content of typeLabel is transformed to an element name and content of child node is copied to it-->
49
    <xsl:template match="description[@typeLabel] | alternativeTitle[@typeLabel] | subject[@typeLabel] | relation[@typeLabel]">
Silvia Witzig's avatar
Silvia Witzig committed
50
51
52
53
54
55
56
        <xsl:variable name="typeLabel" select="@typeLabel"/>
        <xsl:element name="{$typeLabel}">
            <xsl:value-of select="child::*"/>
        </xsl:element>
    </xsl:template>

    <!-- content of typeLabel is copied as content of the node -->
Jonas Waeber's avatar
Jonas Waeber committed
57
    <xsl:template match="format/medium | format/dataFormat/captioningFormat | type/genre">
Silvia Witzig's avatar
Silvia Witzig committed
58
59
60
61
62
        <xsl:element name="{local-name()}">
            <xsl:value-of select="@typeLabel | @language"/>
        </xsl:element>
    </xsl:template>

Jonas Waeber's avatar
Jonas Waeber committed
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
    <xsl:template match="type/objectType">
        <xsl:element name="objectType">
            <xsl:choose>
                <xsl:when test="matches(@typeLabel,'film','i')">
                    <xsl:text>Film</xsl:text>
                </xsl:when>
                <xsl:when test="matches(@typeLabel,'photograph|foto','i')">
                    <xsl:text>Foto</xsl:text>
                </xsl:when>
                <xsl:when test="matches(@typeLabel,'radio','i')">
                    <xsl:text>Radio</xsl:text>
                </xsl:when>
                <xsl:when test="matches(@typeLabel,'television|tv','i')">
                    <xsl:text>TV</xsl:text>
                </xsl:when>
                <xsl:when test="matches(@typeLabel,'ton|sound','i')">
                    <xsl:text>Ton</xsl:text>
                </xsl:when>
                <xsl:when test="matches(@typeLabel,'video','i')">
                    <xsl:text>Video</xsl:text>
                </xsl:when>
84
85
86
                <xsl:when test="matches(@typeLabel,'tbs','i')">
                    <xsl:text>Tonbildschau</xsl:text>
                </xsl:when>
Jonas Waeber's avatar
Jonas Waeber committed
87
88
89
90
            </xsl:choose>
        </xsl:element>
    </xsl:template>

Silvia Witzig's avatar
Silvia Witzig committed
91
92
    <xsl:template match="identifier">
        <xsl:variable name="typeLabel" select="@typeLabel"/>
93
        <xsl:element name="identifier{$typeLabel}">
Silvia Witzig's avatar
Silvia Witzig committed
94
95
96
97
98
99
100
101
102
103
104
105
            <xsl:value-of select="child::ns2:identifier"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="format/videoFormat | format/imageFormat | format/audioFormat">
        <xsl:variable name="format" select="local-name()"/>
        <xsl:for-each select="technicalAttributeString">
            <xsl:variable name="typeLabel" select="@typeLabel"/>
            <xsl:element name="{$format}{$typeLabel}">
                <xsl:value-of select="."/>
            </xsl:element>
        </xsl:for-each>
106
107
108
109
110
111
112
113
114
115
116
117
        <xsl:for-each select="width | height">
            <xsl:variable name="local" select="local-name()"/>
            <xsl:variable name="unit" select="@unit"/>
            <xsl:element name="{$local}">
                <xsl:value-of select="concat(., ' ', $unit)"/>
            </xsl:element>
        </xsl:for-each>
        <xsl:for-each select="audioTrackConfiguration">
            <xsl:element name="audioTrackConfiguration">
                <xsl:value-of select="@typeLabel"/>
            </xsl:element>
        </xsl:for-each>
Silvia Witzig's avatar
Silvia Witzig committed
118
119
120
121
122
    </xsl:template>

    <xsl:template match="contributor | creator | publisher">
        <xsl:variable name="type" select="local-name()"/>
        <xsl:for-each select=".">
123
            <xsl:variable name="role" select="child::role/@typeLabel[. != '']"/>
Silvia Witzig's avatar
Silvia Witzig committed
124
            <xsl:choose>
125
                <xsl:when test="$role = 'ResponsibleInstitution'"/>
Silvia Witzig's avatar
Silvia Witzig committed
126
                <xsl:when test="$role = 'Producer' or $role = 'Production' or $role = 'Produktion'">
127
128
129
130
131
132
133
134
135
136
137
138
139
                    <xsl:choose>
                        <xsl:when test="child::organisationDetails">
                            <xsl:element name="producerCorporateBodyName">
                                <xsl:value-of select="descendant::organisationName"/>
                            </xsl:element>
                        </xsl:when>
                        <xsl:when test="child::contactDetails">
                            <xsl:element name="producerPersonName">
                                <xsl:value-of select="descendant::name"/>
                            </xsl:element>
                        </xsl:when>
                    </xsl:choose>
                </xsl:when>
Silvia Witzig's avatar
Silvia Witzig committed
140
                <xsl:when test="matches($role, 'Interprètes|^Interprète / Choeur$|^Choeur$|^ Choeur |Ensemble|Chanteurs|Chanteuses|^Interprète / Orchestre$')">
Silvia Witzig's avatar
Silvia Witzig committed
141
142
143
144
145
146
147
148
149
150
                    <xsl:element name="{$type}CorporateBody">
                        <xsl:element name="name">
                            <xsl:value-of select="descendant::name"/>
                        </xsl:element>
                        <xsl:if test="$role">
                            <xsl:element name="role">
                                <xsl:value-of select="$role"/>
                            </xsl:element>
                        </xsl:if>
                    </xsl:element>
Silvia Witzig's avatar
Silvia Witzig committed
151
                </xsl:when>
Silvia Witzig's avatar
Silvia Witzig committed
152
153
154
155
156
157
158
159
160
161
162
163
164
                <!-- To be used for all Tanzarchiv RecordSets where a Kompanie is recorded as Person in the data -->
                <!--<xsl:when test="$role = 'Kompanie / Compagnie'">
                    <xsl:element name="{$type}CorporateBody">
                        <xsl:element name="name">
                            <xsl:value-of select="descendant::name"/>
                        </xsl:element>
                        <xsl:if test="$role">
                            <xsl:element name="role">
                                <xsl:value-of select="$role"/>
                            </xsl:element>
                        </xsl:if>
                    </xsl:element>
                </xsl:when>-->
Silvia Witzig's avatar
Silvia Witzig committed
165
166
167
168
169
                <xsl:when test="child::organisationDetails">
                    <xsl:element name="{$type}CorporateBody">
                        <xsl:element name="name">
                            <xsl:value-of select="descendant::organisationName"/>
                        </xsl:element>
170
                        <xsl:if test="$role">
Silvia Witzig's avatar
Silvia Witzig committed
171
                            <xsl:element name="role">
172
                                <xsl:value-of select="$role"/>
Silvia Witzig's avatar
Silvia Witzig committed
173
174
175
176
177
                            </xsl:element>
                        </xsl:if>
                    </xsl:element>
                </xsl:when>
                <xsl:when test="child::contactDetails">
Silvia Witzig's avatar
Silvia Witzig committed
178
179
180
181
182
183
184
185
186
187
188
                    <xsl:choose>
                        <xsl:when test="matches(descendant::name,'^inconnu$')">
                            <xsl:element name="{$type}Agent">
                                <xsl:element name="name">
                                    <xsl:value-of select="descendant::name"/>
                                </xsl:element>
                                <xsl:if test="$role">
                                    <xsl:element name="role">
                                        <xsl:value-of select="$role"/>
                                    </xsl:element>
                                </xsl:if>
Silvia Witzig's avatar
Silvia Witzig committed
189
                            </xsl:element>
Silvia Witzig's avatar
Silvia Witzig committed
190
                        </xsl:when>
Silvia Witzig's avatar
Silvia Witzig committed
191
                        <xsl:when test="descendant::name != ''">
Silvia Witzig's avatar
Silvia Witzig committed
192
193
194
                            <xsl:element name="{$type}Person">
                                <xsl:element name="name">
                                    <xsl:value-of select="descendant::name"/>
Silvia Witzig's avatar
Silvia Witzig committed
195
                                </xsl:element>
Silvia Witzig's avatar
Silvia Witzig committed
196
197
198
199
200
201
                                <xsl:if test="$role">
                                    <xsl:element name="role">
                                        <xsl:value-of select="$role"/>
                                    </xsl:element>
                                </xsl:if>
                            </xsl:element>
Silvia Witzig's avatar
Silvia Witzig committed
202
203
                        </xsl:when>
                        <xsl:otherwise>
Silvia Witzig's avatar
Silvia Witzig committed
204
205
206
207
                            <xsl:element name="{$type}Person">
                                <xsl:element name="name">
                                    <xsl:value-of select="$role"/>
                                </xsl:element>
Silvia Witzig's avatar
Silvia Witzig committed
208
209
210
                            </xsl:element>
                        </xsl:otherwise>
                    </xsl:choose>
Silvia Witzig's avatar
Silvia Witzig committed
211
212
213
214
215
216
                </xsl:when>
            </xsl:choose>
        </xsl:for-each>
    </xsl:template>

    <xsl:template match="rights[@typeLabel='Access']/ns2:rights">
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
        <xsl:if test="matches(.,'onsite')">
            <xsl:element name="accessPhysical">
                <xsl:text>onsite</xsl:text>
            </xsl:element>
        </xsl:if>
        <xsl:if test="matches(.,'noonsite')">
            <xsl:element name="accessPhysical">
                <xsl:text>noonsite</xsl:text>
            </xsl:element>
        </xsl:if>
        <xsl:if test="matches(.,'public')">
            <xsl:element name="accessDigital">
                <xsl:text>public</xsl:text>
            </xsl:element>
            <xsl:element name="rightsStatementText">
                <xsl:text>Copyright Not Evaluated (CNE)</xsl:text>
            </xsl:element>
            <xsl:element name="rightsStatementURL">
                <xsl:text>http://rightsstatements.org/vocab/CNE/1.0/</xsl:text>
            </xsl:element>
        </xsl:if>
        <xsl:if test="matches(.,'private')">
            <xsl:element name="accessDigital">
                <xsl:text>private</xsl:text>
            </xsl:element>
            <xsl:element name="rightsStatementText">
                <xsl:text>Copyright Not Evaluated (CNE)</xsl:text>
            </xsl:element>
            <xsl:element name="rightsStatementURL">
                <xsl:text>http://rightsstatements.org/vocab/CNE/1.0/</xsl:text>
            </xsl:element>
        </xsl:if>
        <xsl:if test="matches(.,'faro')">
            <xsl:element name="accessDigital">
                <xsl:text>faro</xsl:text>
            </xsl:element>
            <xsl:element name="rightsStatementText">
                <xsl:text>Copyright Not Evaluated (CNE)</xsl:text>
            </xsl:element>
            <xsl:element name="rightsStatementURL">
                <xsl:text>http://rightsstatements.org/vocab/CNE/1.0/</xsl:text>
            </xsl:element>
        </xsl:if>
Silvia Witzig's avatar
Silvia Witzig committed
260
261
    </xsl:template>

Silvia Witzig's avatar
Silvia Witzig committed
262
    <xsl:template match="rights[@typeLabel='Holder']/rightsHolder/contactDetails/name | rights[@typeLabel='Holder']/ns2:rights">
Silvia Witzig's avatar
Silvia Witzig committed
263
264
265
266
267
        <xsl:element name="rightsHolder">
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>

Silvia Witzig's avatar
Silvia Witzig committed
268
269
270
271
272
273
    <xsl:template match="rights[@typeLabel='Usage']/ns2:rights">
        <xsl:element name="rightsUsage">
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>

274
    <xsl:template match="core:coreMetadata/ns2:source">
275
276
277
278
279
        <xsl:element name="source">
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>

280
281
    <xsl:template match="date/created | date/issued | temporal/PeriodOfTime">
        <xsl:variable name="date" select="local-name()"/>
Silvia Witzig's avatar
Silvia Witzig committed
282
        <xsl:for-each select=".">
283
284
285
286
287
288
            <xsl:element name="{$date}Date">
                <xsl:choose>
                    <xsl:when test="descendant::periodName">
                        <xsl:value-of select="descendant::periodName"/>
                    </xsl:when>
                    <xsl:otherwise>
Silvia Witzig's avatar
Silvia Witzig committed
289
                        <xsl:call-template name="dates"/>
290
291
292
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:element>
Silvia Witzig's avatar
Silvia Witzig committed
293
294
295
296
        </xsl:for-each>
    </xsl:template>

    <xsl:template name="dates">
Silvia Witzig's avatar
Silvia Witzig committed
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
            <xsl:variable name="startDate" select="@startDate[. != '']"/>
            <xsl:variable name="startYear" select="@startYear[. != '']"/>
            <xsl:variable name="startTime" select="@startTime[. != '']"/>
            <xsl:variable name="endDate" select="@endDate[. != '']"/>
            <xsl:variable name="endYear" select="@endYear[. != '']"/>
            <xsl:variable name="period" select="@period[. != '']"/>

            <xsl:choose>
                <!-- Combinations which are not present in created/issued/temporal and are not processed:
                     * endYear and startDate
                     * period and endDate and startYear
                     * period and endYear and startDate
                     * startTime in another combination but with startDate
                     * period and endDate only
                -->
                <xsl:when test="$startDate and not($endDate | $endYear | $period | $startTime)">
                    <xsl:value-of select="$startDate"/>
                </xsl:when>
                <xsl:when test="$startYear and not($endDate | $endYear | $period | $startTime)">
                    <xsl:value-of select="$startYear"/>
                </xsl:when>
                <xsl:when test="$startDate and $endDate and not($period | $startTime)">
                    <xsl:value-of select="concat($startDate, '/', $endDate)"/>
                </xsl:when>
                <xsl:when test="$startYear and $endDate and not($period | $startTime)">
                    <xsl:value-of select="concat($startYear, '/', $endDate)"/>
                </xsl:when>
                <xsl:when test="$startYear and $endYear and not($period | $startTime)">
                    <xsl:value-of select="concat($startYear, '/', $endYear)"/>
                </xsl:when>
                <xsl:when test="$startTime">
                    <xsl:value-of select="concat($startDate, 'T', $startTime)"/>
                </xsl:when>
                <xsl:when test="$endDate and not ($startDate | $startYear | $period)">
                    <xsl:value-of select="concat('?/', $endDate)"/>
                </xsl:when>
                <xsl:when test="$endYear and not ($startDate | $startYear | $period)">
                    <xsl:value-of select="concat('?/', $endYear)"/>
                </xsl:when>
                <xsl:when test="$period and not($endDate | $endYear | $startDate | $startYear)">
                    <xsl:value-of select="$period"/>
                </xsl:when>
                <xsl:when test="$period and $startDate and not ($endDate | $endYear)">
                    <xsl:value-of select="concat($period, ' ', $startDate)"/>
                </xsl:when>
                <xsl:when test="$period and $startYear and not ($endDate | $endYear)">
                    <xsl:value-of select="concat($period, ' ', $startYear)"/>
                </xsl:when>
                <xsl:when test="$period and $startDate and $endDate">
                    <xsl:value-of select="concat($period, ' ', $startDate, '/', $endDate)"/>
                </xsl:when>
                <xsl:when test="$period and $startYear and $endYear">
Jonas Waeber's avatar
Jonas Waeber committed
349
350
351
352
353
354
355
356
                    <xsl:choose>
                        <xsl:when test="matches(@period,concat(@startYear, '-', @endYear))">
                            <xsl:value-of select="concat($startYear, '/', $endYear)"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="concat($period, ' ', $startYear, '/', $endYear)"/>
                        </xsl:otherwise>
                    </xsl:choose>
Silvia Witzig's avatar
Silvia Witzig committed
357
358
                </xsl:when>
            </xsl:choose>
Silvia Witzig's avatar
Silvia Witzig committed
359
360
361
    </xsl:template>

    <!-- field to delete -->
Silvia Witzig's avatar
Silvia Witzig committed
362
    <xsl:template match="isMemberOf "/>
Silvia Witzig's avatar
Silvia Witzig committed
363
364
365


</xsl:stylesheet>