Merge branch 'master' of ssh://git.indexdata.com:222/home/git/pub/pazpar2
[pazpar2-moved-to-github.git] / etc / tmarc.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0"
3   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pz="http://www.indexdata.com/pazpar2/1.0"
4   xmlns:tmarc="http://www.indexdata.com/turbomarc">
5
6   <xsl:output indent="yes" method="xml" version="1.0"
7     encoding="UTF-8" />
8   <xsl:param name="medium"/>
9
10   <!-- Extract metadata from MARC21/USMARC from streamlined marcxml format 
11     http://www.loc.gov/marc/bibliographic/ecbdhome.html -->
12   <xsl:template name="record-hook" />
13
14
15   <xsl:template match="/">
16       <xsl:apply-templates />
17   </xsl:template>
18
19   <xsl:template match="tmarc:collection">
20     <collection>
21       <xsl:apply-templates />
22     </collection>
23   </xsl:template>
24
25   <xsl:template match="tmarc:r">
26     <xsl:variable name="title_medium" select="tmarc:d245/tmarc:sh" />
27     <xsl:variable name="journal_title" select="tmarc:d773/tmarc:st" />
28     <xsl:variable name="electronic_location_url" select="tmarc:d856/tmarc:su" />
29     <xsl:variable name="fulltext_a" select="tmarc:d900/tmarc:sa" />
30     <xsl:variable name="fulltext_b" select="tmarc:d900/tmarc:sb" />
31     <!-- Does not always hit the right substring. The field is not always fixed-width? -->
32     <xsl:variable name="control_lang" select="substring(tmarc:c008, 36, 3)" />
33     <xsl:variable name="contains110" select="tmarc:d110" />
34     <xsl:variable name="hasAuthorFields" select="tmarc:d100 or tmarc:d111" />
35     <xsl:variable name="typeofrec" select="substring(tmarc:l, 7, 1)"/>
36     <xsl:variable name="typeofvm" select="substring(tmarc:c008, 34, 1)"/>
37     <xsl:variable name="biblevel" select="substring(tmarc:l, 8, 1)"/>
38     <xsl:variable name="physdes" select="substring(tmarc:c007, 1, 1)"/>
39     <xsl:variable name="form1" select="substring(tmarc:c008, 24, 1)"/>
40     <xsl:variable name="form2" select="substring(tmarc:c008, 30, 1)"/>
41     <xsl:variable name="oclca" select="substring(tmarc:c007, 1, 1)"/>
42     <xsl:variable name="oclcb" select="substring(tmarc:c007, 2, 1)"/>
43     <xsl:variable name="oclcd" select="substring(tmarc:c007, 4, 1)"/>
44     <xsl:variable name="oclce" select="substring(tmarc:c007, 5, 1)"/>
45     <xsl:variable name="typeofserial" select="substring(tmarc:c008, 22, 1)"/>
46
47     <xsl:variable name="electronic">
48       <xsl:choose>
49         <xsl:when test="$form1='s' or $form1='q' or $form1='o' or
50            $form2='s' or $form2='q' or $form2='o'">
51            <xsl:text>yes</xsl:text>
52         </xsl:when>
53         <xsl:otherwise/>
54       </xsl:choose>
55     </xsl:variable>
56
57     <xsl:variable name="vmedium">
58       <xsl:choose>
59         <xsl:when test="string-length($medium)"><xsl:value-of select="$medium" /></xsl:when>
60         <xsl:when test="($typeofrec='a' or $typeofrec='t') and $biblevel='m'">book</xsl:when>
61         <xsl:when test="$typeofrec='j' or $typeofrec='i'">
62           <xsl:text>recording</xsl:text>
63           <xsl:choose>
64             <xsl:when test="$oclcb='d' and $oclcd='f'">-cd</xsl:when>
65             <xsl:when test="$oclcb='s'">-cassette</xsl:when>
66             <xsl:when test="$oclcb='d' and $oclcd='a' or $oclcd='b' or
67               $oclcd='c' or $oclcd='d' or $oclcd='e'">-vinyl</xsl:when>
68           </xsl:choose>
69         </xsl:when>
70         <xsl:when test="$typeofrec='g'">
71           <xsl:choose>
72             <xsl:when test="$typeofvm='m' or $typeofvm='v'">
73               <xsl:text>video</xsl:text>
74               <xsl:choose>
75                 <xsl:when test="$oclca='v' and $oclcb='d' and $oclce='v'">-dvd</xsl:when>
76                 <xsl:when test="$oclca='v' and $oclcb='d' and $oclce='s'">-blu-ray</xsl:when>
77                 <xsl:when test="$oclca='v' and $oclcb='f' and $oclce='b'">-vhs</xsl:when>
78               </xsl:choose>
79             </xsl:when>
80             <xsl:otherwise>audio-visual</xsl:otherwise>
81           </xsl:choose>
82         </xsl:when>
83         <xsl:when test="$typeofrec='a' and $biblevel='s'">
84           <xsl:choose>
85             <xsl:when test="$typeofserial='n'">newspaper</xsl:when>
86             <xsl:otherwise>journal</xsl:otherwise>
87           </xsl:choose>
88         </xsl:when>
89         <xsl:when test="$typeofrec='e' or $typeofrec='f'">map</xsl:when>
90         <xsl:when test="$typeofrec='c' or $typeofrec='d'">music-score</xsl:when>
91         <xsl:when test="$form1='a' or $form1='b' or $form1='c'">microform</xsl:when>
92         <xsl:when test="$typeofrec='t'">thesis</xsl:when>
93         <!-- <xsl:when test="$journal_title">article</xsl:when> -->
94         <xsl:when test="$typeofrec='a' or $typeofrec='i' and
95             ($typeofserial='d' or $typeofserial='w')">web</xsl:when>
96         <xsl:when test="$typeofrec='a' and $biblevel='b'">article</xsl:when>
97         <xsl:when test="$typeofrec='m'">electronic</xsl:when>
98         <xsl:when test="$title_medium">
99           <xsl:value-of select="translate($title_medium, ' []/:', '')" />
100         </xsl:when>
101         <xsl:otherwise>
102           <xsl:text>other</xsl:text>
103         </xsl:otherwise>
104       </xsl:choose>
105     </xsl:variable>
106
107     <xsl:variable name="has_fulltext">
108       <xsl:choose>
109         <xsl:when test="tmarc:d856/tmarc:sq">
110           <xsl:text>yes</xsl:text>
111         </xsl:when>
112         <xsl:when test="tmarc:d856/tmarc:si='TEXT*'">
113           <xsl:text>yes</xsl:text>
114         </xsl:when>
115         <xsl:otherwise>
116           <xsl:text>no</xsl:text>
117         </xsl:otherwise>
118       </xsl:choose>
119     </xsl:variable>
120
121     <xsl:variable name="oclc_number">
122       <xsl:choose>
123         <xsl:when test='contains(tmarc:c001,"ocn") or
124                         contains(tmarc:c001,"ocm") or
125                         contains(tmarc:c001,"OCoLC") '>
126          <xsl:value-of select="tmarc:c001"/>
127         </xsl:when>
128         <xsl:when test='contains(tmarc:d035/tmarc:sa,"ocn") or
129                         contains(tmarc:d035/tmarc:sa,"ocm") or
130                         contains(tmarc:d035/tmarc:sa,"OCoLC") '>
131          <xsl:value-of select="tmarc:d035/tmarc:sa"/>
132         </xsl:when>
133       </xsl:choose>
134     </xsl:variable>
135
136     <pz:record>
137 <!--
138       <xsl:attribute name="mergekey">
139     <xsl:text>title </xsl:text>
140   <xsl:value-of select="tmarc:d245/tmarc:sa" />
141   <xsl:text> author </xsl:text>
142   <xsl:value-of select="tmarc:d100/tmarc:sa" />
143   <xsl:text> medium </xsl:text>
144   <xsl:value-of select="$medium" />
145     </xsl:attribute>
146   -->
147
148       <xsl:for-each select="tmarc:c001">
149         <pz:metadata type="id">
150           <xsl:value-of select="." />
151         </pz:metadata>
152       </xsl:for-each>
153
154       <pz:metadata type="oclc-number">
155         <xsl:value-of select="$oclc_number" />
156       </pz:metadata>
157
158       <xsl:for-each select="tmarc:d010">
159         <pz:metadata type="lccn">
160           <xsl:value-of select="tmarc:sa" />
161         </pz:metadata>
162       </xsl:for-each>
163
164       <xsl:for-each select="tmarc:d020">
165         <pz:metadata type="isbn">
166           <xsl:value-of select="tmarc:sa" />
167         </pz:metadata>
168       </xsl:for-each>
169
170       <xsl:for-each select="tmarc:d022">
171         <pz:metadata type="issn">
172           <xsl:value-of select="tmarc:sa" />
173         </pz:metadata>
174       </xsl:for-each>
175
176       <xsl:for-each select="tmarc:d027">
177         <pz:metadata type="tech-rep-nr">
178           <xsl:value-of select="tmarc:sa" />
179         </pz:metadata>
180       </xsl:for-each>
181
182       <xsl:for-each select="tmarc:d035"> 
183         <pz:metadata type="system-control-nr">
184           <xsl:choose>
185             <xsl:when test="tmarc:sa">
186               <xsl:value-of select="tmarc:sa"/>
187             </xsl:when>
188             <xsl:otherwise>
189               <xsl:value-of select="tmarc:sb"/>
190             </xsl:otherwise>
191           </xsl:choose>
192         </pz:metadata>
193       </xsl:for-each>
194
195       <xsl:for-each select="tmarc:d100">
196         <pz:metadata type="author">
197           <xsl:value-of select="tmarc:sa" />
198         </pz:metadata>
199         <pz:metadata type="author-title">
200           <xsl:value-of select="tmarc:sc" />
201         </pz:metadata>
202         <pz:metadata type="author-date">
203           <xsl:value-of select="tmarc:sd" />
204         </pz:metadata>
205       </xsl:for-each>
206
207       <xsl:for-each select="tmarc:d110">
208         <pz:metadata type="corporate-name">
209           <xsl:value-of select="tmarc:sa" />
210         </pz:metadata>
211         <pz:metadata type="corporate-location">
212           <xsl:value-of select="tmarc:sc" />
213         </pz:metadata>
214         <pz:metadata type="corporate-date">
215           <xsl:value-of select="tmarc:sd" />
216         </pz:metadata>
217       </xsl:for-each>
218
219       <xsl:for-each select="tmarc:d111">
220         <pz:metadata type="meeting-name">
221           <xsl:value-of select="tmarc:sa" />
222         </pz:metadata>
223         <pz:metadata type="meeting-location">
224           <xsl:value-of select="tmarc:sc" />
225         </pz:metadata>
226         <pz:metadata type="meeting-date">
227           <xsl:value-of select="tmarc:sd" />
228         </pz:metadata>
229       </xsl:for-each>
230
231       <xsl:for-each select="tmarc:d260">
232         <pz:metadata type="date">
233           <xsl:value-of select="translate(tmarc:sc, 'cp[].', '')" />
234         </pz:metadata>
235       </xsl:for-each>
236
237       <xsl:for-each select="tmarc:d130">
238         <pz:metadata type="title-uniform">
239           <xsl:value-of select="tmarc:sa" />
240         </pz:metadata>
241         <pz:metadata type="title-uniform-media">
242           <xsl:value-of select="tmarc:sm" />
243         </pz:metadata>
244         <pz:metadata type="title-uniform-parts">
245           <xsl:value-of select="tmarc:sn" />
246         </pz:metadata>
247         <pz:metadata type="title-uniform-partname">
248           <xsl:value-of select="tmarc:sp" />
249         </pz:metadata>
250         <pz:metadata type="title-uniform-key">
251           <xsl:value-of select="tmarc:sr" />
252         </pz:metadata>
253       </xsl:for-each>
254
255       <xsl:for-each select="tmarc:d245">
256         <pz:metadata type="title">
257           <xsl:value-of select="tmarc:sa" />
258         </pz:metadata>
259         <pz:metadata type="title-remainder">
260           <xsl:value-of select="tmarc:sb" />
261         </pz:metadata>
262         <pz:metadata type="title-responsibility">
263           <xsl:value-of select="tmarc:sc" />
264         </pz:metadata>
265         <pz:metadata type="title-dates">
266           <xsl:value-of select="tmarc:sf" />
267         </pz:metadata>
268         <pz:metadata type="title-medium">
269           <xsl:value-of select="tmarc:sh" />
270         </pz:metadata>
271         <pz:metadata type="title-number-section">
272           <xsl:value-of select="tmarc:sn" />
273         </pz:metadata>
274         <pz:metadata type="title-complete">
275           <xsl:value-of select="tmarc:sa" />
276           <xsl:if test="tmarc:sb" ><xsl:value-of select="concat(' ', tmarc:sb)" /></xsl:if>
277         </pz:metadata>
278       </xsl:for-each>
279
280       <xsl:for-each select="tmarc:d250">
281         <pz:metadata type="edition">
282           <xsl:value-of select="tmarc:sa" />
283         </pz:metadata>
284       </xsl:for-each>
285
286       <xsl:for-each select="tmarc:d260">
287         <pz:metadata type="publication-place">
288           <xsl:value-of select="tmarc:sa" />
289         </pz:metadata>
290         <pz:metadata type="publication-name">
291           <xsl:value-of select="tmarc:sb" />
292         </pz:metadata>
293         <pz:metadata type="publication-date">
294           <xsl:value-of select="tmarc:sc" />
295         </pz:metadata>
296       </xsl:for-each>
297
298       <xsl:for-each select="tmarc:d300">
299         <pz:metadata type="physical-extent">
300           <xsl:value-of select="tmarc:sa" />
301         </pz:metadata>
302         <pz:metadata type="physical-format">
303           <xsl:value-of select="tmarc:sb" />
304         </pz:metadata>
305         <pz:metadata type="physical-dimensions">
306           <xsl:value-of select="tmarc:sc" />
307         </pz:metadata>
308         <pz:metadata type="physical-accomp">
309           <xsl:value-of select="tmarc:se" />
310         </pz:metadata>
311         <pz:metadata type="physical-unittype">
312           <xsl:value-of select="tmarc:sf" />
313         </pz:metadata>
314         <pz:metadata type="physical-unitsize">
315           <xsl:value-of select="tmarc:sg" />
316         </pz:metadata>
317         <pz:metadata type="physical-specified">
318           <xsl:value-of select="tmarc:s3" />
319         </pz:metadata>
320       </xsl:for-each>
321
322       <xsl:for-each select="tmarc:d440">
323         <pz:metadata type="series-title">
324           <xsl:value-of select="tmarc:sa" />
325         </pz:metadata>
326       </xsl:for-each>
327
328       <xsl:for-each select="tmarc:d500">
329         <pz:metadata type="description">
330           <xsl:for-each select="node()">
331             <xsl:value-of select="text()" />
332           </xsl:for-each>
333         </pz:metadata>
334       </xsl:for-each>
335
336       <xsl:for-each select="tmarc:d505">
337         <pz:metadata type="description">
338           <xsl:for-each select="node()">
339             <xsl:value-of select="text()" />
340           </xsl:for-each>
341         </pz:metadata>
342       </xsl:for-each>
343
344       <xsl:for-each select="tmarc:d518">
345         <pz:metadata type="description">
346           <xsl:for-each select="node()">
347             <xsl:value-of select="text()" />
348           </xsl:for-each>
349         </pz:metadata>
350       </xsl:for-each>
351
352       <xsl:for-each select="tmarc:d520">
353         <pz:metadata type="description">
354           <xsl:for-each select="node()">
355             <xsl:value-of select="text()" />
356           </xsl:for-each>
357         </pz:metadata>
358       </xsl:for-each>
359
360       <xsl:for-each select="tmarc:d522">
361         <pz:metadata type="description">
362           <xsl:for-each select="node()">
363             <xsl:value-of select="text()" />
364           </xsl:for-each>
365         </pz:metadata>
366       </xsl:for-each>
367
368       <xsl:for-each select="tmarc:d911">
369         <pz:metadata type="description">
370           <xsl:for-each select="node()">
371             <xsl:value-of select="text()" />
372           </xsl:for-each>
373         </pz:metadata>
374       </xsl:for-each>
375
376       <xsl:for-each select="tmarc:d600">
377         <pz:metadata type="subject">
378           <xsl:value-of select="tmarc:sa" />
379         </pz:metadata>
380         <pz:metadata type="subject-long">
381           <xsl:for-each select="node()/text()">
382             <xsl:if test="position() > 1">
383               <xsl:text>, </xsl:text>
384             </xsl:if>
385             <xsl:value-of select="." />
386           </xsl:for-each>
387         </pz:metadata>
388       </xsl:for-each>
389
390       <xsl:for-each select="tmarc:d610">
391         <pz:metadata type="subject">
392           <xsl:value-of select="tmarc:sa" />
393         </pz:metadata>
394         <pz:metadata type="subject-long">
395           <xsl:for-each select="node()/text()">
396             <xsl:if test="position() > 1">
397               <xsl:text>, </xsl:text>
398             </xsl:if>
399             <xsl:value-of select="." />
400           </xsl:for-each>
401         </pz:metadata>
402       </xsl:for-each>
403
404       <xsl:for-each select="tmarc:d611">
405         <pz:metadata type="subject">
406           <xsl:value-of select="tmarc:sa" />
407         </pz:metadata>
408         <pz:metadata type="subject-long">
409           <xsl:for-each select="node()/text()">
410             <xsl:if test="position() > 1">
411               <xsl:text>, </xsl:text>
412             </xsl:if>
413             <xsl:value-of select="." />
414           </xsl:for-each>
415         </pz:metadata>
416       </xsl:for-each>
417
418       <xsl:for-each select="tmarc:d630">
419         <pz:metadata type="subject">
420           <xsl:value-of select="tmarc:sa" />
421         </pz:metadata>
422         <pz:metadata type="subject-long">
423           <xsl:for-each select="node()/text()">
424             <xsl:if test="position() > 1">
425               <xsl:text>, </xsl:text>
426             </xsl:if>
427             <xsl:value-of select="." />
428           </xsl:for-each>
429         </pz:metadata>
430       </xsl:for-each>
431
432       <xsl:for-each select="tmarc:d648">
433         <pz:metadata type="subject">
434           <xsl:value-of select="tmarc:sa" />
435         </pz:metadata>
436         <pz:metadata type="subject-long">
437           <xsl:for-each select="node()/text()">
438             <xsl:if test="position() > 1">
439               <xsl:text>, </xsl:text>
440             </xsl:if>
441             <xsl:value-of select="." />
442           </xsl:for-each>
443         </pz:metadata>
444       </xsl:for-each>
445
446       <xsl:for-each select="tmarc:d650">
447         <pz:metadata type="subject">
448           <xsl:value-of select="tmarc:sa" />
449         </pz:metadata>
450         <pz:metadata type="subject-long">
451           <xsl:for-each select="node()/text()">
452             <xsl:if test="position() > 1">
453               <xsl:text>, </xsl:text>
454             </xsl:if>
455             <xsl:value-of select="." />
456           </xsl:for-each>
457         </pz:metadata>
458       </xsl:for-each>
459
460       <xsl:for-each select="tmarc:d651">
461         <pz:metadata type="subject">
462           <xsl:value-of select="tmarc:sa" />
463         </pz:metadata>
464         <pz:metadata type="subject-long">
465           <xsl:for-each select="node()/text()">
466             <xsl:if test="position() > 1">
467               <xsl:text>, </xsl:text>
468             </xsl:if>
469             <xsl:value-of select="." />
470           </xsl:for-each>
471         </pz:metadata>
472       </xsl:for-each>
473
474       <xsl:for-each select="tmarc:d653">
475         <pz:metadata type="subject">
476           <xsl:value-of select="tmarc:sa" />
477         </pz:metadata>
478         <pz:metadata type="subject-long">
479           <xsl:for-each select="node()/text()">
480             <xsl:if test="position() > 1">
481               <xsl:text>, </xsl:text>
482             </xsl:if>
483             <xsl:value-of select="." />
484           </xsl:for-each>
485         </pz:metadata>
486       </xsl:for-each>
487
488       <xsl:for-each select="tmarc:d654">
489         <pz:metadata type="subject">
490           <xsl:value-of select="tmarc:sa" />
491         </pz:metadata>
492         <pz:metadata type="subject-long">
493           <xsl:for-each select="node()/text()">
494             <xsl:if test="position() > 1">
495               <xsl:text>, </xsl:text>
496             </xsl:if>
497             <xsl:value-of select="." />
498           </xsl:for-each>
499         </pz:metadata>
500       </xsl:for-each>
501
502       <xsl:for-each select="tmarc:d655">
503         <pz:metadata type="subject">
504           <xsl:value-of select="tmarc:sa" />
505         </pz:metadata>
506         <pz:metadata type="subject-long">
507           <xsl:for-each select="node()/text()">
508             <xsl:if test="position() > 1">
509               <xsl:text>, </xsl:text>
510             </xsl:if>
511             <xsl:value-of select="." />
512           </xsl:for-each>
513         </pz:metadata>
514       </xsl:for-each>
515
516       <xsl:for-each select="tmarc:d656">
517         <pz:metadata type="subject">
518           <xsl:value-of select="tmarc:sa" />
519         </pz:metadata>
520         <pz:metadata type="subject-long">
521           <xsl:for-each select="node()/text()">
522             <xsl:if test="position() > 1">
523               <xsl:text>, </xsl:text>
524             </xsl:if>
525             <xsl:value-of select="." />
526           </xsl:for-each>
527         </pz:metadata>
528       </xsl:for-each>
529
530       <xsl:for-each select="tmarc:d657">
531         <pz:metadata type="subject">
532           <xsl:value-of select="tmarc:sa" />
533         </pz:metadata>
534         <pz:metadata type="subject-long">
535           <xsl:for-each select="node()/text()">
536             <xsl:if test="position() > 1">
537               <xsl:text>, </xsl:text>
538             </xsl:if>
539             <xsl:value-of select="." />
540           </xsl:for-each>
541         </pz:metadata>
542       </xsl:for-each>
543
544       <xsl:for-each select="tmarc:d658">
545         <pz:metadata type="subject">
546           <xsl:value-of select="tmarc:sa" />
547         </pz:metadata>
548         <pz:metadata type="subject-long">
549           <xsl:for-each select="node()/text()">
550             <xsl:if test="position() > 1">
551               <xsl:text>, </xsl:text>
552             </xsl:if>
553             <xsl:value-of select="." />
554           </xsl:for-each>
555         </pz:metadata>
556       </xsl:for-each>
557
558       <xsl:for-each select="tmarc:d662">
559         <pz:metadata type="subject">
560           <xsl:value-of select="tmarc:sa" />
561         </pz:metadata>
562         <pz:metadata type="subject-long">
563           <xsl:for-each select="node()/text()">
564             <xsl:if test="position() > 1">
565               <xsl:text>, </xsl:text>
566             </xsl:if>
567             <xsl:value-of select="." />
568           </xsl:for-each>
569         </pz:metadata>
570       </xsl:for-each>
571
572       <xsl:for-each select="tmarc:d69X">
573         <pz:metadata type="subject">
574           <xsl:value-of select="tmarc:sa" />
575         </pz:metadata>
576         <pz:metadata type="subject-long">
577           <xsl:for-each select="node()/text()">
578             <xsl:if test="position() > 1">
579               <xsl:text>, </xsl:text>
580             </xsl:if>
581             <xsl:value-of select="." />
582           </xsl:for-each>
583         </pz:metadata>
584       </xsl:for-each>
585
586       <!-- or tmarc:d651 or tmarc:d653 or tmarc:d654 or tmarc:d655 or tmarc:d656 
587         or tmarc:d657 or tmarc:d658 or tmarc:d662 or tmarc:d69X"> -->
588
589       <!-- <xsl:for-each select="tmarc:d600" > <pz:metadata type="subject"> 
590         <xsl:value-of select="tmarc:sa"/> </pz:metadata> <pz:metadata type="subject-long"> 
591         <xsl:for-each select="tmarc:sa tmarc:sb tmarc:sc tmarc:sd "> <xsl:if test="position() 
592         > 1"> <xsl:text>, </xsl:text> </xsl:if> <xsl:value-of select="."/> </xsl:for-each> 
593         </pz:metadata> </xsl:for-each> -->
594
595       <xsl:for-each select="tmarc:d856">
596         <pz:metadata type="electronic-url">
597           <xsl:value-of select="tmarc:su" />
598         </pz:metadata>
599         <pz:metadata type="electronic-text">
600           <xsl:choose>
601             <xsl:when test="tmarc:sy">
602               <xsl:value-of select="tmarc:sy/text()" />
603             </xsl:when>
604             <xsl:when test="tmarc:s3">
605               <xsl:value-of select="tmarc:s3/text()" />
606             </xsl:when>
607              <xsl:otherwise>Get resource</xsl:otherwise>
608            </xsl:choose>
609         </pz:metadata>
610         <pz:metadata type="electronic-note">
611           <xsl:value-of select="tmarc:sz" />
612         </pz:metadata>
613         <pz:metadata type="electronic-format-instruction">
614           <xsl:value-of select="tmarc:si" />
615         </pz:metadata>
616         <pz:metadata type="electronic-format-type">
617           <xsl:value-of select="tmarc:sq" />
618         </pz:metadata>
619       </xsl:for-each>
620
621       <xsl:for-each select="tmarc:d773">
622         <pz:metadata type="citation">
623           <xsl:for-each select="*">
624             <xsl:value-of select="normalize-space(.)" />
625             <xsl:text> </xsl:text>
626           </xsl:for-each>
627         </pz:metadata>
628         <xsl:if test="tmarc:st">
629           <pz:metadata type="journal-title">
630             <xsl:value-of select="tmarc:st"/>
631           </pz:metadata>
632         </xsl:if>
633         <xsl:if test="tmarc:sg">
634           <pz:metadata type="journal-subpart">
635             <xsl:value-of select="tmarc:sg"/>
636           </pz:metadata>
637         </xsl:if>
638         <xsl:if test="tmarc:sp">
639           <pz:metadata type="journal-title-abbrev">
640             <xsl:value-of select="tmarc:sp"/>
641           </pz:metadata>
642         </xsl:if>
643       </xsl:for-each>
644
645       <xsl:for-each select="tmarc:d852">
646         <xsl:if test="tmarc:sy">
647           <pz:metadata type="publicnote">
648             <xsl:value-of select="tmarc:sy" />
649           </pz:metadata>
650         </xsl:if>
651         <xsl:if test="tmarc:sh">
652           <pz:metadata type="callnumber">
653             <xsl:value-of select="tmarc:sh" />
654           </pz:metadata>
655         </xsl:if>
656       </xsl:for-each>
657
658       <pz:metadata type="medium">
659         <xsl:value-of select="$vmedium" />
660         <xsl:if test="string-length($electronic) and $vmedium != 'electronic'">
661           <xsl:text> (electronic)</xsl:text>
662         </xsl:if>
663       </pz:metadata>
664
665       <xsl:for-each select="tmarc:d900/tmarc:sa">
666         <pz:metadata type="fulltext">
667           <xsl:value-of select="." />
668         </pz:metadata>
669       </xsl:for-each>
670
671       <!-- <xsl:if test="$fulltext_a"> <pz:metadata type="fulltext"> <xsl:value-of 
672         select="$fulltext_a"/> </pz:metadata> </xsl:if> -->
673
674       <xsl:for-each select="tmarc:d900/tmarc:sb">
675         <pz:metadata type="fulltext">
676           <xsl:value-of select="." />
677         </pz:metadata>
678       </xsl:for-each>
679
680       <xsl:for-each select="tmarc:d900/tmarc:se">
681         <pz:metadata type="fulltext">
682           <xsl:value-of select="." />
683         </pz:metadata>
684       </xsl:for-each>
685
686       <xsl:for-each select="tmarc:d900/tmarc:sf">
687         <pz:metadata type="fulltext">
688           <xsl:value-of select="." />
689         </pz:metadata>
690       </xsl:for-each>
691
692       <xsl:for-each select="tmarc:d900/tmarc:si">
693         <pz:metadata type="fulltext">
694           <xsl:value-of select="." />
695         </pz:metadata>
696       </xsl:for-each>
697
698       <xsl:for-each select="tmarc:d900/tmarc:sk">
699         <pz:metadata type="fulltext">
700           <xsl:value-of select="." />
701         </pz:metadata>
702       </xsl:for-each>
703
704       <xsl:for-each select="tmarc:d900/tmarc:sq">
705         <pz:metadata type="fulltext">
706           <xsl:value-of select="." />
707         </pz:metadata>
708       </xsl:for-each>
709
710       <xsl:for-each select="tmarc:d900/tmarc:ss">
711         <pz:metadata type="fulltext">
712           <xsl:value-of select="." />
713         </pz:metadata>
714       </xsl:for-each>
715
716       <xsl:for-each select="tmarc:d900/tmarc:su">
717         <pz:metadata type="fulltext">
718           <xsl:value-of select="." />
719         </pz:metadata>
720       </xsl:for-each>
721
722       <xsl:for-each select="tmarc:d900/tmarc:sy">
723         <pz:metadata type="fulltext">
724           <xsl:value-of select="." />
725         </pz:metadata>
726       </xsl:for-each>
727
728
729       <!-- <xsl:if test="$fulltext_b"> <pz:metadata type="fulltext"> <xsl:value-of 
730         select="$fulltext_b"/> </pz:metadata> </xsl:if> -->
731
732       <pz:metadata type="has-fulltext">
733         <xsl:value-of select="$has_fulltext"/>
734       </pz:metadata>
735
736       <xsl:for-each select="tmarc:d907">
737         <!-- or tmarc:d901"> -->
738         <pz:metadata type="iii-id">
739           <xsl:value-of select="tmarc:sa" />
740         </pz:metadata>
741       </xsl:for-each>
742
743       <xsl:for-each select="tmarc:d926">
744         <pz:metadata type="locallocation">
745           <xsl:choose><xsl:when test="tmarc:sa">
746             <xsl:value-of select="tmarc:sa"/>
747           </xsl:when><xsl:otherwise>
748             <xsl:text>PAZPAR2_NULL_VALUE</xsl:text>
749           </xsl:otherwise></xsl:choose>
750         </pz:metadata>
751         <pz:metadata type="callnumber">
752           <xsl:choose><xsl:when test="tmarc:sc">
753             <xsl:value-of select="tmarc:sc"/>
754           </xsl:when><xsl:otherwise>
755             <xsl:text>PAZPAR2_NULL_VALUE</xsl:text>
756           </xsl:otherwise></xsl:choose>
757         </pz:metadata>
758         <pz:metadata type="available">
759           <xsl:choose><xsl:when test="tmarc:se">
760             <xsl:value-of select="tmarc:se"/>
761           </xsl:when><xsl:otherwise>
762             <xsl:text>PAZPAR2_NULL_VALUE</xsl:text>
763           </xsl:otherwise></xsl:choose>
764         </pz:metadata>
765       </xsl:for-each>
766
767       <xsl:for-each select="tmarc:d948">
768         <pz:metadata type="holding">
769           <xsl:for-each select="tmarc:s">
770             <xsl:if test="position() > 1">
771               <xsl:text> </xsl:text>
772             </xsl:if>
773             <xsl:value-of select="." />
774           </xsl:for-each>
775         </pz:metadata>
776       </xsl:for-each>
777
778       <xsl:for-each select="tmarc:d991">
779         <pz:metadata type="holding">
780           <xsl:for-each select="tmarc:s">
781             <xsl:if test="position() > 1">
782               <xsl:text> </xsl:text>
783             </xsl:if>
784             <xsl:value-of select="." />
785           </xsl:for-each>
786         </pz:metadata>
787       </xsl:for-each>
788
789       <xsl:for-each select="tmarc:d999">
790         <pz:metadata type="localid">
791           <xsl:choose>
792             <xsl:when test="tmarc:sa">
793               <xsl:value-of select="tmarc:sa"/>
794             </xsl:when>
795             <xsl:when test="tmarc:sc">
796               <xsl:value-of select="tmarc:sc"/>
797             </xsl:when> 
798             <xsl:otherwise>
799               <xsl:value-of select="tmarc:sd"/>
800             </xsl:otherwise>
801           </xsl:choose>
802         </pz:metadata>
803       </xsl:for-each>
804
805
806       <!-- passthrough id data -->
807       <xsl:for-each select="pz:metadata">
808         <xsl:copy-of select="." />
809       </xsl:for-each>
810
811       <!-- other stylesheets importing this might want to define this -->
812         <xsl:call-template name="record-hook" />
813
814     </pz:record>
815   </xsl:template>
816
817   <xsl:template match="text()" />
818
819   <!-- TODO Does not work anymore -->
820   <xsl:template name="shortTitle">
821     <xsl:param name="tag" />
822     <xsl:for-each select="tmarc:d">
823       <xsl:value-of select="tmarc:sa" />
824       <xsl:value-of select="tmarc:sm" />
825       <xsl:value-of select="tmarc:sn" />
826       <xsl:value-of select="tmarc:sp" />
827       <xsl:value-of select="tmarc:sr" />
828     </xsl:for-each>
829   </xsl:template>
830
831   <!-- No working as expected -->
832   <xsl:template name="description">
833     <xsl:param name="element" />
834     <xsl:for-each select="$element">
835       <pz:metadata type="description">
836         <xsl:for-each select="node()">
837           <xsl:value-of select="text()" />
838         </xsl:for-each>
839       </pz:metadata>
840     </xsl:for-each>
841     <xsl:apply-templates />
842   </xsl:template>
843
844   <!-- <xsl:for-each select="tmarc:d500"> <pz:metadata type="description"> 
845     <xsl:for-each select="node()"> <xsl:value-of select="text()"/> </xsl:for-each> 
846     </pz:metadata> </xsl:for-each> -->
847
848
849
850   <xsl:template name="subject">
851     <xsl:param name="element" />
852     <xsl:for-each select="$element">
853       <pz:metadata type="subject">
854         <xsl:value-of select="tmarc:sa" />
855       </pz:metadata>
856       <pz:metadata type="subject-long">
857         <xsl:for-each select="node()/text()">
858           <xsl:if test="position() > 1">
859             <xsl:text>, </xsl:text>
860           </xsl:if>
861           <xsl:value-of select="." />
862         </xsl:for-each>
863       </pz:metadata>
864     </xsl:for-each>
865   </xsl:template>
866
867
868 </xsl:stylesheet>