Bug 3072: Add Heading-Main and Any to MARC21 DOM
[koha_gimpoz] / etc / zebradb / marc_defs / marc21 / authorities / authority-zebra-indexdefs.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xslo:stylesheet xmlns:xslo="http://www.w3.org/1999/XSL/Transform" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:z="http://indexdata.com/zebra-2.0" xmlns:kohaidx="http://www.koha-community.org/schemas/index-defs" version="1.0">
3   <xslo:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
4   <xslo:template match="text()"/>
5   <xslo:template match="text()" mode="index_subfields"/>
6   <xslo:template match="text()" mode="index_heading"/>
7   <xslo:template match="text()" mode="index_match_heading"/>
8   <xslo:template match="text()" mode="index_subject_thesaurus"/>
9   <xslo:template match="/">
10     <xslo:if test="marc:collection">
11       <collection>
12         <xslo:apply-templates select="marc:collection/marc:record"/>
13       </collection>
14     </xslo:if>
15     <xslo:if test="marc:record">
16       <xslo:apply-templates select="marc:record"/>
17     </xslo:if>
18   </xslo:template>
19   <xslo:template match="marc:record">
20     <xslo:variable name="controlField001" select="normalize-space(marc:controlfield[@tag='001'])"/>
21     <z:record type="update">
22       <xslo:attribute name="z:id">
23         <xslo:value-of select="$controlField001"/>
24       </xslo:attribute>
25       <xslo:apply-templates/>
26       <xslo:apply-templates mode="index_subfields"/>
27       <xslo:apply-templates mode="index_heading"/>
28       <xslo:apply-templates mode="index_match_heading"/>
29       <xslo:apply-templates mode="index_subject_thesaurus"/>
30     </z:record>
31   </xslo:template>
32   <xslo:template match="marc:leader">
33     <z:index name="Record-status:w">
34       <xslo:value-of select="substring(., 6, 1)"/>
35     </z:index>
36     <z:index name="Encoding-level:w">
37       <xslo:value-of select="substring(., 18, 1)"/>
38     </z:index>
39   </xslo:template>
40   <xslo:template match="marc:controlfield[@tag='001']">
41     <z:index name="Local-Number:w">
42       <xslo:value-of select="."/>
43     </z:index>
44   </xslo:template>
45   <xslo:template match="marc:controlfield[@tag='008']">
46     <z:index name="Kind-of-record:w">
47       <xslo:value-of select="substring(., 10, 1)"/>
48     </z:index>
49     <z:index name="Descriptive-cataloging-rules:w">
50       <xslo:value-of select="substring(., 11, 1)"/>
51     </z:index>
52     <z:index name="Heading-use-main-or-added-entry:w">
53       <xslo:value-of select="substring(., 15, 1)"/>
54     </z:index>
55     <z:index name="Heading-use-subject-added-entry:w">
56       <xslo:value-of select="substring(., 16, 1)"/>
57     </z:index>
58     <z:index name="Heading-use-series-added-entry:w">
59       <xslo:value-of select="substring(., 17, 1)"/>
60     </z:index>
61   </xslo:template>
62   <xslo:template mode="index_subfields" match="marc:datafield[@tag='100']">
63     <xslo:for-each select="marc:subfield">
64       <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)">
65         <z:index name="Personal-name:w Personal-name:p Personal-name:s">
66           <xslo:value-of select="."/>
67         </z:index>
68       </xslo:if>
69     </xslo:for-each>
70   </xslo:template>
71   <xslo:template mode="index_subfields" match="marc:datafield[@tag='110']">
72     <xslo:for-each select="marc:subfield">
73       <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)">
74         <z:index name="Corporate-name:w Corporate-name:p">
75           <xslo:value-of select="."/>
76         </z:index>
77       </xslo:if>
78     </xslo:for-each>
79   </xslo:template>
80   <xslo:template mode="index_subfields" match="marc:datafield[@tag='111']">
81     <xslo:for-each select="marc:subfield">
82       <xslo:if test="contains('acdefghjklnpqstvxyz', @code)">
83         <z:index name="Meeting-name:w Meeting-name:p">
84           <xslo:value-of select="."/>
85         </z:index>
86       </xslo:if>
87     </xslo:for-each>
88   </xslo:template>
89   <xslo:template mode="index_subfields" match="marc:datafield[@tag='130']">
90     <xslo:for-each select="marc:subfield">
91       <xslo:if test="contains('adfghklmnoprstvxyz', @code)">
92         <z:index name="Title-uniform:w Title-uniform:p">
93           <xslo:value-of select="."/>
94         </z:index>
95       </xslo:if>
96     </xslo:for-each>
97   </xslo:template>
98   <xslo:template mode="index_subfields" match="marc:datafield[@tag='148']">
99     <xslo:for-each select="marc:subfield">
100       <xslo:if test="contains('avxyz', @code)">
101         <z:index name="Chronological-term:w Chronological-term:p">
102           <xslo:value-of select="."/>
103         </z:index>
104       </xslo:if>
105     </xslo:for-each>
106   </xslo:template>
107   <xslo:template mode="index_subfields" match="marc:datafield[@tag='150']">
108     <xslo:for-each select="marc:subfield">
109       <xslo:if test="contains('abvxyz', @code)">
110         <z:index name="Subject-topical:w Subject-topical:p">
111           <xslo:value-of select="."/>
112         </z:index>
113       </xslo:if>
114     </xslo:for-each>
115   </xslo:template>
116   <xslo:template mode="index_subfields" match="marc:datafield[@tag='151']">
117     <xslo:for-each select="marc:subfield">
118       <xslo:if test="contains('avxyz', @code)">
119         <z:index name="Name-geographic:w Name-geographic:p">
120           <xslo:value-of select="."/>
121         </z:index>
122       </xslo:if>
123     </xslo:for-each>
124   </xslo:template>
125   <xslo:template mode="index_subfields" match="marc:datafield[@tag='155']">
126     <xslo:for-each select="marc:subfield">
127       <xslo:if test="contains('avxyz', @code)">
128         <z:index name="Term-genre-form:w Term-genre-form:p">
129           <xslo:value-of select="."/>
130         </z:index>
131       </xslo:if>
132     </xslo:for-each>
133   </xslo:template>
134   <xslo:template mode="index_subfields" match="marc:datafield[@tag='942']">
135     <xslo:for-each select="marc:subfield">
136       <xslo:if test="contains('a', @code)">
137         <z:index name="authtype:w">
138           <xslo:value-of select="."/>
139         </z:index>
140       </xslo:if>
141     </xslo:for-each>
142   </xslo:template>
143   <xslo:template mode="index_heading" match="marc:datafield[@tag='100']">
144     <z:index name="Personal-name-heading:w Personal-name-heading:p Personal-name-heading:s Heading:w Heading:p Heading:s">
145       <xslo:variable name="raw_heading">
146         <xslo:for-each select="marc:subfield">
147           <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Personal-name-heading:w Personal-name-heading:p Personal-name-heading:s Heading:w Heading:p Heading:s">
148             <xslo:if test="position() &gt; 1">
149               <xslo:choose>
150                 <xslo:when test="contains('vxyz', @code)">
151                   <xslo:text>--</xslo:text>
152                 </xslo:when>
153                 <xslo:otherwise>
154                   <xslo:value-of select="substring(' ', 1, 1)"/>
155                 </xslo:otherwise>
156               </xslo:choose>
157             </xslo:if>
158             <xslo:value-of select="."/>
159           </xslo:if>
160         </xslo:for-each>
161       </xslo:variable>
162       <xslo:value-of select="normalize-space($raw_heading)"/>
163     </z:index>
164     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
165       <xslo:variable name="raw_heading">
166         <xslo:for-each select="marc:subfield">
167           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
168             <xslo:if test="position() &gt; 1">
169               <xslo:choose>
170                 <xslo:when test="contains('', @code)">
171                   <xslo:text>--</xslo:text>
172                 </xslo:when>
173                 <xslo:otherwise>
174                   <xslo:value-of select="substring(' ', 1, 1)"/>
175                 </xslo:otherwise>
176               </xslo:choose>
177             </xslo:if>
178             <xslo:value-of select="."/>
179           </xslo:if>
180         </xslo:for-each>
181       </xslo:variable>
182       <xslo:value-of select="normalize-space($raw_heading)"/>
183     </z:index>
184   </xslo:template>
185   <xslo:template mode="index_heading" match="marc:datafield[@tag='400']">
186     <z:index name="Personal-name-see-from:w Personal-name-see-from:p Personal-name-see-from:s See-from:w See-from:p See-from:s">
187       <xslo:variable name="raw_heading">
188         <xslo:for-each select="marc:subfield">
189           <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Personal-name-see-from:w Personal-name-see-from:p Personal-name-see-from:s See-from:w See-from:p See-from:s">
190             <xslo:if test="position() &gt; 1">
191               <xslo:choose>
192                 <xslo:when test="contains('vxyz', @code)">
193                   <xslo:text>--</xslo:text>
194                 </xslo:when>
195                 <xslo:otherwise>
196                   <xslo:value-of select="substring(' ', 1, 1)"/>
197                 </xslo:otherwise>
198               </xslo:choose>
199             </xslo:if>
200             <xslo:value-of select="."/>
201           </xslo:if>
202         </xslo:for-each>
203       </xslo:variable>
204       <xslo:value-of select="normalize-space($raw_heading)"/>
205     </z:index>
206   </xslo:template>
207   <xslo:template mode="index_heading" match="marc:datafield[@tag='500']">
208     <z:index name="Personal-name-see-also-from:w Personal-name-see-also-from:p Personal-name-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
209       <xslo:variable name="raw_heading">
210         <xslo:for-each select="marc:subfield">
211           <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Personal-name-see-also-from:w Personal-name-see-also-from:p Personal-name-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
212             <xslo:if test="position() &gt; 1">
213               <xslo:choose>
214                 <xslo:when test="contains('vxyz', @code)">
215                   <xslo:text>--</xslo:text>
216                 </xslo:when>
217                 <xslo:otherwise>
218                   <xslo:value-of select="substring(' ', 1, 1)"/>
219                 </xslo:otherwise>
220               </xslo:choose>
221             </xslo:if>
222             <xslo:value-of select="."/>
223           </xslo:if>
224         </xslo:for-each>
225       </xslo:variable>
226       <xslo:value-of select="normalize-space($raw_heading)"/>
227     </z:index>
228   </xslo:template>
229   <xslo:template mode="index_heading" match="marc:datafield[@tag='110']">
230     <z:index name="Corporate-name-heading:w Corporate-name-heading:p Corporate-name-heading:s Heading:w Heading:p Heading:s">
231       <xslo:variable name="raw_heading">
232         <xslo:for-each select="marc:subfield">
233           <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Corporate-name-heading:w Corporate-name-heading:p Corporate-name-heading:s Heading:w Heading:p Heading:s">
234             <xslo:if test="position() &gt; 1">
235               <xslo:choose>
236                 <xslo:when test="contains('vxyz', @code)">
237                   <xslo:text>--</xslo:text>
238                 </xslo:when>
239                 <xslo:otherwise>
240                   <xslo:value-of select="substring(' ', 1, 1)"/>
241                 </xslo:otherwise>
242               </xslo:choose>
243             </xslo:if>
244             <xslo:value-of select="."/>
245           </xslo:if>
246         </xslo:for-each>
247       </xslo:variable>
248       <xslo:value-of select="normalize-space($raw_heading)"/>
249     </z:index>
250     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
251       <xslo:variable name="raw_heading">
252         <xslo:for-each select="marc:subfield">
253           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
254             <xslo:if test="position() &gt; 1">
255               <xslo:choose>
256                 <xslo:when test="contains('', @code)">
257                   <xslo:text>--</xslo:text>
258                 </xslo:when>
259                 <xslo:otherwise>
260                   <xslo:value-of select="substring(' ', 1, 1)"/>
261                 </xslo:otherwise>
262               </xslo:choose>
263             </xslo:if>
264             <xslo:value-of select="."/>
265           </xslo:if>
266         </xslo:for-each>
267       </xslo:variable>
268       <xslo:value-of select="normalize-space($raw_heading)"/>
269     </z:index>
270   </xslo:template>
271   <xslo:template mode="index_heading" match="marc:datafield[@tag='410']">
272     <z:index name="Corporate-name-see-from:w Corporate-name-see-from:p Corporate-name-see-from:s See-from:w See-from:p See-from:s">
273       <xslo:variable name="raw_heading">
274         <xslo:for-each select="marc:subfield">
275           <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Corporate-name-see-from:w Corporate-name-see-from:p Corporate-name-see-from:s See-from:w See-from:p See-from:s">
276             <xslo:if test="position() &gt; 1">
277               <xslo:choose>
278                 <xslo:when test="contains('vxyz', @code)">
279                   <xslo:text>--</xslo:text>
280                 </xslo:when>
281                 <xslo:otherwise>
282                   <xslo:value-of select="substring(' ', 1, 1)"/>
283                 </xslo:otherwise>
284               </xslo:choose>
285             </xslo:if>
286             <xslo:value-of select="."/>
287           </xslo:if>
288         </xslo:for-each>
289       </xslo:variable>
290       <xslo:value-of select="normalize-space($raw_heading)"/>
291     </z:index>
292   </xslo:template>
293   <xslo:template mode="index_heading" match="marc:datafield[@tag='510']">
294     <z:index name="Corporate-name-see-also-from:w Corporate-name-see-also-from:p Corporate-name-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
295       <xslo:variable name="raw_heading">
296         <xslo:for-each select="marc:subfield">
297           <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Corporate-name-see-also-from:w Corporate-name-see-also-from:p Corporate-name-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
298             <xslo:if test="position() &gt; 1">
299               <xslo:choose>
300                 <xslo:when test="contains('vxyz', @code)">
301                   <xslo:text>--</xslo:text>
302                 </xslo:when>
303                 <xslo:otherwise>
304                   <xslo:value-of select="substring(' ', 1, 1)"/>
305                 </xslo:otherwise>
306               </xslo:choose>
307             </xslo:if>
308             <xslo:value-of select="."/>
309           </xslo:if>
310         </xslo:for-each>
311       </xslo:variable>
312       <xslo:value-of select="normalize-space($raw_heading)"/>
313     </z:index>
314   </xslo:template>
315   <xslo:template mode="index_heading" match="marc:datafield[@tag='111']">
316     <z:index name="Meeting-name-heading:w Meeting-name-heading:p Meeting-name-heading:s Heading:w Heading:p Heading:s">
317       <xslo:variable name="raw_heading">
318         <xslo:for-each select="marc:subfield">
319           <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Meeting-name-heading:w Meeting-name-heading:p Meeting-name-heading:s Heading:w Heading:p Heading:s">
320             <xslo:if test="position() &gt; 1">
321               <xslo:choose>
322                 <xslo:when test="contains('vxyz', @code)">
323                   <xslo:text>--</xslo:text>
324                 </xslo:when>
325                 <xslo:otherwise>
326                   <xslo:value-of select="substring(' ', 1, 1)"/>
327                 </xslo:otherwise>
328               </xslo:choose>
329             </xslo:if>
330             <xslo:value-of select="."/>
331           </xslo:if>
332         </xslo:for-each>
333       </xslo:variable>
334       <xslo:value-of select="normalize-space($raw_heading)"/>
335     </z:index>
336     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
337       <xslo:variable name="raw_heading">
338         <xslo:for-each select="marc:subfield">
339           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
340             <xslo:if test="position() &gt; 1">
341               <xslo:choose>
342                 <xslo:when test="contains('', @code)">
343                   <xslo:text>--</xslo:text>
344                 </xslo:when>
345                 <xslo:otherwise>
346                   <xslo:value-of select="substring(' ', 1, 1)"/>
347                 </xslo:otherwise>
348               </xslo:choose>
349             </xslo:if>
350             <xslo:value-of select="."/>
351           </xslo:if>
352         </xslo:for-each>
353       </xslo:variable>
354       <xslo:value-of select="normalize-space($raw_heading)"/>
355     </z:index>
356   </xslo:template>
357   <xslo:template mode="index_heading" match="marc:datafield[@tag='411']">
358     <z:index name="Meeting-name-see-from:w Meeting-name-see-from:p Meeting-name-see-from:s See-from:w See-from:p See-from:s">
359       <xslo:variable name="raw_heading">
360         <xslo:for-each select="marc:subfield">
361           <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Meeting-name-see-from:w Meeting-name-see-from:p Meeting-name-see-from:s See-from:w See-from:p See-from:s">
362             <xslo:if test="position() &gt; 1">
363               <xslo:choose>
364                 <xslo:when test="contains('vxyz', @code)">
365                   <xslo:text>--</xslo:text>
366                 </xslo:when>
367                 <xslo:otherwise>
368                   <xslo:value-of select="substring(' ', 1, 1)"/>
369                 </xslo:otherwise>
370               </xslo:choose>
371             </xslo:if>
372             <xslo:value-of select="."/>
373           </xslo:if>
374         </xslo:for-each>
375       </xslo:variable>
376       <xslo:value-of select="normalize-space($raw_heading)"/>
377     </z:index>
378   </xslo:template>
379   <xslo:template mode="index_heading" match="marc:datafield[@tag='511']">
380     <z:index name="Meeting-name-see-also-from:w Meeting-name-see-also-from:p Meeting-name-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
381       <xslo:variable name="raw_heading">
382         <xslo:for-each select="marc:subfield">
383           <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Meeting-name-see-also-from:w Meeting-name-see-also-from:p Meeting-name-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
384             <xslo:if test="position() &gt; 1">
385               <xslo:choose>
386                 <xslo:when test="contains('vxyz', @code)">
387                   <xslo:text>--</xslo:text>
388                 </xslo:when>
389                 <xslo:otherwise>
390                   <xslo:value-of select="substring(' ', 1, 1)"/>
391                 </xslo:otherwise>
392               </xslo:choose>
393             </xslo:if>
394             <xslo:value-of select="."/>
395           </xslo:if>
396         </xslo:for-each>
397       </xslo:variable>
398       <xslo:value-of select="normalize-space($raw_heading)"/>
399     </z:index>
400   </xslo:template>
401   <xslo:template mode="index_heading" match="marc:datafield[@tag='130']">
402     <z:index name="Title-uniform-heading:w Title-uniform-heading:p Title-uniform-heading:s Heading:w Heading:p Heading:s">
403       <xslo:variable name="raw_heading">
404         <xslo:for-each select="marc:subfield">
405           <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Title-uniform-heading:w Title-uniform-heading:p Title-uniform-heading:s Heading:w Heading:p Heading:s">
406             <xslo:if test="position() &gt; 1">
407               <xslo:choose>
408                 <xslo:when test="contains('vxyz', @code)">
409                   <xslo:text>--</xslo:text>
410                 </xslo:when>
411                 <xslo:otherwise>
412                   <xslo:value-of select="substring(' ', 1, 1)"/>
413                 </xslo:otherwise>
414               </xslo:choose>
415             </xslo:if>
416             <xslo:value-of select="."/>
417           </xslo:if>
418         </xslo:for-each>
419       </xslo:variable>
420       <xslo:value-of select="normalize-space($raw_heading)"/>
421     </z:index>
422     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
423       <xslo:variable name="raw_heading">
424         <xslo:for-each select="marc:subfield">
425           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
426             <xslo:if test="position() &gt; 1">
427               <xslo:choose>
428                 <xslo:when test="contains('', @code)">
429                   <xslo:text>--</xslo:text>
430                 </xslo:when>
431                 <xslo:otherwise>
432                   <xslo:value-of select="substring(' ', 1, 1)"/>
433                 </xslo:otherwise>
434               </xslo:choose>
435             </xslo:if>
436             <xslo:value-of select="."/>
437           </xslo:if>
438         </xslo:for-each>
439       </xslo:variable>
440       <xslo:value-of select="normalize-space($raw_heading)"/>
441     </z:index>
442   </xslo:template>
443   <xslo:template mode="index_heading" match="marc:datafield[@tag='430']">
444     <z:index name="Title-uniform-see-from:w Title-uniform-see-from:p Title-uniform-see-from:s See-from:w See-from:p See-from:s">
445       <xslo:variable name="raw_heading">
446         <xslo:for-each select="marc:subfield">
447           <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Title-uniform-see-from:w Title-uniform-see-from:p Title-uniform-see-from:s See-from:w See-from:p See-from:s">
448             <xslo:if test="position() &gt; 1">
449               <xslo:choose>
450                 <xslo:when test="contains('vxyz', @code)">
451                   <xslo:text>--</xslo:text>
452                 </xslo:when>
453                 <xslo:otherwise>
454                   <xslo:value-of select="substring(' ', 1, 1)"/>
455                 </xslo:otherwise>
456               </xslo:choose>
457             </xslo:if>
458             <xslo:value-of select="."/>
459           </xslo:if>
460         </xslo:for-each>
461       </xslo:variable>
462       <xslo:value-of select="normalize-space($raw_heading)"/>
463     </z:index>
464   </xslo:template>
465   <xslo:template mode="index_heading" match="marc:datafield[@tag='530']">
466     <z:index name="Title-uniform-see-also-from:w Title-uniform-see-also-from:p Title-uniform-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
467       <xslo:variable name="raw_heading">
468         <xslo:for-each select="marc:subfield">
469           <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Title-uniform-see-also-from:w Title-uniform-see-also-from:p Title-uniform-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
470             <xslo:if test="position() &gt; 1">
471               <xslo:choose>
472                 <xslo:when test="contains('vxyz', @code)">
473                   <xslo:text>--</xslo:text>
474                 </xslo:when>
475                 <xslo:otherwise>
476                   <xslo:value-of select="substring(' ', 1, 1)"/>
477                 </xslo:otherwise>
478               </xslo:choose>
479             </xslo:if>
480             <xslo:value-of select="."/>
481           </xslo:if>
482         </xslo:for-each>
483       </xslo:variable>
484       <xslo:value-of select="normalize-space($raw_heading)"/>
485     </z:index>
486   </xslo:template>
487   <xslo:template mode="index_heading" match="marc:datafield[@tag='148']">
488     <z:index name="Chronological-term-heading:w Chronological-term-heading:p Chronological-term-heading:s Heading:w Heading:p Heading:s">
489       <xslo:variable name="raw_heading">
490         <xslo:for-each select="marc:subfield">
491           <xslo:if test="contains('avxyz', @code)" name="Chronological-term-heading:w Chronological-term-heading:p Chronological-term-heading:s Heading:w Heading:p Heading:s">
492             <xslo:if test="position() &gt; 1">
493               <xslo:choose>
494                 <xslo:when test="contains('vxyz', @code)">
495                   <xslo:text>--</xslo:text>
496                 </xslo:when>
497                 <xslo:otherwise>
498                   <xslo:value-of select="substring(' ', 1, 1)"/>
499                 </xslo:otherwise>
500               </xslo:choose>
501             </xslo:if>
502             <xslo:value-of select="."/>
503           </xslo:if>
504         </xslo:for-each>
505       </xslo:variable>
506       <xslo:value-of select="normalize-space($raw_heading)"/>
507     </z:index>
508     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
509       <xslo:variable name="raw_heading">
510         <xslo:for-each select="marc:subfield">
511           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
512             <xslo:if test="position() &gt; 1">
513               <xslo:choose>
514                 <xslo:when test="contains('', @code)">
515                   <xslo:text>--</xslo:text>
516                 </xslo:when>
517                 <xslo:otherwise>
518                   <xslo:value-of select="substring(' ', 1, 1)"/>
519                 </xslo:otherwise>
520               </xslo:choose>
521             </xslo:if>
522             <xslo:value-of select="."/>
523           </xslo:if>
524         </xslo:for-each>
525       </xslo:variable>
526       <xslo:value-of select="normalize-space($raw_heading)"/>
527     </z:index>
528   </xslo:template>
529   <xslo:template mode="index_heading" match="marc:datafield[@tag='448']">
530     <z:index name="Chronological-term-see-from:w Chronological-term-see-from:p Chronological-term-see-from:s See-from:w See-from:p See-from:s">
531       <xslo:variable name="raw_heading">
532         <xslo:for-each select="marc:subfield">
533           <xslo:if test="contains('avxyz', @code)" name="Chronological-term-see-from:w Chronological-term-see-from:p Chronological-term-see-from:s See-from:w See-from:p See-from:s">
534             <xslo:if test="position() &gt; 1">
535               <xslo:choose>
536                 <xslo:when test="contains('vxyz', @code)">
537                   <xslo:text>--</xslo:text>
538                 </xslo:when>
539                 <xslo:otherwise>
540                   <xslo:value-of select="substring(' ', 1, 1)"/>
541                 </xslo:otherwise>
542               </xslo:choose>
543             </xslo:if>
544             <xslo:value-of select="."/>
545           </xslo:if>
546         </xslo:for-each>
547       </xslo:variable>
548       <xslo:value-of select="normalize-space($raw_heading)"/>
549     </z:index>
550   </xslo:template>
551   <xslo:template mode="index_heading" match="marc:datafield[@tag='548']">
552     <z:index name="Chronological-term-see-also-from:w Chronological-term-see-also-from:p Chronological-term-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
553       <xslo:variable name="raw_heading">
554         <xslo:for-each select="marc:subfield">
555           <xslo:if test="contains('avxyz', @code)" name="Chronological-term-see-also-from:w Chronological-term-see-also-from:p Chronological-term-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
556             <xslo:if test="position() &gt; 1">
557               <xslo:choose>
558                 <xslo:when test="contains('vxyz', @code)">
559                   <xslo:text>--</xslo:text>
560                 </xslo:when>
561                 <xslo:otherwise>
562                   <xslo:value-of select="substring(' ', 1, 1)"/>
563                 </xslo:otherwise>
564               </xslo:choose>
565             </xslo:if>
566             <xslo:value-of select="."/>
567           </xslo:if>
568         </xslo:for-each>
569       </xslo:variable>
570       <xslo:value-of select="normalize-space($raw_heading)"/>
571     </z:index>
572   </xslo:template>
573   <xslo:template mode="index_heading" match="marc:datafield[@tag='150']">
574     <z:index name="Subject-topical-heading:w Subject-topical-heading:p Subject-topical-heading:s Heading:w Heading:p Heading:s">
575       <xslo:variable name="raw_heading">
576         <xslo:for-each select="marc:subfield">
577           <xslo:if test="contains('abvxyz', @code)" name="Subject-topical-heading:w Subject-topical-heading:p Subject-topical-heading:s Heading:w Heading:p Heading:s">
578             <xslo:if test="position() &gt; 1">
579               <xslo:choose>
580                 <xslo:when test="contains('vxyz', @code)">
581                   <xslo:text>--</xslo:text>
582                 </xslo:when>
583                 <xslo:otherwise>
584                   <xslo:value-of select="substring(' ', 1, 1)"/>
585                 </xslo:otherwise>
586               </xslo:choose>
587             </xslo:if>
588             <xslo:value-of select="."/>
589           </xslo:if>
590         </xslo:for-each>
591       </xslo:variable>
592       <xslo:value-of select="normalize-space($raw_heading)"/>
593     </z:index>
594     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
595       <xslo:variable name="raw_heading">
596         <xslo:for-each select="marc:subfield">
597           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
598             <xslo:if test="position() &gt; 1">
599               <xslo:choose>
600                 <xslo:when test="contains('', @code)">
601                   <xslo:text>--</xslo:text>
602                 </xslo:when>
603                 <xslo:otherwise>
604                   <xslo:value-of select="substring(' ', 1, 1)"/>
605                 </xslo:otherwise>
606               </xslo:choose>
607             </xslo:if>
608             <xslo:value-of select="."/>
609           </xslo:if>
610         </xslo:for-each>
611       </xslo:variable>
612       <xslo:value-of select="normalize-space($raw_heading)"/>
613     </z:index>
614   </xslo:template>
615   <xslo:template mode="index_heading" match="marc:datafield[@tag='450']">
616     <z:index name="Subject-topical-see-from:w Subject-topical-see-from:p Subject-topical-see-from:s See-from:w See-from:p See-from:s">
617       <xslo:variable name="raw_heading">
618         <xslo:for-each select="marc:subfield">
619           <xslo:if test="contains('abvxyz', @code)" name="Subject-topical-see-from:w Subject-topical-see-from:p Subject-topical-see-from:s See-from:w See-from:p See-from:s">
620             <xslo:if test="position() &gt; 1">
621               <xslo:choose>
622                 <xslo:when test="contains('vxyz', @code)">
623                   <xslo:text>--</xslo:text>
624                 </xslo:when>
625                 <xslo:otherwise>
626                   <xslo:value-of select="substring(' ', 1, 1)"/>
627                 </xslo:otherwise>
628               </xslo:choose>
629             </xslo:if>
630             <xslo:value-of select="."/>
631           </xslo:if>
632         </xslo:for-each>
633       </xslo:variable>
634       <xslo:value-of select="normalize-space($raw_heading)"/>
635     </z:index>
636   </xslo:template>
637   <xslo:template mode="index_heading" match="marc:datafield[@tag='550']">
638     <z:index name="Subject-topical-see-also-from:w Subject-topical-see-also-from:p Subject-topical-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
639       <xslo:variable name="raw_heading">
640         <xslo:for-each select="marc:subfield">
641           <xslo:if test="contains('abvxyz', @code)" name="Subject-topical-see-also-from:w Subject-topical-see-also-from:p Subject-topical-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
642             <xslo:if test="position() &gt; 1">
643               <xslo:choose>
644                 <xslo:when test="contains('vxyz', @code)">
645                   <xslo:text>--</xslo:text>
646                 </xslo:when>
647                 <xslo:otherwise>
648                   <xslo:value-of select="substring(' ', 1, 1)"/>
649                 </xslo:otherwise>
650               </xslo:choose>
651             </xslo:if>
652             <xslo:value-of select="."/>
653           </xslo:if>
654         </xslo:for-each>
655       </xslo:variable>
656       <xslo:value-of select="normalize-space($raw_heading)"/>
657     </z:index>
658   </xslo:template>
659   <xslo:template mode="index_heading" match="marc:datafield[@tag='151']">
660     <z:index name="Name-geographic-heading:w Name-geographic-heading:p Name-geographic-heading:s Heading:w Heading:p Heading:s">
661       <xslo:variable name="raw_heading">
662         <xslo:for-each select="marc:subfield">
663           <xslo:if test="contains('avxyz', @code)" name="Name-geographic-heading:w Name-geographic-heading:p Name-geographic-heading:s Heading:w Heading:p Heading:s">
664             <xslo:if test="position() &gt; 1">
665               <xslo:choose>
666                 <xslo:when test="contains('vxyz', @code)">
667                   <xslo:text>--</xslo:text>
668                 </xslo:when>
669                 <xslo:otherwise>
670                   <xslo:value-of select="substring(' ', 1, 1)"/>
671                 </xslo:otherwise>
672               </xslo:choose>
673             </xslo:if>
674             <xslo:value-of select="."/>
675           </xslo:if>
676         </xslo:for-each>
677       </xslo:variable>
678       <xslo:value-of select="normalize-space($raw_heading)"/>
679     </z:index>
680     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
681       <xslo:variable name="raw_heading">
682         <xslo:for-each select="marc:subfield">
683           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
684             <xslo:if test="position() &gt; 1">
685               <xslo:choose>
686                 <xslo:when test="contains('', @code)">
687                   <xslo:text>--</xslo:text>
688                 </xslo:when>
689                 <xslo:otherwise>
690                   <xslo:value-of select="substring(' ', 1, 1)"/>
691                 </xslo:otherwise>
692               </xslo:choose>
693             </xslo:if>
694             <xslo:value-of select="."/>
695           </xslo:if>
696         </xslo:for-each>
697       </xslo:variable>
698       <xslo:value-of select="normalize-space($raw_heading)"/>
699     </z:index>
700   </xslo:template>
701   <xslo:template mode="index_heading" match="marc:datafield[@tag='451']">
702     <z:index name="Name-geographic-see-from:w Name-geographic-see-from:p Name-geographic-see-from:s See-from:w See-from:p See-from:s">
703       <xslo:variable name="raw_heading">
704         <xslo:for-each select="marc:subfield">
705           <xslo:if test="contains('avxyz', @code)" name="Name-geographic-see-from:w Name-geographic-see-from:p Name-geographic-see-from:s See-from:w See-from:p See-from:s">
706             <xslo:if test="position() &gt; 1">
707               <xslo:choose>
708                 <xslo:when test="contains('vxyz', @code)">
709                   <xslo:text>--</xslo:text>
710                 </xslo:when>
711                 <xslo:otherwise>
712                   <xslo:value-of select="substring(' ', 1, 1)"/>
713                 </xslo:otherwise>
714               </xslo:choose>
715             </xslo:if>
716             <xslo:value-of select="."/>
717           </xslo:if>
718         </xslo:for-each>
719       </xslo:variable>
720       <xslo:value-of select="normalize-space($raw_heading)"/>
721     </z:index>
722   </xslo:template>
723   <xslo:template mode="index_heading" match="marc:datafield[@tag='551']">
724     <z:index name="Name-geographic-see-also-from:w Name-geographic-see-also-from:p Name-geographic-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
725       <xslo:variable name="raw_heading">
726         <xslo:for-each select="marc:subfield">
727           <xslo:if test="contains('avxyz', @code)" name="Name-geographic-see-also-from:w Name-geographic-see-also-from:p Name-geographic-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
728             <xslo:if test="position() &gt; 1">
729               <xslo:choose>
730                 <xslo:when test="contains('vxyz', @code)">
731                   <xslo:text>--</xslo:text>
732                 </xslo:when>
733                 <xslo:otherwise>
734                   <xslo:value-of select="substring(' ', 1, 1)"/>
735                 </xslo:otherwise>
736               </xslo:choose>
737             </xslo:if>
738             <xslo:value-of select="."/>
739           </xslo:if>
740         </xslo:for-each>
741       </xslo:variable>
742       <xslo:value-of select="normalize-space($raw_heading)"/>
743     </z:index>
744   </xslo:template>
745   <xslo:template mode="index_heading" match="marc:datafield[@tag='155']">
746     <z:index name="Term-genre-form-heading:w Term-genre-form-heading:p Term-genre-form-heading:s Heading:w Heading:p Heading:s">
747       <xslo:variable name="raw_heading">
748         <xslo:for-each select="marc:subfield">
749           <xslo:if test="contains('avxyz', @code)" name="Term-genre-form-heading:w Term-genre-form-heading:p Term-genre-form-heading:s Heading:w Heading:p Heading:s">
750             <xslo:if test="position() &gt; 1">
751               <xslo:choose>
752                 <xslo:when test="contains('vxyz', @code)">
753                   <xslo:text>--</xslo:text>
754                 </xslo:when>
755                 <xslo:otherwise>
756                   <xslo:value-of select="substring(' ', 1, 1)"/>
757                 </xslo:otherwise>
758               </xslo:choose>
759             </xslo:if>
760             <xslo:value-of select="."/>
761           </xslo:if>
762         </xslo:for-each>
763       </xslo:variable>
764       <xslo:value-of select="normalize-space($raw_heading)"/>
765     </z:index>
766     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
767       <xslo:variable name="raw_heading">
768         <xslo:for-each select="marc:subfield">
769           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
770             <xslo:if test="position() &gt; 1">
771               <xslo:choose>
772                 <xslo:when test="contains('', @code)">
773                   <xslo:text>--</xslo:text>
774                 </xslo:when>
775                 <xslo:otherwise>
776                   <xslo:value-of select="substring(' ', 1, 1)"/>
777                 </xslo:otherwise>
778               </xslo:choose>
779             </xslo:if>
780             <xslo:value-of select="."/>
781           </xslo:if>
782         </xslo:for-each>
783       </xslo:variable>
784       <xslo:value-of select="normalize-space($raw_heading)"/>
785     </z:index>
786   </xslo:template>
787   <xslo:template mode="index_heading" match="marc:datafield[@tag='455']">
788     <z:index name="Term-genre-form-see-from:w Term-genre-form-see-from:p Term-genre-form-see-from:s See-from:w See-from:p See-from:s">
789       <xslo:variable name="raw_heading">
790         <xslo:for-each select="marc:subfield">
791           <xslo:if test="contains('avxyz', @code)" name="Term-genre-form-see-from:w Term-genre-form-see-from:p Term-genre-form-see-from:s See-from:w See-from:p See-from:s">
792             <xslo:if test="position() &gt; 1">
793               <xslo:choose>
794                 <xslo:when test="contains('vxyz', @code)">
795                   <xslo:text>--</xslo:text>
796                 </xslo:when>
797                 <xslo:otherwise>
798                   <xslo:value-of select="substring(' ', 1, 1)"/>
799                 </xslo:otherwise>
800               </xslo:choose>
801             </xslo:if>
802             <xslo:value-of select="."/>
803           </xslo:if>
804         </xslo:for-each>
805       </xslo:variable>
806       <xslo:value-of select="normalize-space($raw_heading)"/>
807     </z:index>
808   </xslo:template>
809   <xslo:template mode="index_heading" match="marc:datafield[@tag='555']">
810     <z:index name="Term-genre-form-see-also-from:w Term-genre-form-see-also-from:p Term-genre-form-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
811       <xslo:variable name="raw_heading">
812         <xslo:for-each select="marc:subfield">
813           <xslo:if test="contains('avxyz', @code)" name="Term-genre-form-see-also-from:w Term-genre-form-see-also-from:p Term-genre-form-see-also-from:s See-also-from:w See-also-from:p See-also-from:s">
814             <xslo:if test="position() &gt; 1">
815               <xslo:choose>
816                 <xslo:when test="contains('vxyz', @code)">
817                   <xslo:text>--</xslo:text>
818                 </xslo:when>
819                 <xslo:otherwise>
820                   <xslo:value-of select="substring(' ', 1, 1)"/>
821                 </xslo:otherwise>
822               </xslo:choose>
823             </xslo:if>
824             <xslo:value-of select="."/>
825           </xslo:if>
826         </xslo:for-each>
827       </xslo:variable>
828       <xslo:value-of select="normalize-space($raw_heading)"/>
829     </z:index>
830   </xslo:template>
831   <xslo:template mode="index_heading" match="marc:datafield[@tag='180']">
832     <z:index name="General-subdivision:w General-subdivision:p General-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
833       <xslo:variable name="raw_heading">
834         <xslo:for-each select="marc:subfield">
835           <xslo:if test="contains('vxyz', @code)" name="General-subdivision:w General-subdivision:p General-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
836             <xslo:if test="position() &gt; 1">
837               <xslo:choose>
838                 <xslo:when test="contains('vxyz', @code)">
839                   <xslo:text>--</xslo:text>
840                 </xslo:when>
841                 <xslo:otherwise>
842                   <xslo:value-of select="substring(' ', 1, 1)"/>
843                 </xslo:otherwise>
844               </xslo:choose>
845             </xslo:if>
846             <xslo:value-of select="."/>
847           </xslo:if>
848         </xslo:for-each>
849       </xslo:variable>
850       <xslo:value-of select="normalize-space($raw_heading)"/>
851     </z:index>
852   </xslo:template>
853   <xslo:template mode="index_heading" match="marc:datafield[@tag='480']">
854     <z:index name="General-subdivision-see-from:w General-subdivision-see-from:p General-subdivision-see-from:s Subdivision-see-from:w Subdivision-see-from:p Subdivision-see-from:s">
855       <xslo:variable name="raw_heading">
856         <xslo:for-each select="marc:subfield">
857           <xslo:if test="contains('vxyz', @code)" name="General-subdivision-see-from:w General-subdivision-see-from:p General-subdivision-see-from:s Subdivision-see-from:w Subdivision-see-from:p Subdivision-see-from:s">
858             <xslo:if test="position() &gt; 1">
859               <xslo:choose>
860                 <xslo:when test="contains('vxyz', @code)">
861                   <xslo:text>--</xslo:text>
862                 </xslo:when>
863                 <xslo:otherwise>
864                   <xslo:value-of select="substring(' ', 1, 1)"/>
865                 </xslo:otherwise>
866               </xslo:choose>
867             </xslo:if>
868             <xslo:value-of select="."/>
869           </xslo:if>
870         </xslo:for-each>
871       </xslo:variable>
872       <xslo:value-of select="normalize-space($raw_heading)"/>
873     </z:index>
874   </xslo:template>
875   <xslo:template mode="index_heading" match="marc:datafield[@tag='580']">
876     <z:index name="General-subdivision-see-also-from:w General-subdivision-see-also-from:p General-subdivision-see-also-from:s Subdivision-see-also-from:w Subdivision-see-also-from:p Subdivision-see-also-from:s">
877       <xslo:variable name="raw_heading">
878         <xslo:for-each select="marc:subfield">
879           <xslo:if test="contains('vxyz', @code)" name="General-subdivision-see-also-from:w General-subdivision-see-also-from:p General-subdivision-see-also-from:s Subdivision-see-also-from:w Subdivision-see-also-from:p Subdivision-see-also-from:s">
880             <xslo:if test="position() &gt; 1">
881               <xslo:choose>
882                 <xslo:when test="contains('vxyz', @code)">
883                   <xslo:text>--</xslo:text>
884                 </xslo:when>
885                 <xslo:otherwise>
886                   <xslo:value-of select="substring(' ', 1, 1)"/>
887                 </xslo:otherwise>
888               </xslo:choose>
889             </xslo:if>
890             <xslo:value-of select="."/>
891           </xslo:if>
892         </xslo:for-each>
893       </xslo:variable>
894       <xslo:value-of select="normalize-space($raw_heading)"/>
895     </z:index>
896   </xslo:template>
897   <xslo:template mode="index_heading" match="marc:datafield[@tag='181']">
898     <z:index name="Geographic-subdivision:w Geographic-subdivision:p Geographic-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
899       <xslo:variable name="raw_heading">
900         <xslo:for-each select="marc:subfield">
901           <xslo:if test="contains('vxyz', @code)" name="Geographic-subdivision:w Geographic-subdivision:p Geographic-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
902             <xslo:if test="position() &gt; 1">
903               <xslo:choose>
904                 <xslo:when test="contains('vxyz', @code)">
905                   <xslo:text>--</xslo:text>
906                 </xslo:when>
907                 <xslo:otherwise>
908                   <xslo:value-of select="substring(' ', 1, 1)"/>
909                 </xslo:otherwise>
910               </xslo:choose>
911             </xslo:if>
912             <xslo:value-of select="."/>
913           </xslo:if>
914         </xslo:for-each>
915       </xslo:variable>
916       <xslo:value-of select="normalize-space($raw_heading)"/>
917     </z:index>
918   </xslo:template>
919   <xslo:template mode="index_heading" match="marc:datafield[@tag='481']">
920     <z:index name="Geographic-subdivision-see-from:w Geographic-subdivision-see-from:p Geographic-subdivision-see-from:s Subdivision-see-from:w Subdivision-see-from:p Subdivision-see-from:s">
921       <xslo:variable name="raw_heading">
922         <xslo:for-each select="marc:subfield">
923           <xslo:if test="contains('vxyz', @code)" name="Geographic-subdivision-see-from:w Geographic-subdivision-see-from:p Geographic-subdivision-see-from:s Subdivision-see-from:w Subdivision-see-from:p Subdivision-see-from:s">
924             <xslo:if test="position() &gt; 1">
925               <xslo:choose>
926                 <xslo:when test="contains('vxyz', @code)">
927                   <xslo:text>--</xslo:text>
928                 </xslo:when>
929                 <xslo:otherwise>
930                   <xslo:value-of select="substring(' ', 1, 1)"/>
931                 </xslo:otherwise>
932               </xslo:choose>
933             </xslo:if>
934             <xslo:value-of select="."/>
935           </xslo:if>
936         </xslo:for-each>
937       </xslo:variable>
938       <xslo:value-of select="normalize-space($raw_heading)"/>
939     </z:index>
940   </xslo:template>
941   <xslo:template mode="index_heading" match="marc:datafield[@tag='581']">
942     <z:index name="Geographic-subdivision-see-also-from:w Geographic-subdivision-see-also-from:p Geographic-subdivision-see-also-from:s Subdivision-see-also-from:w Subdivision-see-also-from:p Subdivision-see-also-from:s">
943       <xslo:variable name="raw_heading">
944         <xslo:for-each select="marc:subfield">
945           <xslo:if test="contains('vxyz', @code)" name="Geographic-subdivision-see-also-from:w Geographic-subdivision-see-also-from:p Geographic-subdivision-see-also-from:s Subdivision-see-also-from:w Subdivision-see-also-from:p Subdivision-see-also-from:s">
946             <xslo:if test="position() &gt; 1">
947               <xslo:choose>
948                 <xslo:when test="contains('vxyz', @code)">
949                   <xslo:text>--</xslo:text>
950                 </xslo:when>
951                 <xslo:otherwise>
952                   <xslo:value-of select="substring(' ', 1, 1)"/>
953                 </xslo:otherwise>
954               </xslo:choose>
955             </xslo:if>
956             <xslo:value-of select="."/>
957           </xslo:if>
958         </xslo:for-each>
959       </xslo:variable>
960       <xslo:value-of select="normalize-space($raw_heading)"/>
961     </z:index>
962   </xslo:template>
963   <xslo:template mode="index_heading" match="marc:datafield[@tag='182']">
964     <z:index name="Chronological-subdivision:w Chronological-subdivision:p Chronological-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
965       <xslo:variable name="raw_heading">
966         <xslo:for-each select="marc:subfield">
967           <xslo:if test="contains('vxyz', @code)" name="Chronological-subdivision:w Chronological-subdivision:p Chronological-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
968             <xslo:if test="position() &gt; 1">
969               <xslo:choose>
970                 <xslo:when test="contains('vxyz', @code)">
971                   <xslo:text>--</xslo:text>
972                 </xslo:when>
973                 <xslo:otherwise>
974                   <xslo:value-of select="substring(' ', 1, 1)"/>
975                 </xslo:otherwise>
976               </xslo:choose>
977             </xslo:if>
978             <xslo:value-of select="."/>
979           </xslo:if>
980         </xslo:for-each>
981       </xslo:variable>
982       <xslo:value-of select="normalize-space($raw_heading)"/>
983     </z:index>
984   </xslo:template>
985   <xslo:template mode="index_heading" match="marc:datafield[@tag='482']">
986     <z:index name="Chronological-subdivision-see-from:w Chronological-subdivision-see-from:p Chronological-subdivision-see-from:s Subdivision-see-from:w Subdivision-see-from:p Subdivision-see-from:s">
987       <xslo:variable name="raw_heading">
988         <xslo:for-each select="marc:subfield">
989           <xslo:if test="contains('vxyz', @code)" name="Chronological-subdivision-see-from:w Chronological-subdivision-see-from:p Chronological-subdivision-see-from:s Subdivision-see-from:w Subdivision-see-from:p Subdivision-see-from:s">
990             <xslo:if test="position() &gt; 1">
991               <xslo:choose>
992                 <xslo:when test="contains('vxyz', @code)">
993                   <xslo:text>--</xslo:text>
994                 </xslo:when>
995                 <xslo:otherwise>
996                   <xslo:value-of select="substring(' ', 1, 1)"/>
997                 </xslo:otherwise>
998               </xslo:choose>
999             </xslo:if>
1000             <xslo:value-of select="."/>
1001           </xslo:if>
1002         </xslo:for-each>
1003       </xslo:variable>
1004       <xslo:value-of select="normalize-space($raw_heading)"/>
1005     </z:index>
1006   </xslo:template>
1007   <xslo:template mode="index_heading" match="marc:datafield[@tag='582']">
1008     <z:index name="Chronological-subdivision-see-also-from:w Chronological-subdivision-see-also-from:p Chronological-subdivision-see-also-from:s Subdivision-see-also-from:w Subdivision-see-also-from:p Subdivision-see-also-from:s">
1009       <xslo:variable name="raw_heading">
1010         <xslo:for-each select="marc:subfield">
1011           <xslo:if test="contains('vxyz', @code)" name="Chronological-subdivision-see-also-from:w Chronological-subdivision-see-also-from:p Chronological-subdivision-see-also-from:s Subdivision-see-also-from:w Subdivision-see-also-from:p Subdivision-see-also-from:s">
1012             <xslo:if test="position() &gt; 1">
1013               <xslo:choose>
1014                 <xslo:when test="contains('vxyz', @code)">
1015                   <xslo:text>--</xslo:text>
1016                 </xslo:when>
1017                 <xslo:otherwise>
1018                   <xslo:value-of select="substring(' ', 1, 1)"/>
1019                 </xslo:otherwise>
1020               </xslo:choose>
1021             </xslo:if>
1022             <xslo:value-of select="."/>
1023           </xslo:if>
1024         </xslo:for-each>
1025       </xslo:variable>
1026       <xslo:value-of select="normalize-space($raw_heading)"/>
1027     </z:index>
1028   </xslo:template>
1029   <xslo:template mode="index_heading" match="marc:datafield[@tag='185']">
1030     <z:index name="Form-subdivision:w Form-subdivision:p Form-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
1031       <xslo:variable name="raw_heading">
1032         <xslo:for-each select="marc:subfield">
1033           <xslo:if test="contains('vxyz', @code)" name="Form-subdivision:w Form-subdivision:p Form-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
1034             <xslo:if test="position() &gt; 1">
1035               <xslo:choose>
1036                 <xslo:when test="contains('vxyz', @code)">
1037                   <xslo:text>--</xslo:text>
1038                 </xslo:when>
1039                 <xslo:otherwise>
1040                   <xslo:value-of select="substring(' ', 1, 1)"/>
1041                 </xslo:otherwise>
1042               </xslo:choose>
1043             </xslo:if>
1044             <xslo:value-of select="."/>
1045           </xslo:if>
1046         </xslo:for-each>
1047       </xslo:variable>
1048       <xslo:value-of select="normalize-space($raw_heading)"/>
1049     </z:index>
1050   </xslo:template>
1051   <xslo:template mode="index_heading" match="marc:datafield[@tag='485']">
1052     <z:index name="Form-subdivision-see-from:w Form-subdivision-see-from:p Form-subdivision-see-from:s Subdivision-see-from:w Subdivision-see-from:p Subdivision-see-from:s">
1053       <xslo:variable name="raw_heading">
1054         <xslo:for-each select="marc:subfield">
1055           <xslo:if test="contains('vxyz', @code)" name="Form-subdivision-see-from:w Form-subdivision-see-from:p Form-subdivision-see-from:s Subdivision-see-from:w Subdivision-see-from:p Subdivision-see-from:s">
1056             <xslo:if test="position() &gt; 1">
1057               <xslo:choose>
1058                 <xslo:when test="contains('vxyz', @code)">
1059                   <xslo:text>--</xslo:text>
1060                 </xslo:when>
1061                 <xslo:otherwise>
1062                   <xslo:value-of select="substring(' ', 1, 1)"/>
1063                 </xslo:otherwise>
1064               </xslo:choose>
1065             </xslo:if>
1066             <xslo:value-of select="."/>
1067           </xslo:if>
1068         </xslo:for-each>
1069       </xslo:variable>
1070       <xslo:value-of select="normalize-space($raw_heading)"/>
1071     </z:index>
1072   </xslo:template>
1073   <xslo:template mode="index_heading" match="marc:datafield[@tag='585']">
1074     <z:index name="Form-subdivision-see-also-from:w Form-subdivision-see-also-from:p Form-subdivision-see-also-from:s Subdivision-see-also-from:w Subdivision-see-also-from:p Subdivision-see-also-from:s">
1075       <xslo:variable name="raw_heading">
1076         <xslo:for-each select="marc:subfield">
1077           <xslo:if test="contains('vxyz', @code)" name="Form-subdivision-see-also-from:w Form-subdivision-see-also-from:p Form-subdivision-see-also-from:s Subdivision-see-also-from:w Subdivision-see-also-from:p Subdivision-see-also-from:s">
1078             <xslo:if test="position() &gt; 1">
1079               <xslo:choose>
1080                 <xslo:when test="contains('vxyz', @code)">
1081                   <xslo:text>--</xslo:text>
1082                 </xslo:when>
1083                 <xslo:otherwise>
1084                   <xslo:value-of select="substring(' ', 1, 1)"/>
1085                 </xslo:otherwise>
1086               </xslo:choose>
1087             </xslo:if>
1088             <xslo:value-of select="."/>
1089           </xslo:if>
1090         </xslo:for-each>
1091       </xslo:variable>
1092       <xslo:value-of select="normalize-space($raw_heading)"/>
1093     </z:index>
1094   </xslo:template>
1095   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='100']">
1096     <z:index name="Match-heading:p Match-heading:s">
1097       <xslo:variable name="raw_heading">
1098         <xslo:for-each select="marc:subfield">
1099           <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Match-heading:p Match-heading:s">
1100             <xslo:if test="position() &gt; 1">
1101               <xslo:choose>
1102                 <xslo:when test="contains('vxyz', @code)">
1103                   <xslo:choose>
1104                     <xslo:when test="@code = $general_subdivision_subfield">
1105                       <xslo:text> generalsubdiv </xslo:text>
1106                     </xslo:when>
1107                     <xslo:when test="@code = $form_subdivision_subfield">
1108                       <xslo:text> formsubdiv </xslo:text>
1109                     </xslo:when>
1110                     <xslo:when test="@code = $chronological_subdivision_subfield">
1111                       <xslo:text> chronologicalsubdiv </xslo:text>
1112                     </xslo:when>
1113                     <xslo:when test="@code = $geographic_subdivision_subfield">
1114                       <xslo:text> geographicsubdiv </xslo:text>
1115                     </xslo:when>
1116                   </xslo:choose>
1117                 </xslo:when>
1118                 <xslo:otherwise>
1119                   <xslo:value-of select="substring(' ', 1, 1)"/>
1120                 </xslo:otherwise>
1121               </xslo:choose>
1122             </xslo:if>
1123             <xslo:value-of select="."/>
1124           </xslo:if>
1125         </xslo:for-each>
1126       </xslo:variable>
1127       <xslo:value-of select="normalize-space($raw_heading)"/>
1128     </z:index>
1129   </xslo:template>
1130   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='400']">
1131     <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
1132       <xslo:variable name="raw_heading">
1133         <xslo:for-each select="marc:subfield">
1134           <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
1135             <xslo:if test="position() &gt; 1">
1136               <xslo:choose>
1137                 <xslo:when test="contains('vxyz', @code)">
1138                   <xslo:choose>
1139                     <xslo:when test="@code = $general_subdivision_subfield">
1140                       <xslo:text> generalsubdiv </xslo:text>
1141                     </xslo:when>
1142                     <xslo:when test="@code = $form_subdivision_subfield">
1143                       <xslo:text> formsubdiv </xslo:text>
1144                     </xslo:when>
1145                     <xslo:when test="@code = $chronological_subdivision_subfield">
1146                       <xslo:text> chronologicalsubdiv </xslo:text>
1147                     </xslo:when>
1148                     <xslo:when test="@code = $geographic_subdivision_subfield">
1149                       <xslo:text> geographicsubdiv </xslo:text>
1150                     </xslo:when>
1151                   </xslo:choose>
1152                 </xslo:when>
1153                 <xslo:otherwise>
1154                   <xslo:value-of select="substring(' ', 1, 1)"/>
1155                 </xslo:otherwise>
1156               </xslo:choose>
1157             </xslo:if>
1158             <xslo:value-of select="."/>
1159           </xslo:if>
1160         </xslo:for-each>
1161       </xslo:variable>
1162       <xslo:value-of select="normalize-space($raw_heading)"/>
1163     </z:index>
1164   </xslo:template>
1165   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='110']">
1166     <z:index name="Match-heading:p Match-heading:s">
1167       <xslo:variable name="raw_heading">
1168         <xslo:for-each select="marc:subfield">
1169           <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Match-heading:p Match-heading:s">
1170             <xslo:if test="position() &gt; 1">
1171               <xslo:choose>
1172                 <xslo:when test="contains('vxyz', @code)">
1173                   <xslo:choose>
1174                     <xslo:when test="@code = $general_subdivision_subfield">
1175                       <xslo:text> generalsubdiv </xslo:text>
1176                     </xslo:when>
1177                     <xslo:when test="@code = $form_subdivision_subfield">
1178                       <xslo:text> formsubdiv </xslo:text>
1179                     </xslo:when>
1180                     <xslo:when test="@code = $chronological_subdivision_subfield">
1181                       <xslo:text> chronologicalsubdiv </xslo:text>
1182                     </xslo:when>
1183                     <xslo:when test="@code = $geographic_subdivision_subfield">
1184                       <xslo:text> geographicsubdiv </xslo:text>
1185                     </xslo:when>
1186                   </xslo:choose>
1187                 </xslo:when>
1188                 <xslo:otherwise>
1189                   <xslo:value-of select="substring(' ', 1, 1)"/>
1190                 </xslo:otherwise>
1191               </xslo:choose>
1192             </xslo:if>
1193             <xslo:value-of select="."/>
1194           </xslo:if>
1195         </xslo:for-each>
1196       </xslo:variable>
1197       <xslo:value-of select="normalize-space($raw_heading)"/>
1198     </z:index>
1199   </xslo:template>
1200   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='410']">
1201     <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
1202       <xslo:variable name="raw_heading">
1203         <xslo:for-each select="marc:subfield">
1204           <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
1205             <xslo:if test="position() &gt; 1">
1206               <xslo:choose>
1207                 <xslo:when test="contains('vxyz', @code)">
1208                   <xslo:choose>
1209                     <xslo:when test="@code = $general_subdivision_subfield">
1210                       <xslo:text> generalsubdiv </xslo:text>
1211                     </xslo:when>
1212                     <xslo:when test="@code = $form_subdivision_subfield">
1213                       <xslo:text> formsubdiv </xslo:text>
1214                     </xslo:when>
1215                     <xslo:when test="@code = $chronological_subdivision_subfield">
1216                       <xslo:text> chronologicalsubdiv </xslo:text>
1217                     </xslo:when>
1218                     <xslo:when test="@code = $geographic_subdivision_subfield">
1219                       <xslo:text> geographicsubdiv </xslo:text>
1220                     </xslo:when>
1221                   </xslo:choose>
1222                 </xslo:when>
1223                 <xslo:otherwise>
1224                   <xslo:value-of select="substring(' ', 1, 1)"/>
1225                 </xslo:otherwise>
1226               </xslo:choose>
1227             </xslo:if>
1228             <xslo:value-of select="."/>
1229           </xslo:if>
1230         </xslo:for-each>
1231       </xslo:variable>
1232       <xslo:value-of select="normalize-space($raw_heading)"/>
1233     </z:index>
1234   </xslo:template>
1235   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='111']">
1236     <z:index name="Match-heading:p Match-heading:s">
1237       <xslo:variable name="raw_heading">
1238         <xslo:for-each select="marc:subfield">
1239           <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Match-heading:p Match-heading:s">
1240             <xslo:if test="position() &gt; 1">
1241               <xslo:choose>
1242                 <xslo:when test="contains('vxyz', @code)">
1243                   <xslo:choose>
1244                     <xslo:when test="@code = $general_subdivision_subfield">
1245                       <xslo:text> generalsubdiv </xslo:text>
1246                     </xslo:when>
1247                     <xslo:when test="@code = $form_subdivision_subfield">
1248                       <xslo:text> formsubdiv </xslo:text>
1249                     </xslo:when>
1250                     <xslo:when test="@code = $chronological_subdivision_subfield">
1251                       <xslo:text> chronologicalsubdiv </xslo:text>
1252                     </xslo:when>
1253                     <xslo:when test="@code = $geographic_subdivision_subfield">
1254                       <xslo:text> geographicsubdiv </xslo:text>
1255                     </xslo:when>
1256                   </xslo:choose>
1257                 </xslo:when>
1258                 <xslo:otherwise>
1259                   <xslo:value-of select="substring(' ', 1, 1)"/>
1260                 </xslo:otherwise>
1261               </xslo:choose>
1262             </xslo:if>
1263             <xslo:value-of select="."/>
1264           </xslo:if>
1265         </xslo:for-each>
1266       </xslo:variable>
1267       <xslo:value-of select="normalize-space($raw_heading)"/>
1268     </z:index>
1269   </xslo:template>
1270   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='411']">
1271     <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
1272       <xslo:variable name="raw_heading">
1273         <xslo:for-each select="marc:subfield">
1274           <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
1275             <xslo:if test="position() &gt; 1">
1276               <xslo:choose>
1277                 <xslo:when test="contains('vxyz', @code)">
1278                   <xslo:choose>
1279                     <xslo:when test="@code = $general_subdivision_subfield">
1280                       <xslo:text> generalsubdiv </xslo:text>
1281                     </xslo:when>
1282                     <xslo:when test="@code = $form_subdivision_subfield">
1283                       <xslo:text> formsubdiv </xslo:text>
1284                     </xslo:when>
1285                     <xslo:when test="@code = $chronological_subdivision_subfield">
1286                       <xslo:text> chronologicalsubdiv </xslo:text>
1287                     </xslo:when>
1288                     <xslo:when test="@code = $geographic_subdivision_subfield">
1289                       <xslo:text> geographicsubdiv </xslo:text>
1290                     </xslo:when>
1291                   </xslo:choose>
1292                 </xslo:when>
1293                 <xslo:otherwise>
1294                   <xslo:value-of select="substring(' ', 1, 1)"/>
1295                 </xslo:otherwise>
1296               </xslo:choose>
1297             </xslo:if>
1298             <xslo:value-of select="."/>
1299           </xslo:if>
1300         </xslo:for-each>
1301       </xslo:variable>
1302       <xslo:value-of select="normalize-space($raw_heading)"/>
1303     </z:index>
1304   </xslo:template>
1305   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='130']">
1306     <z:index name="Match-heading:p Match-heading:s">
1307       <xslo:variable name="raw_heading">
1308         <xslo:for-each select="marc:subfield">
1309           <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Match-heading:p Match-heading:s">
1310             <xslo:if test="position() &gt; 1">
1311               <xslo:choose>
1312                 <xslo:when test="contains('vxyz', @code)">
1313                   <xslo:choose>
1314                     <xslo:when test="@code = $general_subdivision_subfield">
1315                       <xslo:text> generalsubdiv </xslo:text>
1316                     </xslo:when>
1317                     <xslo:when test="@code = $form_subdivision_subfield">
1318                       <xslo:text> formsubdiv </xslo:text>
1319                     </xslo:when>
1320                     <xslo:when test="@code = $chronological_subdivision_subfield">
1321                       <xslo:text> chronologicalsubdiv </xslo:text>
1322                     </xslo:when>
1323                     <xslo:when test="@code = $geographic_subdivision_subfield">
1324                       <xslo:text> geographicsubdiv </xslo:text>
1325                     </xslo:when>
1326                   </xslo:choose>
1327                 </xslo:when>
1328                 <xslo:otherwise>
1329                   <xslo:value-of select="substring(' ', 1, 1)"/>
1330                 </xslo:otherwise>
1331               </xslo:choose>
1332             </xslo:if>
1333             <xslo:value-of select="."/>
1334           </xslo:if>
1335         </xslo:for-each>
1336       </xslo:variable>
1337       <xslo:value-of select="normalize-space($raw_heading)"/>
1338     </z:index>
1339   </xslo:template>
1340   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='430']">
1341     <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
1342       <xslo:variable name="raw_heading">
1343         <xslo:for-each select="marc:subfield">
1344           <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
1345             <xslo:if test="position() &gt; 1">
1346               <xslo:choose>
1347                 <xslo:when test="contains('vxyz', @code)">
1348                   <xslo:choose>
1349                     <xslo:when test="@code = $general_subdivision_subfield">
1350                       <xslo:text> generalsubdiv </xslo:text>
1351                     </xslo:when>
1352                     <xslo:when test="@code = $form_subdivision_subfield">
1353                       <xslo:text> formsubdiv </xslo:text>
1354                     </xslo:when>
1355                     <xslo:when test="@code = $chronological_subdivision_subfield">
1356                       <xslo:text> chronologicalsubdiv </xslo:text>
1357                     </xslo:when>
1358                     <xslo:when test="@code = $geographic_subdivision_subfield">
1359                       <xslo:text> geographicsubdiv </xslo:text>
1360                     </xslo:when>
1361                   </xslo:choose>
1362                 </xslo:when>
1363                 <xslo:otherwise>
1364                   <xslo:value-of select="substring(' ', 1, 1)"/>
1365                 </xslo:otherwise>
1366               </xslo:choose>
1367             </xslo:if>
1368             <xslo:value-of select="."/>
1369           </xslo:if>
1370         </xslo:for-each>
1371       </xslo:variable>
1372       <xslo:value-of select="normalize-space($raw_heading)"/>
1373     </z:index>
1374   </xslo:template>
1375   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='148']">
1376     <z:index name="Match-heading:p Match-heading:s">
1377       <xslo:variable name="raw_heading">
1378         <xslo:for-each select="marc:subfield">
1379           <xslo:if test="contains('avxyz', @code)" name="Match-heading:p Match-heading:s">
1380             <xslo:if test="position() &gt; 1">
1381               <xslo:choose>
1382                 <xslo:when test="contains('vxyz', @code)">
1383                   <xslo:choose>
1384                     <xslo:when test="@code = $general_subdivision_subfield">
1385                       <xslo:text> generalsubdiv </xslo:text>
1386                     </xslo:when>
1387                     <xslo:when test="@code = $form_subdivision_subfield">
1388                       <xslo:text> formsubdiv </xslo:text>
1389                     </xslo:when>
1390                     <xslo:when test="@code = $chronological_subdivision_subfield">
1391                       <xslo:text> chronologicalsubdiv </xslo:text>
1392                     </xslo:when>
1393                     <xslo:when test="@code = $geographic_subdivision_subfield">
1394                       <xslo:text> geographicsubdiv </xslo:text>
1395                     </xslo:when>
1396                   </xslo:choose>
1397                 </xslo:when>
1398                 <xslo:otherwise>
1399                   <xslo:value-of select="substring(' ', 1, 1)"/>
1400                 </xslo:otherwise>
1401               </xslo:choose>
1402             </xslo:if>
1403             <xslo:value-of select="."/>
1404           </xslo:if>
1405         </xslo:for-each>
1406       </xslo:variable>
1407       <xslo:value-of select="normalize-space($raw_heading)"/>
1408     </z:index>
1409   </xslo:template>
1410   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='448']">
1411     <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
1412       <xslo:variable name="raw_heading">
1413         <xslo:for-each select="marc:subfield">
1414           <xslo:if test="contains('avxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
1415             <xslo:if test="position() &gt; 1">
1416               <xslo:choose>
1417                 <xslo:when test="contains('vxyz', @code)">
1418                   <xslo:choose>
1419                     <xslo:when test="@code = $general_subdivision_subfield">
1420                       <xslo:text> generalsubdiv </xslo:text>
1421                     </xslo:when>
1422                     <xslo:when test="@code = $form_subdivision_subfield">
1423                       <xslo:text> formsubdiv </xslo:text>
1424                     </xslo:when>
1425                     <xslo:when test="@code = $chronological_subdivision_subfield">
1426                       <xslo:text> chronologicalsubdiv </xslo:text>
1427                     </xslo:when>
1428                     <xslo:when test="@code = $geographic_subdivision_subfield">
1429                       <xslo:text> geographicsubdiv </xslo:text>
1430                     </xslo:when>
1431                   </xslo:choose>
1432                 </xslo:when>
1433                 <xslo:otherwise>
1434                   <xslo:value-of select="substring(' ', 1, 1)"/>
1435                 </xslo:otherwise>
1436               </xslo:choose>
1437             </xslo:if>
1438             <xslo:value-of select="."/>
1439           </xslo:if>
1440         </xslo:for-each>
1441       </xslo:variable>
1442       <xslo:value-of select="normalize-space($raw_heading)"/>
1443     </z:index>
1444   </xslo:template>
1445   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='150']">
1446     <z:index name="Match-heading:p Match-heading:s">
1447       <xslo:variable name="raw_heading">
1448         <xslo:for-each select="marc:subfield">
1449           <xslo:if test="contains('abvxyz', @code)" name="Match-heading:p Match-heading:s">
1450             <xslo:if test="position() &gt; 1">
1451               <xslo:choose>
1452                 <xslo:when test="contains('vxyz', @code)">
1453                   <xslo:choose>
1454                     <xslo:when test="@code = $general_subdivision_subfield">
1455                       <xslo:text> generalsubdiv </xslo:text>
1456                     </xslo:when>
1457                     <xslo:when test="@code = $form_subdivision_subfield">
1458                       <xslo:text> formsubdiv </xslo:text>
1459                     </xslo:when>
1460                     <xslo:when test="@code = $chronological_subdivision_subfield">
1461                       <xslo:text> chronologicalsubdiv </xslo:text>
1462                     </xslo:when>
1463                     <xslo:when test="@code = $geographic_subdivision_subfield">
1464                       <xslo:text> geographicsubdiv </xslo:text>
1465                     </xslo:when>
1466                   </xslo:choose>
1467                 </xslo:when>
1468                 <xslo:otherwise>
1469                   <xslo:value-of select="substring(' ', 1, 1)"/>
1470                 </xslo:otherwise>
1471               </xslo:choose>
1472             </xslo:if>
1473             <xslo:value-of select="."/>
1474           </xslo:if>
1475         </xslo:for-each>
1476       </xslo:variable>
1477       <xslo:value-of select="normalize-space($raw_heading)"/>
1478     </z:index>
1479   </xslo:template>
1480   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='450']">
1481     <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
1482       <xslo:variable name="raw_heading">
1483         <xslo:for-each select="marc:subfield">
1484           <xslo:if test="contains('abvxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
1485             <xslo:if test="position() &gt; 1">
1486               <xslo:choose>
1487                 <xslo:when test="contains('vxyz', @code)">
1488                   <xslo:choose>
1489                     <xslo:when test="@code = $general_subdivision_subfield">
1490                       <xslo:text> generalsubdiv </xslo:text>
1491                     </xslo:when>
1492                     <xslo:when test="@code = $form_subdivision_subfield">
1493                       <xslo:text> formsubdiv </xslo:text>
1494                     </xslo:when>
1495                     <xslo:when test="@code = $chronological_subdivision_subfield">
1496                       <xslo:text> chronologicalsubdiv </xslo:text>
1497                     </xslo:when>
1498                     <xslo:when test="@code = $geographic_subdivision_subfield">
1499                       <xslo:text> geographicsubdiv </xslo:text>
1500                     </xslo:when>
1501                   </xslo:choose>
1502                 </xslo:when>
1503                 <xslo:otherwise>
1504                   <xslo:value-of select="substring(' ', 1, 1)"/>
1505                 </xslo:otherwise>
1506               </xslo:choose>
1507             </xslo:if>
1508             <xslo:value-of select="."/>
1509           </xslo:if>
1510         </xslo:for-each>
1511       </xslo:variable>
1512       <xslo:value-of select="normalize-space($raw_heading)"/>
1513     </z:index>
1514   </xslo:template>
1515   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='151']">
1516     <z:index name="Match-heading:p Match-heading:s">
1517       <xslo:variable name="raw_heading">
1518         <xslo:for-each select="marc:subfield">
1519           <xslo:if test="contains('avxyz', @code)" name="Match-heading:p Match-heading:s">
1520             <xslo:if test="position() &gt; 1">
1521               <xslo:choose>
1522                 <xslo:when test="contains('vxyz', @code)">
1523                   <xslo:choose>
1524                     <xslo:when test="@code = $general_subdivision_subfield">
1525                       <xslo:text> generalsubdiv </xslo:text>
1526                     </xslo:when>
1527                     <xslo:when test="@code = $form_subdivision_subfield">
1528                       <xslo:text> formsubdiv </xslo:text>
1529                     </xslo:when>
1530                     <xslo:when test="@code = $chronological_subdivision_subfield">
1531                       <xslo:text> chronologicalsubdiv </xslo:text>
1532                     </xslo:when>
1533                     <xslo:when test="@code = $geographic_subdivision_subfield">
1534                       <xslo:text> geographicsubdiv </xslo:text>
1535                     </xslo:when>
1536                   </xslo:choose>
1537                 </xslo:when>
1538                 <xslo:otherwise>
1539                   <xslo:value-of select="substring(' ', 1, 1)"/>
1540                 </xslo:otherwise>
1541               </xslo:choose>
1542             </xslo:if>
1543             <xslo:value-of select="."/>
1544           </xslo:if>
1545         </xslo:for-each>
1546       </xslo:variable>
1547       <xslo:value-of select="normalize-space($raw_heading)"/>
1548     </z:index>
1549   </xslo:template>
1550   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='451']">
1551     <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
1552       <xslo:variable name="raw_heading">
1553         <xslo:for-each select="marc:subfield">
1554           <xslo:if test="contains('avxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
1555             <xslo:if test="position() &gt; 1">
1556               <xslo:choose>
1557                 <xslo:when test="contains('vxyz', @code)">
1558                   <xslo:choose>
1559                     <xslo:when test="@code = $general_subdivision_subfield">
1560                       <xslo:text> generalsubdiv </xslo:text>
1561                     </xslo:when>
1562                     <xslo:when test="@code = $form_subdivision_subfield">
1563                       <xslo:text> formsubdiv </xslo:text>
1564                     </xslo:when>
1565                     <xslo:when test="@code = $chronological_subdivision_subfield">
1566                       <xslo:text> chronologicalsubdiv </xslo:text>
1567                     </xslo:when>
1568                     <xslo:when test="@code = $geographic_subdivision_subfield">
1569                       <xslo:text> geographicsubdiv </xslo:text>
1570                     </xslo:when>
1571                   </xslo:choose>
1572                 </xslo:when>
1573                 <xslo:otherwise>
1574                   <xslo:value-of select="substring(' ', 1, 1)"/>
1575                 </xslo:otherwise>
1576               </xslo:choose>
1577             </xslo:if>
1578             <xslo:value-of select="."/>
1579           </xslo:if>
1580         </xslo:for-each>
1581       </xslo:variable>
1582       <xslo:value-of select="normalize-space($raw_heading)"/>
1583     </z:index>
1584   </xslo:template>
1585   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='155']">
1586     <z:index name="Match-heading:p Match-heading:s">
1587       <xslo:variable name="raw_heading">
1588         <xslo:for-each select="marc:subfield">
1589           <xslo:if test="contains('avxyz', @code)" name="Match-heading:p Match-heading:s">
1590             <xslo:if test="position() &gt; 1">
1591               <xslo:choose>
1592                 <xslo:when test="contains('vxyz', @code)">
1593                   <xslo:choose>
1594                     <xslo:when test="@code = $general_subdivision_subfield">
1595                       <xslo:text> generalsubdiv </xslo:text>
1596                     </xslo:when>
1597                     <xslo:when test="@code = $form_subdivision_subfield">
1598                       <xslo:text> formsubdiv </xslo:text>
1599                     </xslo:when>
1600                     <xslo:when test="@code = $chronological_subdivision_subfield">
1601                       <xslo:text> chronologicalsubdiv </xslo:text>
1602                     </xslo:when>
1603                     <xslo:when test="@code = $geographic_subdivision_subfield">
1604                       <xslo:text> geographicsubdiv </xslo:text>
1605                     </xslo:when>
1606                   </xslo:choose>
1607                 </xslo:when>
1608                 <xslo:otherwise>
1609                   <xslo:value-of select="substring(' ', 1, 1)"/>
1610                 </xslo:otherwise>
1611               </xslo:choose>
1612             </xslo:if>
1613             <xslo:value-of select="."/>
1614           </xslo:if>
1615         </xslo:for-each>
1616       </xslo:variable>
1617       <xslo:value-of select="normalize-space($raw_heading)"/>
1618     </z:index>
1619   </xslo:template>
1620   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='455']">
1621     <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
1622       <xslo:variable name="raw_heading">
1623         <xslo:for-each select="marc:subfield">
1624           <xslo:if test="contains('avxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
1625             <xslo:if test="position() &gt; 1">
1626               <xslo:choose>
1627                 <xslo:when test="contains('vxyz', @code)">
1628                   <xslo:choose>
1629                     <xslo:when test="@code = $general_subdivision_subfield">
1630                       <xslo:text> generalsubdiv </xslo:text>
1631                     </xslo:when>
1632                     <xslo:when test="@code = $form_subdivision_subfield">
1633                       <xslo:text> formsubdiv </xslo:text>
1634                     </xslo:when>
1635                     <xslo:when test="@code = $chronological_subdivision_subfield">
1636                       <xslo:text> chronologicalsubdiv </xslo:text>
1637                     </xslo:when>
1638                     <xslo:when test="@code = $geographic_subdivision_subfield">
1639                       <xslo:text> geographicsubdiv </xslo:text>
1640                     </xslo:when>
1641                   </xslo:choose>
1642                 </xslo:when>
1643                 <xslo:otherwise>
1644                   <xslo:value-of select="substring(' ', 1, 1)"/>
1645                 </xslo:otherwise>
1646               </xslo:choose>
1647             </xslo:if>
1648             <xslo:value-of select="."/>
1649           </xslo:if>
1650         </xslo:for-each>
1651       </xslo:variable>
1652       <xslo:value-of select="normalize-space($raw_heading)"/>
1653     </z:index>
1654   </xslo:template>
1655   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='180']">
1656     <z:index name="Match-subdivision:p Match-subdivision:s">
1657       <xslo:variable name="raw_heading">
1658         <xslo:for-each select="marc:subfield">
1659           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision:p Match-subdivision:s">
1660             <xslo:if test="position() &gt; 1">
1661               <xslo:choose>
1662                 <xslo:when test="contains('vxyz', @code)">
1663                   <xslo:choose>
1664                     <xslo:when test="@code = $general_subdivision_subfield">
1665                       <xslo:text> generalsubdiv </xslo:text>
1666                     </xslo:when>
1667                     <xslo:when test="@code = $form_subdivision_subfield">
1668                       <xslo:text> formsubdiv </xslo:text>
1669                     </xslo:when>
1670                     <xslo:when test="@code = $chronological_subdivision_subfield">
1671                       <xslo:text> chronologicalsubdiv </xslo:text>
1672                     </xslo:when>
1673                     <xslo:when test="@code = $geographic_subdivision_subfield">
1674                       <xslo:text> geographicsubdiv </xslo:text>
1675                     </xslo:when>
1676                   </xslo:choose>
1677                 </xslo:when>
1678                 <xslo:otherwise>
1679                   <xslo:value-of select="substring(' ', 1, 1)"/>
1680                 </xslo:otherwise>
1681               </xslo:choose>
1682             </xslo:if>
1683             <xslo:value-of select="."/>
1684           </xslo:if>
1685         </xslo:for-each>
1686       </xslo:variable>
1687       <xslo:value-of select="normalize-space($raw_heading)"/>
1688     </z:index>
1689   </xslo:template>
1690   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='480']">
1691     <z:index name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
1692       <xslo:variable name="raw_heading">
1693         <xslo:for-each select="marc:subfield">
1694           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
1695             <xslo:if test="position() &gt; 1">
1696               <xslo:choose>
1697                 <xslo:when test="contains('vxyz', @code)">
1698                   <xslo:choose>
1699                     <xslo:when test="@code = $general_subdivision_subfield">
1700                       <xslo:text> generalsubdiv </xslo:text>
1701                     </xslo:when>
1702                     <xslo:when test="@code = $form_subdivision_subfield">
1703                       <xslo:text> formsubdiv </xslo:text>
1704                     </xslo:when>
1705                     <xslo:when test="@code = $chronological_subdivision_subfield">
1706                       <xslo:text> chronologicalsubdiv </xslo:text>
1707                     </xslo:when>
1708                     <xslo:when test="@code = $geographic_subdivision_subfield">
1709                       <xslo:text> geographicsubdiv </xslo:text>
1710                     </xslo:when>
1711                   </xslo:choose>
1712                 </xslo:when>
1713                 <xslo:otherwise>
1714                   <xslo:value-of select="substring(' ', 1, 1)"/>
1715                 </xslo:otherwise>
1716               </xslo:choose>
1717             </xslo:if>
1718             <xslo:value-of select="."/>
1719           </xslo:if>
1720         </xslo:for-each>
1721       </xslo:variable>
1722       <xslo:value-of select="normalize-space($raw_heading)"/>
1723     </z:index>
1724   </xslo:template>
1725   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='181']">
1726     <z:index name="Match-subdivision:p Match-subdivision:s">
1727       <xslo:variable name="raw_heading">
1728         <xslo:for-each select="marc:subfield">
1729           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision:p Match-subdivision:s">
1730             <xslo:if test="position() &gt; 1">
1731               <xslo:choose>
1732                 <xslo:when test="contains('vxyz', @code)">
1733                   <xslo:choose>
1734                     <xslo:when test="@code = $general_subdivision_subfield">
1735                       <xslo:text> generalsubdiv </xslo:text>
1736                     </xslo:when>
1737                     <xslo:when test="@code = $form_subdivision_subfield">
1738                       <xslo:text> formsubdiv </xslo:text>
1739                     </xslo:when>
1740                     <xslo:when test="@code = $chronological_subdivision_subfield">
1741                       <xslo:text> chronologicalsubdiv </xslo:text>
1742                     </xslo:when>
1743                     <xslo:when test="@code = $geographic_subdivision_subfield">
1744                       <xslo:text> geographicsubdiv </xslo:text>
1745                     </xslo:when>
1746                   </xslo:choose>
1747                 </xslo:when>
1748                 <xslo:otherwise>
1749                   <xslo:value-of select="substring(' ', 1, 1)"/>
1750                 </xslo:otherwise>
1751               </xslo:choose>
1752             </xslo:if>
1753             <xslo:value-of select="."/>
1754           </xslo:if>
1755         </xslo:for-each>
1756       </xslo:variable>
1757       <xslo:value-of select="normalize-space($raw_heading)"/>
1758     </z:index>
1759   </xslo:template>
1760   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='481']">
1761     <z:index name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
1762       <xslo:variable name="raw_heading">
1763         <xslo:for-each select="marc:subfield">
1764           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
1765             <xslo:if test="position() &gt; 1">
1766               <xslo:choose>
1767                 <xslo:when test="contains('vxyz', @code)">
1768                   <xslo:choose>
1769                     <xslo:when test="@code = $general_subdivision_subfield">
1770                       <xslo:text> generalsubdiv </xslo:text>
1771                     </xslo:when>
1772                     <xslo:when test="@code = $form_subdivision_subfield">
1773                       <xslo:text> formsubdiv </xslo:text>
1774                     </xslo:when>
1775                     <xslo:when test="@code = $chronological_subdivision_subfield">
1776                       <xslo:text> chronologicalsubdiv </xslo:text>
1777                     </xslo:when>
1778                     <xslo:when test="@code = $geographic_subdivision_subfield">
1779                       <xslo:text> geographicsubdiv </xslo:text>
1780                     </xslo:when>
1781                   </xslo:choose>
1782                 </xslo:when>
1783                 <xslo:otherwise>
1784                   <xslo:value-of select="substring(' ', 1, 1)"/>
1785                 </xslo:otherwise>
1786               </xslo:choose>
1787             </xslo:if>
1788             <xslo:value-of select="."/>
1789           </xslo:if>
1790         </xslo:for-each>
1791       </xslo:variable>
1792       <xslo:value-of select="normalize-space($raw_heading)"/>
1793     </z:index>
1794   </xslo:template>
1795   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='182']">
1796     <z:index name="Match-subdivision:p Match-subdivision:s">
1797       <xslo:variable name="raw_heading">
1798         <xslo:for-each select="marc:subfield">
1799           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision:p Match-subdivision:s">
1800             <xslo:if test="position() &gt; 1">
1801               <xslo:choose>
1802                 <xslo:when test="contains('vxyz', @code)">
1803                   <xslo:choose>
1804                     <xslo:when test="@code = $general_subdivision_subfield">
1805                       <xslo:text> generalsubdiv </xslo:text>
1806                     </xslo:when>
1807                     <xslo:when test="@code = $form_subdivision_subfield">
1808                       <xslo:text> formsubdiv </xslo:text>
1809                     </xslo:when>
1810                     <xslo:when test="@code = $chronological_subdivision_subfield">
1811                       <xslo:text> chronologicalsubdiv </xslo:text>
1812                     </xslo:when>
1813                     <xslo:when test="@code = $geographic_subdivision_subfield">
1814                       <xslo:text> geographicsubdiv </xslo:text>
1815                     </xslo:when>
1816                   </xslo:choose>
1817                 </xslo:when>
1818                 <xslo:otherwise>
1819                   <xslo:value-of select="substring(' ', 1, 1)"/>
1820                 </xslo:otherwise>
1821               </xslo:choose>
1822             </xslo:if>
1823             <xslo:value-of select="."/>
1824           </xslo:if>
1825         </xslo:for-each>
1826       </xslo:variable>
1827       <xslo:value-of select="normalize-space($raw_heading)"/>
1828     </z:index>
1829   </xslo:template>
1830   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='482']">
1831     <z:index name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
1832       <xslo:variable name="raw_heading">
1833         <xslo:for-each select="marc:subfield">
1834           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
1835             <xslo:if test="position() &gt; 1">
1836               <xslo:choose>
1837                 <xslo:when test="contains('vxyz', @code)">
1838                   <xslo:choose>
1839                     <xslo:when test="@code = $general_subdivision_subfield">
1840                       <xslo:text> generalsubdiv </xslo:text>
1841                     </xslo:when>
1842                     <xslo:when test="@code = $form_subdivision_subfield">
1843                       <xslo:text> formsubdiv </xslo:text>
1844                     </xslo:when>
1845                     <xslo:when test="@code = $chronological_subdivision_subfield">
1846                       <xslo:text> chronologicalsubdiv </xslo:text>
1847                     </xslo:when>
1848                     <xslo:when test="@code = $geographic_subdivision_subfield">
1849                       <xslo:text> geographicsubdiv </xslo:text>
1850                     </xslo:when>
1851                   </xslo:choose>
1852                 </xslo:when>
1853                 <xslo:otherwise>
1854                   <xslo:value-of select="substring(' ', 1, 1)"/>
1855                 </xslo:otherwise>
1856               </xslo:choose>
1857             </xslo:if>
1858             <xslo:value-of select="."/>
1859           </xslo:if>
1860         </xslo:for-each>
1861       </xslo:variable>
1862       <xslo:value-of select="normalize-space($raw_heading)"/>
1863     </z:index>
1864   </xslo:template>
1865   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='485']">
1866     <z:index name="Match-subdivision:p Match-subdivision:s">
1867       <xslo:variable name="raw_heading">
1868         <xslo:for-each select="marc:subfield">
1869           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision:p Match-subdivision:s">
1870             <xslo:if test="position() &gt; 1">
1871               <xslo:choose>
1872                 <xslo:when test="contains('vxyz', @code)">
1873                   <xslo:choose>
1874                     <xslo:when test="@code = $general_subdivision_subfield">
1875                       <xslo:text> generalsubdiv </xslo:text>
1876                     </xslo:when>
1877                     <xslo:when test="@code = $form_subdivision_subfield">
1878                       <xslo:text> formsubdiv </xslo:text>
1879                     </xslo:when>
1880                     <xslo:when test="@code = $chronological_subdivision_subfield">
1881                       <xslo:text> chronologicalsubdiv </xslo:text>
1882                     </xslo:when>
1883                     <xslo:when test="@code = $geographic_subdivision_subfield">
1884                       <xslo:text> geographicsubdiv </xslo:text>
1885                     </xslo:when>
1886                   </xslo:choose>
1887                 </xslo:when>
1888                 <xslo:otherwise>
1889                   <xslo:value-of select="substring(' ', 1, 1)"/>
1890                 </xslo:otherwise>
1891               </xslo:choose>
1892             </xslo:if>
1893             <xslo:value-of select="."/>
1894           </xslo:if>
1895         </xslo:for-each>
1896       </xslo:variable>
1897       <xslo:value-of select="normalize-space($raw_heading)"/>
1898     </z:index>
1899   </xslo:template>
1900   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='185']">
1901     <z:index name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
1902       <xslo:variable name="raw_heading">
1903         <xslo:for-each select="marc:subfield">
1904           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
1905             <xslo:if test="position() &gt; 1">
1906               <xslo:choose>
1907                 <xslo:when test="contains('vxyz', @code)">
1908                   <xslo:choose>
1909                     <xslo:when test="@code = $general_subdivision_subfield">
1910                       <xslo:text> generalsubdiv </xslo:text>
1911                     </xslo:when>
1912                     <xslo:when test="@code = $form_subdivision_subfield">
1913                       <xslo:text> formsubdiv </xslo:text>
1914                     </xslo:when>
1915                     <xslo:when test="@code = $chronological_subdivision_subfield">
1916                       <xslo:text> chronologicalsubdiv </xslo:text>
1917                     </xslo:when>
1918                     <xslo:when test="@code = $geographic_subdivision_subfield">
1919                       <xslo:text> geographicsubdiv </xslo:text>
1920                     </xslo:when>
1921                   </xslo:choose>
1922                 </xslo:when>
1923                 <xslo:otherwise>
1924                   <xslo:value-of select="substring(' ', 1, 1)"/>
1925                 </xslo:otherwise>
1926               </xslo:choose>
1927             </xslo:if>
1928             <xslo:value-of select="."/>
1929           </xslo:if>
1930         </xslo:for-each>
1931       </xslo:variable>
1932       <xslo:value-of select="normalize-space($raw_heading)"/>
1933     </z:index>
1934   </xslo:template>
1935   <xslo:variable name="form_subdivision_subfield">v</xslo:variable>
1936   <xslo:variable name="general_subdivision_subfield">x</xslo:variable>
1937   <xslo:variable name="chronological_subdivision_subfield">y</xslo:variable>
1938   <xslo:variable name="geographic_subdivision_subfield">z</xslo:variable>
1939   <xslo:template mode="index_subject_thesaurus" match="marc:controlfield[@tag='008']">
1940     <xslo:variable name="thesaurus_code1" select="substring(., 12, 1)"/>
1941     <xslo:variable name="full_thesaurus_code">
1942       <xslo:choose>
1943         <xslo:when test="$thesaurus_code1 = 'a'">
1944           <xslo:text>lcsh</xslo:text>
1945         </xslo:when>
1946         <xslo:when test="$thesaurus_code1 = 'b'">
1947           <xslo:text>lcac</xslo:text>
1948         </xslo:when>
1949         <xslo:when test="$thesaurus_code1 = 'c'">
1950           <xslo:text>mesh</xslo:text>
1951         </xslo:when>
1952         <xslo:when test="$thesaurus_code1 = 'd'">
1953           <xslo:text>nal</xslo:text>
1954         </xslo:when>
1955         <xslo:when test="$thesaurus_code1 = 'k'">
1956           <xslo:text>cash</xslo:text>
1957         </xslo:when>
1958         <xslo:when test="$thesaurus_code1 = 'n'">
1959           <xslo:text>notapplicable</xslo:text>
1960         </xslo:when>
1961         <xslo:when test="$thesaurus_code1 = 'r'">
1962           <xslo:text>aat</xslo:text>
1963         </xslo:when>
1964         <xslo:when test="$thesaurus_code1 = 's'">
1965           <xslo:text>sears</xslo:text>
1966         </xslo:when>
1967         <xslo:when test="$thesaurus_code1 = 'v'">
1968           <xslo:text>rvm</xslo:text>
1969         </xslo:when>
1970         <xslo:when test="$thesaurus_code1 = 'z'">
1971           <xslo:choose>
1972             <xslo:when test="//marc:datafield[@tag='040']/marc:subfield[@code='f']">
1973               <xslo:value-of select="//marc:datafield[@tag='040']/marc:subfield[@code='f']"/>
1974             </xslo:when>
1975             <xslo:otherwise>
1976               <xslo:text>notdefined</xslo:text>
1977             </xslo:otherwise>
1978           </xslo:choose>
1979         </xslo:when>
1980         <xslo:otherwise>
1981           <xslo:text>notdefined</xslo:text>
1982         </xslo:otherwise>
1983       </xslo:choose>
1984     </xslo:variable>
1985     <z:index name="Subject-heading-thesaurus:w">
1986       <xslo:value-of select="$full_thesaurus_code"/>
1987     </z:index>
1988   </xslo:template>
1989   <xslo:template match="*">
1990     <z:index name="Any:w Any:p">
1991       <xslo:value-of select="."/>
1992     </z:index>
1993   </xslo:template>
1994 </xslo:stylesheet>