source: CMDI-Interoperability/PARADISEC/trunk/PARADISECitem2CMDI.xsl

Last change on this file was 3119, checked in by mwindhouwer, 11 years ago

Initial import

File size: 19.0 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
3    xmlns:xs="http://www.w3.org/2001/XMLSchema"
4    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="xs functx"
5    xmlns:cmd="http://www.clarin.eu/cmd/" xmlns:functx="http://www.functx.com">
6
7    <xsl:param name="CMDProfile" select="'clarin.eu:cr1:p_1369752611621'"/>
8    <xsl:param name="CMDCollection" select="'PARADISEC'"/>
9    <xsl:param name="CMDBaseURI" select="'http://www.example.com'"/>
10
11    <xsl:include href="utils.xsl"/>
12
13    <xsl:template match="text()"/>
14
15    <xsl:template match="/item">
16        <cmd:CMD CMDVersion="1.1"
17            xsi:schemaLocation="http://www.clarin.eu/cmd/ http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/{$CMDProfile}/xsd">
18            <cmd:Header>
19                <cmd:MdCreator>
20                    <xsl:value-of
21                        select="replace(replace(base-uri(document('')),'.*/',''),'.xsl','')"/>
22                </cmd:MdCreator>
23                <cmd:MdCreationDate>
24                    <xsl:value-of select="format-date(current-date(),'[Y]-[M01]-[D01]')"/>
25                </cmd:MdCreationDate>
26                <cmd:MdSelfLink>
27                    <xsl:value-of select="cmd:createLink($CMDBaseURI,identifier)"/>
28                </cmd:MdSelfLink>
29                <cmd:MdProfile>
30                    <xsl:value-of select="$CMDProfile"/>
31                </cmd:MdProfile>
32                <cmd:MdCollectionDisplayName>
33                    <xsl:value-of select="$CMDCollection"/>
34                </cmd:MdCollectionDisplayName>
35            </cmd:Header>
36            <cmd:Resources>
37                <cmd:ResourceProxyList>
38                    <xsl:for-each select="files/file">
39                        <cmd:ResourceProxy id="f{name}">
40                            <cmd:ResourceType>Metadata</cmd:ResourceType>
41                            <cmd:ResourceRef>
42                                <xsl:value-of select="cmd:notEmptyValue(/item/archiveLink)"/>
43                                <xsl:text>/</xsl:text>
44                                <xsl:value-of select="cmd:notEmptyValue(name)"/>
45                            </cmd:ResourceRef>
46                        </cmd:ResourceProxy>
47                    </xsl:for-each>
48                </cmd:ResourceProxyList>
49                <cmd:JournalFileProxyList/>
50                <cmd:ResourceRelationList/>
51            </cmd:Resources>
52            <cmd:Components>
53                <cmd:item xmlns:cmd="http://www.clarin.eu/cmd/">
54                    <cmd:itemInfo>
55                        <cmd:identifier>
56                            <xsl:value-of select="cmd:notEmptyValue(identifier)"/>
57                        </cmd:identifier>
58                        <cmd:collectionId>
59                            <xsl:value-of select="cmd:notEmptyValue(collectionId)"/>
60                        </cmd:collectionId>
61                        <xsl:for-each select="title[cmd:exists(.)]">
62                            <cmd:title>
63                                <xsl:value-of select="cmd:notEmptyValue(.)"/>
64                            </cmd:title>
65                        </xsl:for-each>
66                        <xsl:if test="cmd:exists(url)">
67                            <cmd:url>
68                                <xsl:value-of select="cmd:notEmptyValue(url)"/>
69                            </cmd:url>
70                        </xsl:if>
71                        <xsl:for-each select="discourseType[cmd:exists(.)]">
72                            <cmd:discourseType>
73                                <xsl:value-of select="cmd:notEmptyValue(.)"/>
74                            </cmd:discourseType>
75                        </xsl:for-each>
76                        <xsl:if test="cmd:exists(citation)">
77                            <cmd:citation>
78                                <xsl:value-of select="cmd:notEmptyValue(citation)"/>
79                            </cmd:citation>
80                        </xsl:if>
81                        <xsl:if test="cmd:exists(university)">
82                            <cmd:university>
83                                <xsl:value-of select="cmd:notEmptyValue(university)"/>
84                            </cmd:university>
85                        </xsl:if>
86                        <xsl:if test="cmd:exists(description)">
87                            <cmd:Description>
88                                <cmd:Description>
89                                    <xsl:value-of select="cmd:notEmptyValue(description)"/>
90                                </cmd:Description>
91                            </cmd:Description>
92                        </xsl:if>
93                        <cmd:geographicalCoverage>
94                            <xsl:if test="cmd:exists(region)">
95                                <cmd:Region>
96                                    <xsl:value-of select="cmd:notEmptyValue(region)"/>
97                                </cmd:Region>
98                            </xsl:if>
99                            <xsl:for-each select="countries/country[cmd:exists(.)]">
100                                <cmd:Country>
101                                    <cmd:CountryName>
102                                        <xsl:value-of
103                                            select="cmd:notEmptyValue(.,functx:substring-before-last(.,' - '))"
104                                        />
105                                    </cmd:CountryName>
106                                    <cmd:CountryCoding>
107                                        <xsl:value-of
108                                            select="cmd:notEmptyValue(.,functx:substring-after-last(.,' - '))"
109                                        />
110                                    </cmd:CountryCoding>
111                                </cmd:Country>
112                            </xsl:for-each>
113                            <cmd:geographicalLocation>
114                                <cmd:southLimit>
115                                    <xsl:value-of
116                                        select="cmd:notEmptyValue(geographicLocation/south_limit)"/>
117                                </cmd:southLimit>
118                                <cmd:northLimit>
119                                    <xsl:value-of
120                                        select="cmd:notEmptyValue(geographicLocation/north_limit)"/>
121                                </cmd:northLimit>
122                                <cmd:eastLimit>
123                                    <xsl:value-of
124                                        select="cmd:notEmptyValue(geographicLocation/east_limit)"/>
125                                </cmd:eastLimit>
126                                <cmd:westLimit>
127                                    <xsl:value-of
128                                        select="cmd:notEmptyValue(geographicLocation/west_limit)"/>
129                                </cmd:westLimit>
130                            </cmd:geographicalLocation>
131                        </cmd:geographicalCoverage>
132                        <xsl:for-each select="(collector|operator)[cmd:exists(.)]">
133                            <cmd:Creator>
134                                <cmd:Role>
135                                    <xsl:value-of select="name()"/>
136                                </cmd:Role>
137                                <cmd:Contact>
138                                    <cmd:Person>
139                                        <xsl:value-of select="cmd:notEmptyValue(.)"/>
140                                    </cmd:Person>
141                                </cmd:Contact>
142                            </cmd:Creator>
143                        </xsl:for-each>
144                        <cmd:origination>
145                            <cmd:date>
146                                <xsl:value-of select="cmd:notEmptyValue(originationDate)"/>
147                            </cmd:date>
148                            <xsl:if test="cmd:exists(originationNarrative)">
149                                <cmd:narrative>
150                                    <xsl:value-of select="cmd:notEmptyValue(originationNarrative)"/>
151                                </cmd:narrative>
152                            </xsl:if>
153                        </cmd:origination>
154                        <xsl:if test="exists(dataCategory[cmd:exists(.)])">
155                            <cmd:dataCategories>
156                                <xsl:for-each select="dataCategory[cmd:exists(.)]">
157                                    <cmd:dataCategory>
158                                        <xsl:value-of select="cmd:notEmptyValue(.)"/>
159                                    </cmd:dataCategory>
160                                </xsl:for-each>
161                            </cmd:dataCategories>
162                        </xsl:if>
163                        <xsl:if test="exists(agents/agent[cmd:exists(.)])">
164                            <cmd:agents>
165                                <xsl:for-each select="agent[cmd:exists(.)]">
166                                    <cmd:agent role="{@role}">
167                                        <xsl:value-of select="cmd:notEmptyValue(.)"/>
168                                    </cmd:agent>
169                                </xsl:for-each>
170                            </cmd:agents>
171                        </xsl:if>
172                        <cmd:languageInfo>
173                            <xsl:if test="cmd:exists(dialect)">
174                                <cmd:dialect>
175                                    <xsl:value-of select="cmd:notEmptyValue(dialect)"/>
176                                </cmd:dialect>
177                            </xsl:if>
178                            <xsl:if test="cmd:exists(language)">
179                                <cmd:languageAsGiven>
180                                    <xsl:value-of select="cmd:notEmptyValue(language)"/>
181                                </cmd:languageAsGiven>
182                            </xsl:if>
183                            <xsl:if test="exists(subjectLanguages/language[cmd:exists(.)])">
184                                <cmd:subjectLanguages>
185                                    <xsl:for-each select="subjectLanguages/language[cmd:exists(.)]">
186                                        <cmd:Language>
187                                            <cmd:LanguageName>
188                                                <xsl:value-of
189                                                  select="cmd:notEmptyValue(.,functx:substring-before-last(.,' - '))"
190                                                />
191                                            </cmd:LanguageName>
192                                            <cmd:ISO639>
193                                                <cmd:iso-639-3-code>
194                                                  <xsl:value-of
195                                                  select="cmd:notEmptyValue(.,functx:substring-after-last(.,' - '))"
196                                                  />
197                                                </cmd:iso-639-3-code>
198                                            </cmd:ISO639>
199                                        </cmd:Language>
200                                    </xsl:for-each>
201                                </cmd:subjectLanguages>
202                            </xsl:if>
203                            <xsl:if test="exists(contentLanguages/language[cmd:exists(.)])">
204                                <cmd:contentLanguages>
205                                    <xsl:for-each select="contentLanguages/language[cmd:exists(.)]">
206                                        <cmd:Language>
207                                            <cmd:LanguageName>
208                                                <xsl:value-of
209                                                  select="cmd:notEmptyValue(.,functx:substring-before-last(.,' - '))"
210                                                />
211                                            </cmd:LanguageName>
212                                            <cmd:ISO639>
213                                                <cmd:iso-639-3-code>
214                                                  <xsl:value-of
215                                                  select="cmd:notEmptyValue(.,functx:substring-after-last(.,' - '))"
216                                                  />
217                                                </cmd:iso-639-3-code>
218                                            </cmd:ISO639>
219                                        </cmd:Language>
220                                    </xsl:for-each>
221                                </cmd:contentLanguages>
222                            </xsl:if>
223                        </cmd:languageInfo>
224                    </cmd:itemInfo>
225                    <cmd:files>
226                        <xsl:apply-templates select="files/file"/>
227                    </cmd:files>
228                    <xsl:apply-templates select="archiveInfo"/>
229                    <xsl:apply-templates select="adminInfo"/>
230                </cmd:item>
231            </cmd:Components>
232        </cmd:CMD>
233    </xsl:template>
234
235    <xsl:template match="file">
236        <cmd:fileInfo ref="f{cmd:notEmptyValue(name)}">
237            <cmd:name>
238                <xsl:value-of select="cmd:notEmptyValue(name)"/>
239            </cmd:name>
240            <cmd:fileSize
241                unit="{cmd:notEmptyValue(fileSize,functx:substring-after-last(fileSize,' '))}">
242                <xsl:value-of
243                    select="cmd:notEmptyValue(fileSize,functx:substring-before-last(fileSize,' '))"
244                />
245            </cmd:fileSize>
246            <xsl:if test="cmd:exists(duration)">
247                <cmd:duration>
248                    <xsl:value-of select="cmd:notEmptyValue(duration)"/>
249                </cmd:duration>
250            </xsl:if>
251            <xsl:if test="cmd:exists(bitrate)">
252                <cmd:bitRate
253                    unit="{cmd:notEmptyValue(bitrate,functx:substring-after-last(bitrate,' '))}">
254                    <xsl:value-of
255                        select="cmd:notEmptyValue(bitrate,functx:substring-before-last(bitrate,' '))"
256                    />
257                </cmd:bitRate>
258            </xsl:if>
259            <xsl:if test="cmd:exists(sampleRate)">
260                <cmd:sampleRate
261                    unit="{cmd:notEmptyValue(sampleRate,functx:substring-after-last(sampleRate,' '))}">
262                    <xsl:value-of
263                        select="cmd:notEmptyValue(sampleRate,functx:substring-before-last(sampleRate,' '))"
264                    />
265                </cmd:sampleRate>
266            </xsl:if>
267            <xsl:if test="cmd:exists(channels)">
268                <cmd:channels>
269                    <xsl:value-of select="cmd:notEmptyValue(channels)"/>
270                </cmd:channels>
271            </xsl:if>
272            <xsl:if test="cmd:exists(frameRate)">
273                <cmd:frameRate
274                    unit="{cmd:notEmptyValue(frameRate,functx:substring-after-last(frameRate,' '))}">
275                    <xsl:value-of
276                        select="cmd:notEmptyValue(frameRate,functx:substring-before-last(frameRate,' '))"
277                    />
278                </cmd:frameRate>
279            </xsl:if>
280            <cmd:MimeType>
281                <cmd:MimeType>
282                    <xsl:value-of select="cmd:notEmptyValue(mimeType)"/>
283                </cmd:MimeType>
284            </cmd:MimeType>
285        </cmd:fileInfo>
286    </xsl:template>
287
288    <xsl:template match="archiveInfo">
289        <cmd:archiveInfo>
290            <cmd:bornDigital>
291                <xsl:value-of select="cmd:notEmptyValue(bornDigital)"/>
292            </cmd:bornDigital>
293            <cmd:tapesReturned>
294                <xsl:value-of select="cmd:notEmptyValue(tapesReturned)"/>
295            </cmd:tapesReturned>
296            <xsl:if test="cmd:exists(originalMedia)">
297                <cmd:originalMedia>
298                    <xsl:value-of select="cmd:notEmptyValue(originalMedia)"/>
299                </cmd:originalMedia>
300            </xsl:if>
301            <xsl:if test="cmd:exists(dateReceived)">
302                <cmd:dateReceived>
303                    <xsl:value-of select="cmd:ISODateTime(cmd:notEmptyValue(dateReceived))"/>
304                </cmd:dateReceived>
305            </xsl:if>
306            <xsl:if test="cmd:exists(dateDigitised)">
307                <cmd:dateDigitised>
308                    <xsl:value-of select="cmd:ISODateTime(cmd:notEmptyValue(dateDigitised))"/>
309                </cmd:dateDigitised>
310            </xsl:if>
311            <xsl:if test="cmd:exists(ingestNotes)">
312                <cmd:ingestNotes>
313                    <xsl:value-of select="cmd:notEmptyValue(ingestNotes)"/>
314                </cmd:ingestNotes>
315            </xsl:if>
316            <xsl:if test="cmd:exists(metadataImportedOn)">
317                <cmd:metadataImportedOn>
318                    <xsl:value-of select="cmd:ISODateTime(cmd:notEmptyValue(metadataImportedOn))"/>
319                </cmd:metadataImportedOn>
320            </xsl:if>
321            <xsl:if test="cmd:exists(metadataExportedOn)">
322                <cmd:metadataExportedOn>
323                    <xsl:value-of select="cmd:ISODateTime(cmd:notEmptyValue(metadataExportedOn))"/>
324                </cmd:metadataExportedOn>
325            </xsl:if>
326            <xsl:if test="cmd:exists(tracking)">
327                <cmd:tracking>
328                    <xsl:value-of select="cmd:notEmptyValue(tracking)"/>
329                </cmd:tracking>
330            </xsl:if>
331        </cmd:archiveInfo>
332    </xsl:template>
333
334    <xsl:template match="adminInfo">
335        <cmd:adminInfo>
336            <xsl:if test="cmd:exists(dataAccessConditions)">
337                <cmd:dataAccess>
338                    <cmd:conditions>
339                        <xsl:value-of select="cmd:notEmptyValue(dataAccessConditions)"/>
340                    </cmd:conditions>
341                    <xsl:if test="cmd:exists(dataAccessNarrative)">
342                        <cmd:narrative>
343                            <xsl:value-of select="cmd:notEmptyValue(dataAccessNarrative)"/>
344                        </cmd:narrative>
345                    </xsl:if>
346                </cmd:dataAccess>
347            </xsl:if>
348            <cmd:record>
349                <cmd:created>
350                    <xsl:value-of select="cmd:ISODateTime(cmd:notEmptyValue(recordCreated))"/>
351                </cmd:created>
352                <cmd:lastModified>
353                    <xsl:value-of select="cmd:ISODateTime(cmd:notEmptyValue(recordLastModified))"/>
354                </cmd:lastModified>
355            </cmd:record>
356            <xsl:if test="exists((adminComment|adminAccess/userName)[cmd:exists(.)])">
357                <cmd:admin>
358                    <xsl:if test="cmd:exists(adminComment)">
359                        <cmd:comment>
360                            <xsl:value-of select="cmd:notEmptyValue(adminComment)"/>
361                        </cmd:comment>
362                    </xsl:if>
363                    <xsl:if test="exists(adminAccess/userName[cmd:exists(.)])">
364                        <cmd:access>
365                            <xsl:for-each select="adminAccess/userName[cmd:exists(.)]">
366                                <cmd:userName>
367                                    <xsl:value-of select="cmd:notEmptyValue(.)"/>
368                                </cmd:userName>
369                            </xsl:for-each>
370                        </cmd:access>
371                    </xsl:if>
372                </cmd:admin>
373            </xsl:if>
374        </cmd:adminInfo>
375    </xsl:template>
376
377</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.