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