1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | <xsl:stylesheet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
---|
3 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" |
---|
4 | xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" |
---|
5 | xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" |
---|
6 | xmlns:defns="http://www.openarchives.org/OAI/2.0/" |
---|
7 | xmlns:olac="http://www.language-archives.org/OLAC/1.0/" |
---|
8 | xmlns:olac11="http://www.language-archives.org/OLAC/1.1/" |
---|
9 | xsi:schemaLocation=" http://purl.org/dc/elements/1.1/ http://www.language-archives.org/OLAC/1.0/dc.xsd http://purl.org/dc/terms/ http://www.language-archives.org/OLAC/1.0/dcterms.xsd http://www.language-archives.org/OLAC/1.0/ http://www.language-archives.org/OLAC/1.0/olac.xsd http://www.language-archives.org/OLAC/1.0/third-party/software.xsd "> |
---|
10 | |
---|
11 | <!-- run on ubtunu with: saxonb-xslt -ext:on -it main ~/svn/clarin/metadata/trunk/toolkit/xslt/olac2cmdi.xsl --> |
---|
12 | |
---|
13 | <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> |
---|
14 | |
---|
15 | <xsl:template match="/"> |
---|
16 | <CMD |
---|
17 | xsi:schemaLocation="http://www.clarin.eu/cmd http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/clarin.eu:cr1:p_1288172614026/xsd"> |
---|
18 | <Header> |
---|
19 | <MdCreator>olac2cmdi.xsl</MdCreator> |
---|
20 | <MdCreationDate> |
---|
21 | <xsl:variable name="date"> |
---|
22 | <xsl:value-of select="//defns:datestamp"/> |
---|
23 | </xsl:variable> |
---|
24 | <xsl:choose> |
---|
25 | <xsl:when test="contains($date,'T')"> |
---|
26 | <xsl:value-of select="substring-before($date,'T')"/> |
---|
27 | </xsl:when> |
---|
28 | <xsl:otherwise> |
---|
29 | <xsl:value-of select="$date"/> |
---|
30 | </xsl:otherwise> |
---|
31 | </xsl:choose> |
---|
32 | </MdCreationDate> |
---|
33 | <MdSelfLink> |
---|
34 | <xsl:value-of select="//defns:identifier"/> |
---|
35 | </MdSelfLink> |
---|
36 | <MdProfile>clarin.eu:cr1:p_1288172614026</MdProfile> |
---|
37 | </Header> |
---|
38 | <Resources> |
---|
39 | <ResourceProxyList/> |
---|
40 | <JournalFileProxyList/> |
---|
41 | <ResourceRelationList/> |
---|
42 | </Resources> |
---|
43 | <Components> |
---|
44 | <OLAC-DcmiTerms> |
---|
45 | |
---|
46 | <xsl:apply-templates select="//dcterms:abstract"/> |
---|
47 | <xsl:apply-templates select="//dcterms:accessRights"/> |
---|
48 | <xsl:apply-templates select="//dcterms:accrualMethod"/> |
---|
49 | <xsl:apply-templates select="//dcterms:accrualPeriodicity"/> |
---|
50 | <xsl:apply-templates select="//dcterms:accrualPolicy"/> |
---|
51 | <xsl:apply-templates select="//dcterms:alternative"/> |
---|
52 | <xsl:apply-templates select="//dcterms:audience"/> |
---|
53 | <xsl:apply-templates select="//dcterms:available"/> |
---|
54 | <xsl:apply-templates select="//dcterms:bibliographicCitation"/> |
---|
55 | <xsl:apply-templates select="//dcterms:conformsTo"/> |
---|
56 | |
---|
57 | <xsl:apply-templates select="//dc:contributor"/> |
---|
58 | <xsl:apply-templates select="//dc:coverage"/> |
---|
59 | |
---|
60 | <xsl:apply-templates select="//dcterms:created"/> |
---|
61 | |
---|
62 | <xsl:apply-templates select="//dc:creator"/> |
---|
63 | <xsl:apply-templates select="//dc:date"/> |
---|
64 | |
---|
65 | <xsl:apply-templates select="//dcterms:dateAccepted"/> |
---|
66 | <xsl:apply-templates select="//dcterms:dateCopyrighted"/> |
---|
67 | <xsl:apply-templates select="//dcterms:dateSubmitted"/> |
---|
68 | |
---|
69 | <xsl:apply-templates select="//dc:description"/> |
---|
70 | |
---|
71 | <xsl:apply-templates select="//dcterms:educationLevel"/> |
---|
72 | <xsl:apply-templates select="//dcterms:extent"/> |
---|
73 | |
---|
74 | <xsl:apply-templates select="//dc:format"/> |
---|
75 | |
---|
76 | <xsl:apply-templates select="//dcterms:hasFormat"/> |
---|
77 | <xsl:apply-templates select="//dcterms:hasPart"/> |
---|
78 | <xsl:apply-templates select="//dcterms:hasVersion"/> |
---|
79 | |
---|
80 | <xsl:apply-templates select="//dc:identifier"/> |
---|
81 | |
---|
82 | <xsl:apply-templates select="//dc:instructionalMethod"/> |
---|
83 | |
---|
84 | <xsl:apply-templates select="//dcterms:isFormatOf"/> |
---|
85 | <xsl:apply-templates select="//dcterms:isPartOf"/> |
---|
86 | <xsl:apply-templates select="//dcterms:isReferencedBy"/> |
---|
87 | <xsl:apply-templates select="//dcterms:isReplacedBy"/> |
---|
88 | <xsl:apply-templates select="//dcterms:isRequiredBy"/> |
---|
89 | <xsl:apply-templates select="//dcterms:issued"/> |
---|
90 | <xsl:apply-templates select="//dcterms:isVersionOf"/> |
---|
91 | |
---|
92 | <xsl:apply-templates select="//dc:language"/> |
---|
93 | |
---|
94 | <xsl:apply-templates select="//dcterms:license"/> |
---|
95 | <xsl:apply-templates select="//dcterms:mediator"/> |
---|
96 | <xsl:apply-templates select="//dcterms:medium"/> |
---|
97 | <xsl:apply-templates select="//dcterms:modified"/> |
---|
98 | <xsl:apply-templates select="//dcterms:provenance"/> |
---|
99 | |
---|
100 | <xsl:apply-templates select="//dc:publisher"/> |
---|
101 | |
---|
102 | <xsl:apply-templates select="//dcterms:references"/> |
---|
103 | |
---|
104 | <xsl:apply-templates select="//dc:relation"/> |
---|
105 | |
---|
106 | <xsl:apply-templates select="//dcterms:replaces"/> |
---|
107 | <xsl:apply-templates select="//dcterms:requires"/> |
---|
108 | |
---|
109 | <xsl:apply-templates select="//dc:rights"/> |
---|
110 | |
---|
111 | <xsl:apply-templates select="//dcterms:rightsHolder"/> |
---|
112 | |
---|
113 | <xsl:apply-templates select="//dc:source"/> |
---|
114 | |
---|
115 | <xsl:apply-templates select="//dcterms:spatial"/> |
---|
116 | |
---|
117 | <xsl:apply-templates select="//dc:subject"/> |
---|
118 | |
---|
119 | <xsl:apply-templates select="//dcterms:tableOfContents"/> |
---|
120 | <xsl:apply-templates select="//dcterms:temporal"/> |
---|
121 | |
---|
122 | <xsl:apply-templates select="//dc:title"/> |
---|
123 | <xsl:apply-templates select="//dc:type"/> |
---|
124 | |
---|
125 | <xsl:apply-templates select="//dcterms:valid"/> |
---|
126 | |
---|
127 | </OLAC-DcmiTerms> |
---|
128 | </Components> |
---|
129 | </CMD> |
---|
130 | </xsl:template> |
---|
131 | |
---|
132 | <xsl:template match="dc:contributor"> |
---|
133 | <contributor> |
---|
134 | <xsl:if test="@xsi:type='olac:role'"> |
---|
135 | <xsl:attribute name="olac-role"> |
---|
136 | <!-- note: namespace wildcard necessary to match with both OLAC 1.0 and 1.1 --> |
---|
137 | <xsl:value-of select="@*:code"/> |
---|
138 | </xsl:attribute> |
---|
139 | </xsl:if> |
---|
140 | <xsl:value-of select="."/> |
---|
141 | </contributor> |
---|
142 | </xsl:template> |
---|
143 | |
---|
144 | <xsl:template match="dc:description"> |
---|
145 | <description> |
---|
146 | <xsl:apply-templates select="./@xml:lang"/> |
---|
147 | <xsl:apply-templates select="@xsi:type"/> |
---|
148 | <xsl:value-of select="."/> |
---|
149 | </description> |
---|
150 | </xsl:template> |
---|
151 | |
---|
152 | <xsl:template match="dc:language[@xsi:type='olac:language']" priority="3"> |
---|
153 | <language> |
---|
154 | <xsl:attribute name="olac-language"> |
---|
155 | <xsl:value-of select="@*:code"/> |
---|
156 | </xsl:attribute> |
---|
157 | </language> |
---|
158 | </xsl:template> |
---|
159 | |
---|
160 | <xsl:template match="dc:subject[@xsi:type='olac:language']" priority="3"> |
---|
161 | <subject> |
---|
162 | <xsl:attribute name="olac-language"> |
---|
163 | <xsl:value-of select="@*:code"/> |
---|
164 | </xsl:attribute> |
---|
165 | </subject> |
---|
166 | </xsl:template> |
---|
167 | |
---|
168 | <xsl:template match="//dc:subject[@xsi:type='olac:linguistic-field']" priority="3"> |
---|
169 | <subject> |
---|
170 | <xsl:attribute name="olac-linguistic-field"> |
---|
171 | <xsl:value-of select="@*:code"/> |
---|
172 | </xsl:attribute> |
---|
173 | </subject> |
---|
174 | </xsl:template> |
---|
175 | |
---|
176 | <xsl:template match="//dc:subject[@xsi:type='olac:discourse-type']" priority="3"> |
---|
177 | <subject> |
---|
178 | <xsl:attribute name="olac-discourse-type"> |
---|
179 | <xsl:value-of select="@*:code"/> |
---|
180 | </xsl:attribute> |
---|
181 | </subject> |
---|
182 | </xsl:template> |
---|
183 | |
---|
184 | |
---|
185 | <xsl:template match="//dc:subject" priority="1"> |
---|
186 | <subject> |
---|
187 | <xsl:apply-templates select="./@xml:lang"/> |
---|
188 | <xsl:apply-templates select="@xsi:type"/> |
---|
189 | <xsl:value-of select="."/> |
---|
190 | </subject> |
---|
191 | </xsl:template> |
---|
192 | |
---|
193 | |
---|
194 | <xsl:template match="//dc:title"> |
---|
195 | <title> |
---|
196 | <xsl:apply-templates select="./@xml:lang"/> |
---|
197 | <xsl:apply-templates select="@xsi:type"/> |
---|
198 | <xsl:value-of select="."/> |
---|
199 | </title> |
---|
200 | </xsl:template> |
---|
201 | |
---|
202 | |
---|
203 | <xsl:template match="//dc:type[@xsi:type='olac:discourse-type']" priority="2"> |
---|
204 | <type> |
---|
205 | <xsl:attribute name="olac-discourse-type"> |
---|
206 | <xsl:value-of select="@*:code"/> |
---|
207 | </xsl:attribute> |
---|
208 | </type> |
---|
209 | </xsl:template> |
---|
210 | |
---|
211 | |
---|
212 | <xsl:template match="//dc:type[@xsi:type='olac:linguistic-type']" priority="2"> |
---|
213 | <type> |
---|
214 | <xsl:attribute name="olac-linguistic-type"> |
---|
215 | <xsl:value-of select="@*:code"/> |
---|
216 | </xsl:attribute> |
---|
217 | </type> |
---|
218 | </xsl:template> |
---|
219 | |
---|
220 | |
---|
221 | <xsl:template match="//dc:type" priority="1"> |
---|
222 | <type> |
---|
223 | <xsl:apply-templates select="@xsi:type"/> |
---|
224 | <xsl:value-of select="."/> |
---|
225 | </type> |
---|
226 | </xsl:template> |
---|
227 | |
---|
228 | <xsl:template match="@xml:lang"> |
---|
229 | <xsl:attribute name="xml:lang"> |
---|
230 | <xsl:value-of select="."/> |
---|
231 | </xsl:attribute> |
---|
232 | </xsl:template> |
---|
233 | |
---|
234 | <xsl:template match="@xsi:type"> |
---|
235 | <xsl:variable name="attval"> |
---|
236 | <xsl:value-of select="."/> |
---|
237 | </xsl:variable> |
---|
238 | <xsl:if test="contains($attval, 'dcterms:')"> |
---|
239 | <xsl:variable name="attclean"> |
---|
240 | <xsl:value-of select="replace($attval, 'dcterms:','')"/> |
---|
241 | </xsl:variable> |
---|
242 | <xsl:attribute name="dcterms-type"> |
---|
243 | <xsl:value-of select="$attclean"/> |
---|
244 | </xsl:attribute> |
---|
245 | </xsl:if> |
---|
246 | </xsl:template> |
---|
247 | |
---|
248 | <!-- general DC template --> |
---|
249 | <xsl:template match="dc:*"> |
---|
250 | <xsl:variable name="tagname"> |
---|
251 | <xsl:value-of select="local-name()"/> |
---|
252 | </xsl:variable> |
---|
253 | <xsl:element name="{$tagname}"> |
---|
254 | <xsl:apply-templates select="@xsi:type"/> |
---|
255 | <xsl:value-of select="."/> |
---|
256 | </xsl:element> |
---|
257 | </xsl:template> |
---|
258 | |
---|
259 | <!-- general DC terms template --> |
---|
260 | <xsl:template match="dcterms:*"> |
---|
261 | <xsl:variable name="tagname"> |
---|
262 | <xsl:value-of select="local-name()"/> |
---|
263 | </xsl:variable> |
---|
264 | |
---|
265 | <xsl:element name="{$tagname}"> |
---|
266 | <xsl:apply-templates select="@xsi:type"/> |
---|
267 | <xsl:value-of select="."/> |
---|
268 | </xsl:element> |
---|
269 | </xsl:template> |
---|
270 | |
---|
271 | |
---|
272 | |
---|
273 | <xsl:template name="main"> |
---|
274 | <xsl:for-each |
---|
275 | select="collection('file:////home/dietuyt/olac?select=*.xml;recurse=yes;on-error=ignore')"> |
---|
276 | <xsl:result-document href="{document-uri(.)}.cmdi"> |
---|
277 | <xsl:apply-templates select="."/> |
---|
278 | </xsl:result-document> |
---|
279 | </xsl:for-each> |
---|
280 | </xsl:template> |
---|
281 | |
---|
282 | |
---|
283 | </xsl:stylesheet> |
---|