transform.xslt 15.7 KB
Newer Older
Jonas Waeber's avatar
Jonas Waeber committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?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#"
                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"
Jonas Waeber's avatar
Jonas Waeber committed
17
18
19
20
21
22
23
24
25
26
27
                xpath-default-namespace="urn:ebu:metadata-schema:ebuCore_2012">

    <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>

Jonas Waeber's avatar
Jonas Waeber committed
32

33
    <xsl:template match="core:coreMetadata">
Jonas Waeber's avatar
Jonas Waeber 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-->
Jonas Waeber's avatar
Jonas Waeber committed
49
    <xsl:template match="description[@typeLabel] | alternativeTitle[@typeLabel] | subject[@typeLabel] | relation[@typeLabel]">
Jonas Waeber's avatar
Jonas Waeber 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">
Jonas Waeber's avatar
Jonas Waeber 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>

Jonas Waeber's avatar
Jonas Waeber committed
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
    <xsl:template match="identifier">
        <xsl:variable name="typeLabel" select="@typeLabel"/>
        <xsl:element name="identifier{$typeLabel}">
            <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>
Jonas Waeber's avatar
Jonas Waeber committed
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>
Jonas Waeber's avatar
Jonas Waeber 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=".">
Jonas Waeber's avatar
Jonas Waeber committed
123
            <xsl:variable name="role" select="child::role/@typeLabel[. != '']"/>
Jonas Waeber's avatar
Jonas Waeber committed
124
            <xsl:choose>
Jonas Waeber's avatar
Jonas Waeber committed
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'">
Jonas Waeber's avatar
Jonas Waeber committed
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>-->
Jonas Waeber's avatar
Jonas Waeber 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>
Jonas Waeber's avatar
Jonas Waeber committed
171
                        <xsl:if test="$role">
Jonas Waeber's avatar
Jonas Waeber committed
172
                            <xsl:element name="role">
Jonas Waeber's avatar
Jonas Waeber committed
173
                                <xsl:value-of select="$role"/>
Jonas Waeber's avatar
Jonas Waeber committed
174
175
176
177
178
179
180
181
182
                            </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>
Jonas Waeber's avatar
Jonas Waeber committed
183
                        <xsl:if test="$role">
Jonas Waeber's avatar
Jonas Waeber committed
184
                            <xsl:element name="role">
Jonas Waeber's avatar
Jonas Waeber committed
185
                                <xsl:value-of select="$role"/>
Jonas Waeber's avatar
Jonas Waeber committed
186
187
188
189
190
191
192
193
194
                            </xsl:element>
                        </xsl:if>
                    </xsl:element>
                </xsl:when>
            </xsl:choose>
        </xsl:for-each>
    </xsl:template>

    <xsl:template match="rights[@typeLabel='Access']/ns2:rights">
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
        <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>
Jonas Waeber's avatar
Jonas Waeber committed
238
239
    </xsl:template>

Silvia Witzig's avatar
Silvia Witzig committed
240
    <xsl:template match="rights[@typeLabel='Holder']/rightsHolder/contactDetails/name | rights[@typeLabel='Holder']/ns2:rights">
Jonas Waeber's avatar
Jonas Waeber committed
241
242
243
244
245
        <xsl:element name="rightsHolder">
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>

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

252
    <xsl:template match="core:coreMetadata/ns2:source">
Jonas Waeber's avatar
Jonas Waeber committed
253
254
255
256
257
        <xsl:element name="source">
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>

258
259
    <xsl:template match="date/created | date/issued | temporal/PeriodOfTime">
        <xsl:variable name="date" select="local-name()"/>
Jonas Waeber's avatar
Jonas Waeber committed
260
        <xsl:for-each select=".">
261
262
263
264
265
266
            <xsl:element name="{$date}Date">
                <xsl:choose>
                    <xsl:when test="descendant::periodName">
                        <xsl:value-of select="descendant::periodName"/>
                    </xsl:when>
                    <xsl:otherwise>
Jonas Waeber's avatar
Jonas Waeber committed
267
                        <xsl:call-template name="dates"/>
268
269
270
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:element>
Jonas Waeber's avatar
Jonas Waeber committed
271
272
273
274
        </xsl:for-each>
    </xsl:template>

    <xsl:template name="dates">
Jonas Waeber's avatar
Jonas Waeber committed
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
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">
                    <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>
                </xsl:when>
            </xsl:choose>
Jonas Waeber's avatar
Jonas Waeber committed
337
338
339
    </xsl:template>

    <!-- field to delete -->
Silvia Witzig's avatar
Silvia Witzig committed
340
    <xsl:template match="isMemberOf "/>
Jonas Waeber's avatar
Jonas Waeber committed
341
342
343


</xsl:stylesheet>