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