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