transform.xslt 16.3 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
        <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 -->
Silvia Witzig's avatar
Silvia Witzig committed
42
    <xsl:template match="title | format/essenceLocator | format/duration | format/start | language | references">
Silvia Witzig's avatar
Silvia Witzig committed
43
44
45
46
47
        <xsl:element name="{local-name()}">
            <xsl:value-of select="child::*"/>
        </xsl:element>
    </xsl:template>

Silvia Witzig's avatar
Silvia Witzig committed
48
49
50
51
52
53
    <xsl:template match="coverage/spatial/location">
        <xsl:element name="{local-name()}">
            <xsl:value-of select="replace(child::*, '\* ', '')"/>
        </xsl:element>
    </xsl:template>

Silvia Witzig's avatar
Silvia Witzig committed
54
    <!-- content of typeLabel is transformed to an element name and content of child node is copied to it-->
55
    <xsl:template match="description[@typeLabel] | alternativeTitle[@typeLabel] | subject[@typeLabel] | relation[@typeLabel]">
Silvia Witzig's avatar
Silvia Witzig committed
56
57
58
59
60
61
62
        <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
63
    <xsl:template match="format/medium | format/dataFormat/captioningFormat | type/genre">
Silvia Witzig's avatar
Silvia Witzig committed
64
65
66
67
68
        <xsl:element name="{local-name()}">
            <xsl:value-of select="@typeLabel | @language"/>
        </xsl:element>
    </xsl:template>

Jonas Waeber's avatar
Jonas Waeber committed
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
    <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>
90
91
92
                <xsl:when test="matches(@typeLabel,'tbs','i')">
                    <xsl:text>Tonbildschau</xsl:text>
                </xsl:when>
Jonas Waeber's avatar
Jonas Waeber committed
93
94
95
96
            </xsl:choose>
        </xsl:element>
    </xsl:template>

Silvia Witzig's avatar
Silvia Witzig committed
97
98
    <xsl:template match="identifier">
        <xsl:variable name="typeLabel" select="@typeLabel"/>
99
        <xsl:element name="identifier{$typeLabel}">
Silvia Witzig's avatar
Silvia Witzig committed
100
101
102
103
104
105
106
107
108
109
110
111
            <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>
112
113
114
115
116
117
118
119
120
121
122
123
        <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
124
125
126
127
128
    </xsl:template>

    <xsl:template match="contributor | creator | publisher">
        <xsl:variable name="type" select="local-name()"/>
        <xsl:for-each select=".">
129
            <xsl:variable name="role" select="child::role/@typeLabel[. != '']"/>
Silvia Witzig's avatar
Silvia Witzig committed
130
            <xsl:choose>
131
                <xsl:when test="$role = 'ResponsibleInstitution'"/>
Silvia Witzig's avatar
Silvia Witzig committed
132
                <xsl:when test="$role = 'Producer' or $role = 'Production' or $role = 'Produktion'">
133
134
135
136
137
138
139
140
141
142
143
144
145
                    <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
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
                <!-- To be used for all SRF RecordSets where a Redaktion is recorded as Person in the data -->
                <!--<xsl:when test="$role = 'Redaktion'">
                    <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>-->
                <!-- 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
172
173
174
175
176
                <xsl:when test="child::organisationDetails">
                    <xsl:element name="{$type}CorporateBody">
                        <xsl:element name="name">
                            <xsl:value-of select="descendant::organisationName"/>
                        </xsl:element>
177
                        <xsl:if test="$role">
Silvia Witzig's avatar
Silvia Witzig committed
178
                            <xsl:element name="role">
179
                                <xsl:value-of select="$role"/>
Silvia Witzig's avatar
Silvia Witzig committed
180
181
182
183
184
185
186
187
188
                            </xsl:element>
                        </xsl:if>
                    </xsl:element>
                </xsl:when>
                <xsl:when test="child::contactDetails">
                    <xsl:element name="{$type}Person">
                        <xsl:element name="name">
                            <xsl:value-of select="descendant::name"/>
                        </xsl:element>
189
                        <xsl:if test="$role">
Silvia Witzig's avatar
Silvia Witzig committed
190
                            <xsl:element name="role">
191
                                <xsl:value-of select="$role"/>
Silvia Witzig's avatar
Silvia Witzig committed
192
193
194
195
196
197
198
199
200
                            </xsl:element>
                        </xsl:if>
                    </xsl:element>
                </xsl:when>
            </xsl:choose>
        </xsl:for-each>
    </xsl:template>

    <xsl:template match="rights[@typeLabel='Access']/ns2:rights">
Silvia Witzig's avatar
Silvia Witzig committed
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
        <xsl:choose>
            <xsl:when test="matches(.,'noonsite')">
                <xsl:element name="accessPhysical">
                    <xsl:text>noonsite</xsl:text>
                </xsl:element>
            </xsl:when>
            <xsl:otherwise>
                <xsl:if test="matches(.,'onsite')">
                    <xsl:element name="accessPhysical">
                        <xsl:text>onsite</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>
            </xsl:otherwise>
        </xsl:choose>
Silvia Witzig's avatar
Silvia Witzig committed
248
249
    </xsl:template>

Silvia Witzig's avatar
Silvia Witzig committed
250
    <xsl:template match="rights[@typeLabel='Holder']/rightsHolder/contactDetails/name | rights[@typeLabel='Holder']/ns2:rights">
Silvia Witzig's avatar
Silvia Witzig committed
251
252
253
254
255
        <xsl:element name="rightsHolder">
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>

Silvia Witzig's avatar
Silvia Witzig committed
256
257
258
259
260
261
    <xsl:template match="rights[@typeLabel='Usage']/ns2:rights">
        <xsl:element name="rightsUsage">
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>

262
    <xsl:template match="core:coreMetadata/ns2:source">
263
264
265
266
267
        <xsl:element name="source">
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>

268
269
    <xsl:template match="date/created | date/issued | temporal/PeriodOfTime">
        <xsl:variable name="date" select="local-name()"/>
Silvia Witzig's avatar
Silvia Witzig committed
270
        <xsl:for-each select=".">
271
272
273
274
275
276
            <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
277
                        <xsl:call-template name="dates"/>
278
279
280
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:element>
Silvia Witzig's avatar
Silvia Witzig committed
281
282
283
284
        </xsl:for-each>
    </xsl:template>

    <xsl:template name="dates">
Silvia Witzig's avatar
Silvia Witzig committed
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
            <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
337
338
339
340
341
342
343
344
                    <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
345
346
                </xsl:when>
            </xsl:choose>
Silvia Witzig's avatar
Silvia Witzig committed
347
348
349
    </xsl:template>

    <!-- field to delete -->
Silvia Witzig's avatar
Silvia Witzig committed
350
    <xsl:template match="isMemberOf "/>
Silvia Witzig's avatar
Silvia Witzig committed
351
352
353


</xsl:stylesheet>