transform.xslt 16.1 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
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
                <!-- 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
166
167
168
169
170
                <xsl:when test="child::organisationDetails">
                    <xsl:element name="{$type}CorporateBody">
                        <xsl:element name="name">
                            <xsl:value-of select="descendant::organisationName"/>
                        </xsl:element>
171
                        <xsl:if test="$role">
Silvia Witzig's avatar
Silvia Witzig committed
172
                            <xsl:element name="role">
173
                                <xsl:value-of select="$role"/>
Silvia Witzig's avatar
Silvia Witzig committed
174
175
176
177
178
179
180
                            </xsl:element>
                        </xsl:if>
                    </xsl:element>
                </xsl:when>
                <xsl:when test="child::contactDetails">
                    <xsl:element name="{$type}Person">
                        <xsl:element name="name">
Silvia Witzig's avatar
Silvia Witzig committed
181
182
183
184
185
186
187
188
                            <xsl:choose>
                                <xsl:when test="descendant::name = 'WILLIAM RITTER'">
                                    <xsl:value-of select="'RITTER WILLIAM'"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="descendant::name"/>
                                </xsl:otherwise>
                            </xsl:choose>
Silvia Witzig's avatar
Silvia Witzig committed
189
                        </xsl:element>
190
                        <xsl:if test="$role">
Silvia Witzig's avatar
Silvia Witzig committed
191
                            <xsl:element name="role">
192
                                <xsl:value-of select="$role"/>
Silvia Witzig's avatar
Silvia Witzig committed
193
194
195
196
197
198
199
200
201
                            </xsl:element>
                        </xsl:if>
                    </xsl:element>
                </xsl:when>
            </xsl:choose>
        </xsl:for-each>
    </xsl:template>

    <xsl:template match="rights[@typeLabel='Access']/ns2:rights">
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
        <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
245
246
    </xsl:template>

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

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

259
    <xsl:template match="core:coreMetadata/ns2:source">
260
261
262
263
264
        <xsl:element name="source">
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>

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

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

    <!-- field to delete -->
Silvia Witzig's avatar
Silvia Witzig committed
347
    <xsl:template match="isMemberOf "/>
Silvia Witzig's avatar
Silvia Witzig committed
348
349
350


</xsl:stylesheet>