Bug 7818: add warning about not editing record.abs when using DOM filter
[koha.git] / etc / zebradb / marc_defs / marc21 / authorities / authority-zebra-indexdefs.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 This file has been automatically generated from a Koha index definition file
4 with the stylesheet koha-indexdefs-to-zebra.xsl. Do not manually edit this file,
5 as it may be overwritten. To regenerate, edit the appropriate Koha index
6 definition file (probably something like {biblio,authority}-koha-indexdefs.xml) and run:
7 `xsltproc koha-indexdefs-to-zebra.xsl {biblio,authority}-koha-indexdefs.xml >
8 {biblio,authority}-zebra-indexdefs.xsl` (substituting the appropriate file names).
9 -->
10 <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">
11   <xslo:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
12   <xslo:template match="text()"/>
13   <xslo:template match="text()" mode="index_subfields"/>
14   <xslo:template match="text()" mode="index_data_field"/>
15   <xslo:template match="text()" mode="index_heading"/>
16   <xslo:template match="text()" mode="index_match_heading"/>
17   <xslo:template match="text()" mode="index_subject_thesaurus"/>
18   <xslo:template match="/">
19     <xslo:if test="marc:collection">
20       <collection>
21         <xslo:apply-templates select="marc:collection/marc:record"/>
22       </collection>
23     </xslo:if>
24     <xslo:if test="marc:record">
25       <xslo:apply-templates select="marc:record"/>
26     </xslo:if>
27   </xslo:template>
28   <xslo:template match="marc:record">
29     <xslo:variable name="controlField001" select="normalize-space(marc:controlfield[@tag='001'])"/>
30     <z:record type="update">
31       <xslo:attribute name="z:id">
32         <xslo:value-of select="$controlField001"/>
33       </xslo:attribute>
34       <xslo:apply-templates/>
35       <xslo:apply-templates mode="index_subfields"/>
36       <xslo:apply-templates mode="index_data_field"/>
37       <xslo:apply-templates mode="index_heading"/>
38       <xslo:apply-templates mode="index_match_heading"/>
39       <xslo:apply-templates mode="index_subject_thesaurus"/>
40     </z:record>
41   </xslo:template>
42   <xslo:template match="marc:leader">
43     <z:index name="Record-status:w">
44       <xslo:value-of select="substring(., 6, 1)"/>
45     </z:index>
46     <z:index name="Encoding-level:w">
47       <xslo:value-of select="substring(., 18, 1)"/>
48     </z:index>
49   </xslo:template>
50   <xslo:template match="marc:controlfield[@tag='001']">
51     <z:index name="Local-Number:w Local-Number:s">
52       <xslo:value-of select="."/>
53     </z:index>
54   </xslo:template>
55   <xslo:template match="marc:controlfield[@tag='008']">
56     <z:index name="Kind-of-record:w">
57       <xslo:value-of select="substring(., 10, 1)"/>
58     </z:index>
59     <z:index name="Descriptive-cataloging-rules:w">
60       <xslo:value-of select="substring(., 11, 1)"/>
61     </z:index>
62     <z:index name="Heading-use-main-or-added-entry:w">
63       <xslo:value-of select="substring(., 15, 1)"/>
64     </z:index>
65     <z:index name="Heading-use-subject-added-entry:w">
66       <xslo:value-of select="substring(., 16, 1)"/>
67     </z:index>
68     <z:index name="Heading-use-series-added-entry:w">
69       <xslo:value-of select="substring(., 17, 1)"/>
70     </z:index>
71   </xslo:template>
72   <xslo:template mode="index_subfields" match="marc:datafield[@tag='100']">
73     <xslo:for-each select="marc:subfield">
74       <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)">
75         <z:index name="Personal-name:w Personal-name:p Personal-name:s">
76           <xslo:value-of select="."/>
77         </z:index>
78       </xslo:if>
79     </xslo:for-each>
80   </xslo:template>
81   <xslo:template mode="index_subfields" match="marc:datafield[@tag='110']">
82     <xslo:for-each select="marc:subfield">
83       <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)">
84         <z:index name="Corporate-name:w Corporate-name:p">
85           <xslo:value-of select="."/>
86         </z:index>
87       </xslo:if>
88     </xslo:for-each>
89   </xslo:template>
90   <xslo:template mode="index_subfields" match="marc:datafield[@tag='111']">
91     <xslo:for-each select="marc:subfield">
92       <xslo:if test="contains('acdefghjklnpqstvxyz', @code)">
93         <z:index name="Meeting-name:w Meeting-name:p">
94           <xslo:value-of select="."/>
95         </z:index>
96       </xslo:if>
97     </xslo:for-each>
98   </xslo:template>
99   <xslo:template mode="index_subfields" match="marc:datafield[@tag='130']">
100     <xslo:for-each select="marc:subfield">
101       <xslo:if test="contains('adfghklmnoprstvxyz', @code)">
102         <z:index name="Title-uniform:w Title-uniform:p">
103           <xslo:value-of select="."/>
104         </z:index>
105       </xslo:if>
106     </xslo:for-each>
107   </xslo:template>
108   <xslo:template mode="index_subfields" match="marc:datafield[@tag='148']">
109     <xslo:for-each select="marc:subfield">
110       <xslo:if test="contains('avxyz', @code)">
111         <z:index name="Chronological-term:w Chronological-term:p">
112           <xslo:value-of select="."/>
113         </z:index>
114       </xslo:if>
115     </xslo:for-each>
116   </xslo:template>
117   <xslo:template mode="index_subfields" match="marc:datafield[@tag='150']">
118     <xslo:for-each select="marc:subfield">
119       <xslo:if test="contains('abvxyz', @code)">
120         <z:index name="Subject-topical:w Subject-topical:p">
121           <xslo:value-of select="."/>
122         </z:index>
123       </xslo:if>
124     </xslo:for-each>
125   </xslo:template>
126   <xslo:template mode="index_subfields" match="marc:datafield[@tag='151']">
127     <xslo:for-each select="marc:subfield">
128       <xslo:if test="contains('avxyz', @code)">
129         <z:index name="Name-geographic:w Name-geographic:p">
130           <xslo:value-of select="."/>
131         </z:index>
132       </xslo:if>
133     </xslo:for-each>
134   </xslo:template>
135   <xslo:template mode="index_subfields" match="marc:datafield[@tag='155']">
136     <xslo:for-each select="marc:subfield">
137       <xslo:if test="contains('avxyz', @code)">
138         <z:index name="Term-genre-form:w Term-genre-form:p">
139           <xslo:value-of select="."/>
140         </z:index>
141       </xslo:if>
142     </xslo:for-each>
143   </xslo:template>
144   <xslo:template mode="index_subfields" match="marc:datafield[@tag='942']">
145     <xslo:for-each select="marc:subfield">
146       <xslo:if test="contains('a', @code)">
147         <z:index name="authtype:w">
148           <xslo:value-of select="."/>
149         </z:index>
150       </xslo:if>
151     </xslo:for-each>
152   </xslo:template>
153   <xslo:template mode="index_heading" match="marc:datafield[@tag='100']">
154     <z:index name="Personal-name-heading:w Personal-name-heading:p Personal-name-heading:s Heading:w Heading:p Heading:s">
155       <xslo:variable name="raw_heading">
156         <xslo:for-each select="marc:subfield">
157           <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">
158             <xslo:if test="position() &gt; 1">
159               <xslo:choose>
160                 <xslo:when test="contains('vxyz', @code)">
161                   <xslo:text>--</xslo:text>
162                 </xslo:when>
163                 <xslo:otherwise>
164                   <xslo:value-of select="substring(' ', 1, 1)"/>
165                 </xslo:otherwise>
166               </xslo:choose>
167             </xslo:if>
168             <xslo:value-of select="."/>
169           </xslo:if>
170         </xslo:for-each>
171       </xslo:variable>
172       <xslo:value-of select="normalize-space($raw_heading)"/>
173     </z:index>
174     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
175       <xslo:variable name="raw_heading">
176         <xslo:for-each select="marc:subfield">
177           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
178             <xslo:if test="position() &gt; 1">
179               <xslo:choose>
180                 <xslo:when test="contains('', @code)">
181                   <xslo:text>--</xslo:text>
182                 </xslo:when>
183                 <xslo:otherwise>
184                   <xslo:value-of select="substring(' ', 1, 1)"/>
185                 </xslo:otherwise>
186               </xslo:choose>
187             </xslo:if>
188             <xslo:value-of select="."/>
189           </xslo:if>
190         </xslo:for-each>
191       </xslo:variable>
192       <xslo:value-of select="normalize-space($raw_heading)"/>
193     </z:index>
194   </xslo:template>
195   <xslo:template mode="index_heading" match="marc:datafield[@tag='400']">
196     <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">
197       <xslo:variable name="raw_heading">
198         <xslo:for-each select="marc:subfield">
199           <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">
200             <xslo:if test="position() &gt; 1">
201               <xslo:choose>
202                 <xslo:when test="contains('vxyz', @code)">
203                   <xslo:text>--</xslo:text>
204                 </xslo:when>
205                 <xslo:otherwise>
206                   <xslo:value-of select="substring(' ', 1, 1)"/>
207                 </xslo:otherwise>
208               </xslo:choose>
209             </xslo:if>
210             <xslo:value-of select="."/>
211           </xslo:if>
212         </xslo:for-each>
213       </xslo:variable>
214       <xslo:value-of select="normalize-space($raw_heading)"/>
215     </z:index>
216   </xslo:template>
217   <xslo:template mode="index_heading" match="marc:datafield[@tag='500']">
218     <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">
219       <xslo:variable name="raw_heading">
220         <xslo:for-each select="marc:subfield">
221           <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">
222             <xslo:if test="position() &gt; 1">
223               <xslo:choose>
224                 <xslo:when test="contains('vxyz', @code)">
225                   <xslo:text>--</xslo:text>
226                 </xslo:when>
227                 <xslo:otherwise>
228                   <xslo:value-of select="substring(' ', 1, 1)"/>
229                 </xslo:otherwise>
230               </xslo:choose>
231             </xslo:if>
232             <xslo:value-of select="."/>
233           </xslo:if>
234         </xslo:for-each>
235       </xslo:variable>
236       <xslo:value-of select="normalize-space($raw_heading)"/>
237     </z:index>
238   </xslo:template>
239   <xslo:template mode="index_heading" match="marc:datafield[@tag='110']">
240     <z:index name="Corporate-name-heading:w Corporate-name-heading:p Corporate-name-heading:s Heading:w Heading:p Heading:s">
241       <xslo:variable name="raw_heading">
242         <xslo:for-each select="marc:subfield">
243           <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">
244             <xslo:if test="position() &gt; 1">
245               <xslo:choose>
246                 <xslo:when test="contains('vxyz', @code)">
247                   <xslo:text>--</xslo:text>
248                 </xslo:when>
249                 <xslo:otherwise>
250                   <xslo:value-of select="substring(' ', 1, 1)"/>
251                 </xslo:otherwise>
252               </xslo:choose>
253             </xslo:if>
254             <xslo:value-of select="."/>
255           </xslo:if>
256         </xslo:for-each>
257       </xslo:variable>
258       <xslo:value-of select="normalize-space($raw_heading)"/>
259     </z:index>
260     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
261       <xslo:variable name="raw_heading">
262         <xslo:for-each select="marc:subfield">
263           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
264             <xslo:if test="position() &gt; 1">
265               <xslo:choose>
266                 <xslo:when test="contains('', @code)">
267                   <xslo:text>--</xslo:text>
268                 </xslo:when>
269                 <xslo:otherwise>
270                   <xslo:value-of select="substring(' ', 1, 1)"/>
271                 </xslo:otherwise>
272               </xslo:choose>
273             </xslo:if>
274             <xslo:value-of select="."/>
275           </xslo:if>
276         </xslo:for-each>
277       </xslo:variable>
278       <xslo:value-of select="normalize-space($raw_heading)"/>
279     </z:index>
280   </xslo:template>
281   <xslo:template mode="index_heading" match="marc:datafield[@tag='410']">
282     <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">
283       <xslo:variable name="raw_heading">
284         <xslo:for-each select="marc:subfield">
285           <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">
286             <xslo:if test="position() &gt; 1">
287               <xslo:choose>
288                 <xslo:when test="contains('vxyz', @code)">
289                   <xslo:text>--</xslo:text>
290                 </xslo:when>
291                 <xslo:otherwise>
292                   <xslo:value-of select="substring(' ', 1, 1)"/>
293                 </xslo:otherwise>
294               </xslo:choose>
295             </xslo:if>
296             <xslo:value-of select="."/>
297           </xslo:if>
298         </xslo:for-each>
299       </xslo:variable>
300       <xslo:value-of select="normalize-space($raw_heading)"/>
301     </z:index>
302   </xslo:template>
303   <xslo:template mode="index_heading" match="marc:datafield[@tag='510']">
304     <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">
305       <xslo:variable name="raw_heading">
306         <xslo:for-each select="marc:subfield">
307           <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">
308             <xslo:if test="position() &gt; 1">
309               <xslo:choose>
310                 <xslo:when test="contains('vxyz', @code)">
311                   <xslo:text>--</xslo:text>
312                 </xslo:when>
313                 <xslo:otherwise>
314                   <xslo:value-of select="substring(' ', 1, 1)"/>
315                 </xslo:otherwise>
316               </xslo:choose>
317             </xslo:if>
318             <xslo:value-of select="."/>
319           </xslo:if>
320         </xslo:for-each>
321       </xslo:variable>
322       <xslo:value-of select="normalize-space($raw_heading)"/>
323     </z:index>
324   </xslo:template>
325   <xslo:template mode="index_heading" match="marc:datafield[@tag='111']">
326     <z:index name="Meeting-name-heading:w Meeting-name-heading:p Meeting-name-heading:s Heading:w Heading:p Heading:s">
327       <xslo:variable name="raw_heading">
328         <xslo:for-each select="marc:subfield">
329           <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">
330             <xslo:if test="position() &gt; 1">
331               <xslo:choose>
332                 <xslo:when test="contains('vxyz', @code)">
333                   <xslo:text>--</xslo:text>
334                 </xslo:when>
335                 <xslo:otherwise>
336                   <xslo:value-of select="substring(' ', 1, 1)"/>
337                 </xslo:otherwise>
338               </xslo:choose>
339             </xslo:if>
340             <xslo:value-of select="."/>
341           </xslo:if>
342         </xslo:for-each>
343       </xslo:variable>
344       <xslo:value-of select="normalize-space($raw_heading)"/>
345     </z:index>
346     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
347       <xslo:variable name="raw_heading">
348         <xslo:for-each select="marc:subfield">
349           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
350             <xslo:if test="position() &gt; 1">
351               <xslo:choose>
352                 <xslo:when test="contains('', @code)">
353                   <xslo:text>--</xslo:text>
354                 </xslo:when>
355                 <xslo:otherwise>
356                   <xslo:value-of select="substring(' ', 1, 1)"/>
357                 </xslo:otherwise>
358               </xslo:choose>
359             </xslo:if>
360             <xslo:value-of select="."/>
361           </xslo:if>
362         </xslo:for-each>
363       </xslo:variable>
364       <xslo:value-of select="normalize-space($raw_heading)"/>
365     </z:index>
366   </xslo:template>
367   <xslo:template mode="index_heading" match="marc:datafield[@tag='411']">
368     <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">
369       <xslo:variable name="raw_heading">
370         <xslo:for-each select="marc:subfield">
371           <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">
372             <xslo:if test="position() &gt; 1">
373               <xslo:choose>
374                 <xslo:when test="contains('vxyz', @code)">
375                   <xslo:text>--</xslo:text>
376                 </xslo:when>
377                 <xslo:otherwise>
378                   <xslo:value-of select="substring(' ', 1, 1)"/>
379                 </xslo:otherwise>
380               </xslo:choose>
381             </xslo:if>
382             <xslo:value-of select="."/>
383           </xslo:if>
384         </xslo:for-each>
385       </xslo:variable>
386       <xslo:value-of select="normalize-space($raw_heading)"/>
387     </z:index>
388   </xslo:template>
389   <xslo:template mode="index_heading" match="marc:datafield[@tag='511']">
390     <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">
391       <xslo:variable name="raw_heading">
392         <xslo:for-each select="marc:subfield">
393           <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">
394             <xslo:if test="position() &gt; 1">
395               <xslo:choose>
396                 <xslo:when test="contains('vxyz', @code)">
397                   <xslo:text>--</xslo:text>
398                 </xslo:when>
399                 <xslo:otherwise>
400                   <xslo:value-of select="substring(' ', 1, 1)"/>
401                 </xslo:otherwise>
402               </xslo:choose>
403             </xslo:if>
404             <xslo:value-of select="."/>
405           </xslo:if>
406         </xslo:for-each>
407       </xslo:variable>
408       <xslo:value-of select="normalize-space($raw_heading)"/>
409     </z:index>
410   </xslo:template>
411   <xslo:template mode="index_heading" match="marc:datafield[@tag='130']">
412     <z:index name="Title-uniform-heading:w Title-uniform-heading:p Title-uniform-heading:s Heading:w Heading:p Heading:s">
413       <xslo:variable name="raw_heading">
414         <xslo:for-each select="marc:subfield">
415           <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">
416             <xslo:if test="position() &gt; 1">
417               <xslo:choose>
418                 <xslo:when test="contains('vxyz', @code)">
419                   <xslo:text>--</xslo:text>
420                 </xslo:when>
421                 <xslo:otherwise>
422                   <xslo:value-of select="substring(' ', 1, 1)"/>
423                 </xslo:otherwise>
424               </xslo:choose>
425             </xslo:if>
426             <xslo:value-of select="."/>
427           </xslo:if>
428         </xslo:for-each>
429       </xslo:variable>
430       <xslo:value-of select="normalize-space($raw_heading)"/>
431     </z:index>
432     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
433       <xslo:variable name="raw_heading">
434         <xslo:for-each select="marc:subfield">
435           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
436             <xslo:if test="position() &gt; 1">
437               <xslo:choose>
438                 <xslo:when test="contains('', @code)">
439                   <xslo:text>--</xslo:text>
440                 </xslo:when>
441                 <xslo:otherwise>
442                   <xslo:value-of select="substring(' ', 1, 1)"/>
443                 </xslo:otherwise>
444               </xslo:choose>
445             </xslo:if>
446             <xslo:value-of select="."/>
447           </xslo:if>
448         </xslo:for-each>
449       </xslo:variable>
450       <xslo:value-of select="normalize-space($raw_heading)"/>
451     </z:index>
452   </xslo:template>
453   <xslo:template mode="index_heading" match="marc:datafield[@tag='430']">
454     <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">
455       <xslo:variable name="raw_heading">
456         <xslo:for-each select="marc:subfield">
457           <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">
458             <xslo:if test="position() &gt; 1">
459               <xslo:choose>
460                 <xslo:when test="contains('vxyz', @code)">
461                   <xslo:text>--</xslo:text>
462                 </xslo:when>
463                 <xslo:otherwise>
464                   <xslo:value-of select="substring(' ', 1, 1)"/>
465                 </xslo:otherwise>
466               </xslo:choose>
467             </xslo:if>
468             <xslo:value-of select="."/>
469           </xslo:if>
470         </xslo:for-each>
471       </xslo:variable>
472       <xslo:value-of select="normalize-space($raw_heading)"/>
473     </z:index>
474   </xslo:template>
475   <xslo:template mode="index_heading" match="marc:datafield[@tag='530']">
476     <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">
477       <xslo:variable name="raw_heading">
478         <xslo:for-each select="marc:subfield">
479           <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">
480             <xslo:if test="position() &gt; 1">
481               <xslo:choose>
482                 <xslo:when test="contains('vxyz', @code)">
483                   <xslo:text>--</xslo:text>
484                 </xslo:when>
485                 <xslo:otherwise>
486                   <xslo:value-of select="substring(' ', 1, 1)"/>
487                 </xslo:otherwise>
488               </xslo:choose>
489             </xslo:if>
490             <xslo:value-of select="."/>
491           </xslo:if>
492         </xslo:for-each>
493       </xslo:variable>
494       <xslo:value-of select="normalize-space($raw_heading)"/>
495     </z:index>
496   </xslo:template>
497   <xslo:template mode="index_heading" match="marc:datafield[@tag='148']">
498     <z:index name="Chronological-term-heading:w Chronological-term-heading:p Chronological-term-heading:s Heading:w Heading:p Heading:s">
499       <xslo:variable name="raw_heading">
500         <xslo:for-each select="marc:subfield">
501           <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">
502             <xslo:if test="position() &gt; 1">
503               <xslo:choose>
504                 <xslo:when test="contains('vxyz', @code)">
505                   <xslo:text>--</xslo:text>
506                 </xslo:when>
507                 <xslo:otherwise>
508                   <xslo:value-of select="substring(' ', 1, 1)"/>
509                 </xslo:otherwise>
510               </xslo:choose>
511             </xslo:if>
512             <xslo:value-of select="."/>
513           </xslo:if>
514         </xslo:for-each>
515       </xslo:variable>
516       <xslo:value-of select="normalize-space($raw_heading)"/>
517     </z:index>
518     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
519       <xslo:variable name="raw_heading">
520         <xslo:for-each select="marc:subfield">
521           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
522             <xslo:if test="position() &gt; 1">
523               <xslo:choose>
524                 <xslo:when test="contains('', @code)">
525                   <xslo:text>--</xslo:text>
526                 </xslo:when>
527                 <xslo:otherwise>
528                   <xslo:value-of select="substring(' ', 1, 1)"/>
529                 </xslo:otherwise>
530               </xslo:choose>
531             </xslo:if>
532             <xslo:value-of select="."/>
533           </xslo:if>
534         </xslo:for-each>
535       </xslo:variable>
536       <xslo:value-of select="normalize-space($raw_heading)"/>
537     </z:index>
538   </xslo:template>
539   <xslo:template mode="index_heading" match="marc:datafield[@tag='448']">
540     <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">
541       <xslo:variable name="raw_heading">
542         <xslo:for-each select="marc:subfield">
543           <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">
544             <xslo:if test="position() &gt; 1">
545               <xslo:choose>
546                 <xslo:when test="contains('vxyz', @code)">
547                   <xslo:text>--</xslo:text>
548                 </xslo:when>
549                 <xslo:otherwise>
550                   <xslo:value-of select="substring(' ', 1, 1)"/>
551                 </xslo:otherwise>
552               </xslo:choose>
553             </xslo:if>
554             <xslo:value-of select="."/>
555           </xslo:if>
556         </xslo:for-each>
557       </xslo:variable>
558       <xslo:value-of select="normalize-space($raw_heading)"/>
559     </z:index>
560   </xslo:template>
561   <xslo:template mode="index_heading" match="marc:datafield[@tag='548']">
562     <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">
563       <xslo:variable name="raw_heading">
564         <xslo:for-each select="marc:subfield">
565           <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">
566             <xslo:if test="position() &gt; 1">
567               <xslo:choose>
568                 <xslo:when test="contains('vxyz', @code)">
569                   <xslo:text>--</xslo:text>
570                 </xslo:when>
571                 <xslo:otherwise>
572                   <xslo:value-of select="substring(' ', 1, 1)"/>
573                 </xslo:otherwise>
574               </xslo:choose>
575             </xslo:if>
576             <xslo:value-of select="."/>
577           </xslo:if>
578         </xslo:for-each>
579       </xslo:variable>
580       <xslo:value-of select="normalize-space($raw_heading)"/>
581     </z:index>
582   </xslo:template>
583   <xslo:template mode="index_heading" match="marc:datafield[@tag='150']">
584     <z:index name="Subject-topical-heading:w Subject-topical-heading:p Subject-topical-heading:s Heading:w Heading:p Heading:s">
585       <xslo:variable name="raw_heading">
586         <xslo:for-each select="marc:subfield">
587           <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">
588             <xslo:if test="position() &gt; 1">
589               <xslo:choose>
590                 <xslo:when test="contains('vxyz', @code)">
591                   <xslo:text>--</xslo:text>
592                 </xslo:when>
593                 <xslo:otherwise>
594                   <xslo:value-of select="substring(' ', 1, 1)"/>
595                 </xslo:otherwise>
596               </xslo:choose>
597             </xslo:if>
598             <xslo:value-of select="."/>
599           </xslo:if>
600         </xslo:for-each>
601       </xslo:variable>
602       <xslo:value-of select="normalize-space($raw_heading)"/>
603     </z:index>
604     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
605       <xslo:variable name="raw_heading">
606         <xslo:for-each select="marc:subfield">
607           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
608             <xslo:if test="position() &gt; 1">
609               <xslo:choose>
610                 <xslo:when test="contains('', @code)">
611                   <xslo:text>--</xslo:text>
612                 </xslo:when>
613                 <xslo:otherwise>
614                   <xslo:value-of select="substring(' ', 1, 1)"/>
615                 </xslo:otherwise>
616               </xslo:choose>
617             </xslo:if>
618             <xslo:value-of select="."/>
619           </xslo:if>
620         </xslo:for-each>
621       </xslo:variable>
622       <xslo:value-of select="normalize-space($raw_heading)"/>
623     </z:index>
624   </xslo:template>
625   <xslo:template mode="index_heading" match="marc:datafield[@tag='450']">
626     <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">
627       <xslo:variable name="raw_heading">
628         <xslo:for-each select="marc:subfield">
629           <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">
630             <xslo:if test="position() &gt; 1">
631               <xslo:choose>
632                 <xslo:when test="contains('vxyz', @code)">
633                   <xslo:text>--</xslo:text>
634                 </xslo:when>
635                 <xslo:otherwise>
636                   <xslo:value-of select="substring(' ', 1, 1)"/>
637                 </xslo:otherwise>
638               </xslo:choose>
639             </xslo:if>
640             <xslo:value-of select="."/>
641           </xslo:if>
642         </xslo:for-each>
643       </xslo:variable>
644       <xslo:value-of select="normalize-space($raw_heading)"/>
645     </z:index>
646   </xslo:template>
647   <xslo:template mode="index_heading" match="marc:datafield[@tag='550']">
648     <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">
649       <xslo:variable name="raw_heading">
650         <xslo:for-each select="marc:subfield">
651           <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">
652             <xslo:if test="position() &gt; 1">
653               <xslo:choose>
654                 <xslo:when test="contains('vxyz', @code)">
655                   <xslo:text>--</xslo:text>
656                 </xslo:when>
657                 <xslo:otherwise>
658                   <xslo:value-of select="substring(' ', 1, 1)"/>
659                 </xslo:otherwise>
660               </xslo:choose>
661             </xslo:if>
662             <xslo:value-of select="."/>
663           </xslo:if>
664         </xslo:for-each>
665       </xslo:variable>
666       <xslo:value-of select="normalize-space($raw_heading)"/>
667     </z:index>
668   </xslo:template>
669   <xslo:template mode="index_heading" match="marc:datafield[@tag='151']">
670     <z:index name="Name-geographic-heading:w Name-geographic-heading:p Name-geographic-heading:s Heading:w Heading:p Heading:s">
671       <xslo:variable name="raw_heading">
672         <xslo:for-each select="marc:subfield">
673           <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">
674             <xslo:if test="position() &gt; 1">
675               <xslo:choose>
676                 <xslo:when test="contains('vxyz', @code)">
677                   <xslo:text>--</xslo:text>
678                 </xslo:when>
679                 <xslo:otherwise>
680                   <xslo:value-of select="substring(' ', 1, 1)"/>
681                 </xslo:otherwise>
682               </xslo:choose>
683             </xslo:if>
684             <xslo:value-of select="."/>
685           </xslo:if>
686         </xslo:for-each>
687       </xslo:variable>
688       <xslo:value-of select="normalize-space($raw_heading)"/>
689     </z:index>
690     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
691       <xslo:variable name="raw_heading">
692         <xslo:for-each select="marc:subfield">
693           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
694             <xslo:if test="position() &gt; 1">
695               <xslo:choose>
696                 <xslo:when test="contains('', @code)">
697                   <xslo:text>--</xslo:text>
698                 </xslo:when>
699                 <xslo:otherwise>
700                   <xslo:value-of select="substring(' ', 1, 1)"/>
701                 </xslo:otherwise>
702               </xslo:choose>
703             </xslo:if>
704             <xslo:value-of select="."/>
705           </xslo:if>
706         </xslo:for-each>
707       </xslo:variable>
708       <xslo:value-of select="normalize-space($raw_heading)"/>
709     </z:index>
710   </xslo:template>
711   <xslo:template mode="index_heading" match="marc:datafield[@tag='451']">
712     <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">
713       <xslo:variable name="raw_heading">
714         <xslo:for-each select="marc:subfield">
715           <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">
716             <xslo:if test="position() &gt; 1">
717               <xslo:choose>
718                 <xslo:when test="contains('vxyz', @code)">
719                   <xslo:text>--</xslo:text>
720                 </xslo:when>
721                 <xslo:otherwise>
722                   <xslo:value-of select="substring(' ', 1, 1)"/>
723                 </xslo:otherwise>
724               </xslo:choose>
725             </xslo:if>
726             <xslo:value-of select="."/>
727           </xslo:if>
728         </xslo:for-each>
729       </xslo:variable>
730       <xslo:value-of select="normalize-space($raw_heading)"/>
731     </z:index>
732   </xslo:template>
733   <xslo:template mode="index_heading" match="marc:datafield[@tag='551']">
734     <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">
735       <xslo:variable name="raw_heading">
736         <xslo:for-each select="marc:subfield">
737           <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">
738             <xslo:if test="position() &gt; 1">
739               <xslo:choose>
740                 <xslo:when test="contains('vxyz', @code)">
741                   <xslo:text>--</xslo:text>
742                 </xslo:when>
743                 <xslo:otherwise>
744                   <xslo:value-of select="substring(' ', 1, 1)"/>
745                 </xslo:otherwise>
746               </xslo:choose>
747             </xslo:if>
748             <xslo:value-of select="."/>
749           </xslo:if>
750         </xslo:for-each>
751       </xslo:variable>
752       <xslo:value-of select="normalize-space($raw_heading)"/>
753     </z:index>
754   </xslo:template>
755   <xslo:template mode="index_heading" match="marc:datafield[@tag='155']">
756     <z:index name="Term-genre-form-heading:w Term-genre-form-heading:p Term-genre-form-heading:s Heading:w Heading:p Heading:s">
757       <xslo:variable name="raw_heading">
758         <xslo:for-each select="marc:subfield">
759           <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">
760             <xslo:if test="position() &gt; 1">
761               <xslo:choose>
762                 <xslo:when test="contains('vxyz', @code)">
763                   <xslo:text>--</xslo:text>
764                 </xslo:when>
765                 <xslo:otherwise>
766                   <xslo:value-of select="substring(' ', 1, 1)"/>
767                 </xslo:otherwise>
768               </xslo:choose>
769             </xslo:if>
770             <xslo:value-of select="."/>
771           </xslo:if>
772         </xslo:for-each>
773       </xslo:variable>
774       <xslo:value-of select="normalize-space($raw_heading)"/>
775     </z:index>
776     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
777       <xslo:variable name="raw_heading">
778         <xslo:for-each select="marc:subfield">
779           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
780             <xslo:if test="position() &gt; 1">
781               <xslo:choose>
782                 <xslo:when test="contains('', @code)">
783                   <xslo:text>--</xslo:text>
784                 </xslo:when>
785                 <xslo:otherwise>
786                   <xslo:value-of select="substring(' ', 1, 1)"/>
787                 </xslo:otherwise>
788               </xslo:choose>
789             </xslo:if>
790             <xslo:value-of select="."/>
791           </xslo:if>
792         </xslo:for-each>
793       </xslo:variable>
794       <xslo:value-of select="normalize-space($raw_heading)"/>
795     </z:index>
796   </xslo:template>
797   <xslo:template mode="index_heading" match="marc:datafield[@tag='455']">
798     <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">
799       <xslo:variable name="raw_heading">
800         <xslo:for-each select="marc:subfield">
801           <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">
802             <xslo:if test="position() &gt; 1">
803               <xslo:choose>
804                 <xslo:when test="contains('vxyz', @code)">
805                   <xslo:text>--</xslo:text>
806                 </xslo:when>
807                 <xslo:otherwise>
808                   <xslo:value-of select="substring(' ', 1, 1)"/>
809                 </xslo:otherwise>
810               </xslo:choose>
811             </xslo:if>
812             <xslo:value-of select="."/>
813           </xslo:if>
814         </xslo:for-each>
815       </xslo:variable>
816       <xslo:value-of select="normalize-space($raw_heading)"/>
817     </z:index>
818   </xslo:template>
819   <xslo:template mode="index_heading" match="marc:datafield[@tag='555']">
820     <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">
821       <xslo:variable name="raw_heading">
822         <xslo:for-each select="marc:subfield">
823           <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">
824             <xslo:if test="position() &gt; 1">
825               <xslo:choose>
826                 <xslo:when test="contains('vxyz', @code)">
827                   <xslo:text>--</xslo:text>
828                 </xslo:when>
829                 <xslo:otherwise>
830                   <xslo:value-of select="substring(' ', 1, 1)"/>
831                 </xslo:otherwise>
832               </xslo:choose>
833             </xslo:if>
834             <xslo:value-of select="."/>
835           </xslo:if>
836         </xslo:for-each>
837       </xslo:variable>
838       <xslo:value-of select="normalize-space($raw_heading)"/>
839     </z:index>
840   </xslo:template>
841   <xslo:template mode="index_heading" match="marc:datafield[@tag='180']">
842     <z:index name="General-subdivision:w General-subdivision:p General-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
843       <xslo:variable name="raw_heading">
844         <xslo:for-each select="marc:subfield">
845           <xslo:if test="contains('vxyz', @code)" name="General-subdivision:w General-subdivision:p General-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
846             <xslo:if test="position() &gt; 1">
847               <xslo:choose>
848                 <xslo:when test="contains('vxyz', @code)">
849                   <xslo:text>--</xslo:text>
850                 </xslo:when>
851                 <xslo:otherwise>
852                   <xslo:value-of select="substring(' ', 1, 1)"/>
853                 </xslo:otherwise>
854               </xslo:choose>
855             </xslo:if>
856             <xslo:value-of select="."/>
857           </xslo:if>
858         </xslo:for-each>
859       </xslo:variable>
860       <xslo:value-of select="normalize-space($raw_heading)"/>
861     </z:index>
862   </xslo:template>
863   <xslo:template mode="index_heading" match="marc:datafield[@tag='480']">
864     <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">
865       <xslo:variable name="raw_heading">
866         <xslo:for-each select="marc:subfield">
867           <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">
868             <xslo:if test="position() &gt; 1">
869               <xslo:choose>
870                 <xslo:when test="contains('vxyz', @code)">
871                   <xslo:text>--</xslo:text>
872                 </xslo:when>
873                 <xslo:otherwise>
874                   <xslo:value-of select="substring(' ', 1, 1)"/>
875                 </xslo:otherwise>
876               </xslo:choose>
877             </xslo:if>
878             <xslo:value-of select="."/>
879           </xslo:if>
880         </xslo:for-each>
881       </xslo:variable>
882       <xslo:value-of select="normalize-space($raw_heading)"/>
883     </z:index>
884   </xslo:template>
885   <xslo:template mode="index_heading" match="marc:datafield[@tag='580']">
886     <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">
887       <xslo:variable name="raw_heading">
888         <xslo:for-each select="marc:subfield">
889           <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">
890             <xslo:if test="position() &gt; 1">
891               <xslo:choose>
892                 <xslo:when test="contains('vxyz', @code)">
893                   <xslo:text>--</xslo:text>
894                 </xslo:when>
895                 <xslo:otherwise>
896                   <xslo:value-of select="substring(' ', 1, 1)"/>
897                 </xslo:otherwise>
898               </xslo:choose>
899             </xslo:if>
900             <xslo:value-of select="."/>
901           </xslo:if>
902         </xslo:for-each>
903       </xslo:variable>
904       <xslo:value-of select="normalize-space($raw_heading)"/>
905     </z:index>
906   </xslo:template>
907   <xslo:template mode="index_heading" match="marc:datafield[@tag='181']">
908     <z:index name="Geographic-subdivision:w Geographic-subdivision:p Geographic-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
909       <xslo:variable name="raw_heading">
910         <xslo:for-each select="marc:subfield">
911           <xslo:if test="contains('vxyz', @code)" name="Geographic-subdivision:w Geographic-subdivision:p Geographic-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
912             <xslo:if test="position() &gt; 1">
913               <xslo:choose>
914                 <xslo:when test="contains('vxyz', @code)">
915                   <xslo:text>--</xslo:text>
916                 </xslo:when>
917                 <xslo:otherwise>
918                   <xslo:value-of select="substring(' ', 1, 1)"/>
919                 </xslo:otherwise>
920               </xslo:choose>
921             </xslo:if>
922             <xslo:value-of select="."/>
923           </xslo:if>
924         </xslo:for-each>
925       </xslo:variable>
926       <xslo:value-of select="normalize-space($raw_heading)"/>
927     </z:index>
928   </xslo:template>
929   <xslo:template mode="index_heading" match="marc:datafield[@tag='481']">
930     <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">
931       <xslo:variable name="raw_heading">
932         <xslo:for-each select="marc:subfield">
933           <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">
934             <xslo:if test="position() &gt; 1">
935               <xslo:choose>
936                 <xslo:when test="contains('vxyz', @code)">
937                   <xslo:text>--</xslo:text>
938                 </xslo:when>
939                 <xslo:otherwise>
940                   <xslo:value-of select="substring(' ', 1, 1)"/>
941                 </xslo:otherwise>
942               </xslo:choose>
943             </xslo:if>
944             <xslo:value-of select="."/>
945           </xslo:if>
946         </xslo:for-each>
947       </xslo:variable>
948       <xslo:value-of select="normalize-space($raw_heading)"/>
949     </z:index>
950   </xslo:template>
951   <xslo:template mode="index_heading" match="marc:datafield[@tag='581']">
952     <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">
953       <xslo:variable name="raw_heading">
954         <xslo:for-each select="marc:subfield">
955           <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">
956             <xslo:if test="position() &gt; 1">
957               <xslo:choose>
958                 <xslo:when test="contains('vxyz', @code)">
959                   <xslo:text>--</xslo:text>
960                 </xslo:when>
961                 <xslo:otherwise>
962                   <xslo:value-of select="substring(' ', 1, 1)"/>
963                 </xslo:otherwise>
964               </xslo:choose>
965             </xslo:if>
966             <xslo:value-of select="."/>
967           </xslo:if>
968         </xslo:for-each>
969       </xslo:variable>
970       <xslo:value-of select="normalize-space($raw_heading)"/>
971     </z:index>
972   </xslo:template>
973   <xslo:template mode="index_heading" match="marc:datafield[@tag='182']">
974     <z:index name="Chronological-subdivision:w Chronological-subdivision:p Chronological-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
975       <xslo:variable name="raw_heading">
976         <xslo:for-each select="marc:subfield">
977           <xslo:if test="contains('vxyz', @code)" name="Chronological-subdivision:w Chronological-subdivision:p Chronological-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
978             <xslo:if test="position() &gt; 1">
979               <xslo:choose>
980                 <xslo:when test="contains('vxyz', @code)">
981                   <xslo:text>--</xslo:text>
982                 </xslo:when>
983                 <xslo:otherwise>
984                   <xslo:value-of select="substring(' ', 1, 1)"/>
985                 </xslo:otherwise>
986               </xslo:choose>
987             </xslo:if>
988             <xslo:value-of select="."/>
989           </xslo:if>
990         </xslo:for-each>
991       </xslo:variable>
992       <xslo:value-of select="normalize-space($raw_heading)"/>
993     </z:index>
994   </xslo:template>
995   <xslo:template mode="index_heading" match="marc:datafield[@tag='482']">
996     <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">
997       <xslo:variable name="raw_heading">
998         <xslo:for-each select="marc:subfield">
999           <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">
1000             <xslo:if test="position() &gt; 1">
1001               <xslo:choose>
1002                 <xslo:when test="contains('vxyz', @code)">
1003                   <xslo:text>--</xslo:text>
1004                 </xslo:when>
1005                 <xslo:otherwise>
1006                   <xslo:value-of select="substring(' ', 1, 1)"/>
1007                 </xslo:otherwise>
1008               </xslo:choose>
1009             </xslo:if>
1010             <xslo:value-of select="."/>
1011           </xslo:if>
1012         </xslo:for-each>
1013       </xslo:variable>
1014       <xslo:value-of select="normalize-space($raw_heading)"/>
1015     </z:index>
1016   </xslo:template>
1017   <xslo:template mode="index_heading" match="marc:datafield[@tag='582']">
1018     <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">
1019       <xslo:variable name="raw_heading">
1020         <xslo:for-each select="marc:subfield">
1021           <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">
1022             <xslo:if test="position() &gt; 1">
1023               <xslo:choose>
1024                 <xslo:when test="contains('vxyz', @code)">
1025                   <xslo:text>--</xslo:text>
1026                 </xslo:when>
1027                 <xslo:otherwise>
1028                   <xslo:value-of select="substring(' ', 1, 1)"/>
1029                 </xslo:otherwise>
1030               </xslo:choose>
1031             </xslo:if>
1032             <xslo:value-of select="."/>
1033           </xslo:if>
1034         </xslo:for-each>
1035       </xslo:variable>
1036       <xslo:value-of select="normalize-space($raw_heading)"/>
1037     </z:index>
1038   </xslo:template>
1039   <xslo:template mode="index_heading" match="marc:datafield[@tag='185']">
1040     <z:index name="Form-subdivision:w Form-subdivision:p Form-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
1041       <xslo:variable name="raw_heading">
1042         <xslo:for-each select="marc:subfield">
1043           <xslo:if test="contains('vxyz', @code)" name="Form-subdivision:w Form-subdivision:p Form-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
1044             <xslo:if test="position() &gt; 1">
1045               <xslo:choose>
1046                 <xslo:when test="contains('vxyz', @code)">
1047                   <xslo:text>--</xslo:text>
1048                 </xslo:when>
1049                 <xslo:otherwise>
1050                   <xslo:value-of select="substring(' ', 1, 1)"/>
1051                 </xslo:otherwise>
1052               </xslo:choose>
1053             </xslo:if>
1054             <xslo:value-of select="."/>
1055           </xslo:if>
1056         </xslo:for-each>
1057       </xslo:variable>
1058       <xslo:value-of select="normalize-space($raw_heading)"/>
1059     </z:index>
1060   </xslo:template>
1061   <xslo:template mode="index_heading" match="marc:datafield[@tag='485']">
1062     <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">
1063       <xslo:variable name="raw_heading">
1064         <xslo:for-each select="marc:subfield">
1065           <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">
1066             <xslo:if test="position() &gt; 1">
1067               <xslo:choose>
1068                 <xslo:when test="contains('vxyz', @code)">
1069                   <xslo:text>--</xslo:text>
1070                 </xslo:when>
1071                 <xslo:otherwise>
1072                   <xslo:value-of select="substring(' ', 1, 1)"/>
1073                 </xslo:otherwise>
1074               </xslo:choose>
1075             </xslo:if>
1076             <xslo:value-of select="."/>
1077           </xslo:if>
1078         </xslo:for-each>
1079       </xslo:variable>
1080       <xslo:value-of select="normalize-space($raw_heading)"/>
1081     </z:index>
1082   </xslo:template>
1083   <xslo:template mode="index_heading" match="marc:datafield[@tag='585']">
1084     <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">
1085       <xslo:variable name="raw_heading">
1086         <xslo:for-each select="marc:subfield">
1087           <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">
1088             <xslo:if test="position() &gt; 1">
1089               <xslo:choose>
1090                 <xslo:when test="contains('vxyz', @code)">
1091                   <xslo:text>--</xslo:text>
1092                 </xslo:when>
1093                 <xslo:otherwise>
1094                   <xslo:value-of select="substring(' ', 1, 1)"/>
1095                 </xslo:otherwise>
1096               </xslo:choose>
1097             </xslo:if>
1098             <xslo:value-of select="."/>
1099           </xslo:if>
1100         </xslo:for-each>
1101       </xslo:variable>
1102       <xslo:value-of select="normalize-space($raw_heading)"/>
1103     </z:index>
1104   </xslo:template>
1105   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='100']">
1106     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1107       <xslo:variable name="raw_heading">
1108         <xslo:for-each select="marc:subfield">
1109           <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1110             <xslo:if test="position() &gt; 1">
1111               <xslo:choose>
1112                 <xslo:when test="contains('vxyz', @code)">
1113                   <xslo:choose>
1114                     <xslo:when test="@code = $general_subdivision_subfield">
1115                       <xslo:text> generalsubdiv </xslo:text>
1116                     </xslo:when>
1117                     <xslo:when test="@code = $form_subdivision_subfield">
1118                       <xslo:text> formsubdiv </xslo:text>
1119                     </xslo:when>
1120                     <xslo:when test="@code = $chronological_subdivision_subfield">
1121                       <xslo:text> chronologicalsubdiv </xslo:text>
1122                     </xslo:when>
1123                     <xslo:when test="@code = $geographic_subdivision_subfield">
1124                       <xslo:text> geographicsubdiv </xslo:text>
1125                     </xslo:when>
1126                   </xslo:choose>
1127                 </xslo:when>
1128                 <xslo:otherwise>
1129                   <xslo:value-of select="substring(' ', 1, 1)"/>
1130                 </xslo:otherwise>
1131               </xslo:choose>
1132             </xslo:if>
1133             <xslo:call-template name="chopPunctuation">
1134               <xslo:with-param name="chopString">
1135                 <xslo:value-of select="."/>
1136               </xslo:with-param>
1137             </xslo:call-template>
1138           </xslo:if>
1139         </xslo:for-each>
1140       </xslo:variable>
1141       <xslo:value-of select="normalize-space($raw_heading)"/>
1142     </z:index>
1143   </xslo:template>
1144   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='400']">
1145     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1146       <xslo:variable name="raw_heading">
1147         <xslo:for-each select="marc:subfield">
1148           <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1149             <xslo:if test="position() &gt; 1">
1150               <xslo:choose>
1151                 <xslo:when test="contains('vxyz', @code)">
1152                   <xslo:choose>
1153                     <xslo:when test="@code = $general_subdivision_subfield">
1154                       <xslo:text> generalsubdiv </xslo:text>
1155                     </xslo:when>
1156                     <xslo:when test="@code = $form_subdivision_subfield">
1157                       <xslo:text> formsubdiv </xslo:text>
1158                     </xslo:when>
1159                     <xslo:when test="@code = $chronological_subdivision_subfield">
1160                       <xslo:text> chronologicalsubdiv </xslo:text>
1161                     </xslo:when>
1162                     <xslo:when test="@code = $geographic_subdivision_subfield">
1163                       <xslo:text> geographicsubdiv </xslo:text>
1164                     </xslo:when>
1165                   </xslo:choose>
1166                 </xslo:when>
1167                 <xslo:otherwise>
1168                   <xslo:value-of select="substring(' ', 1, 1)"/>
1169                 </xslo:otherwise>
1170               </xslo:choose>
1171             </xslo:if>
1172             <xslo:call-template name="chopPunctuation">
1173               <xslo:with-param name="chopString">
1174                 <xslo:value-of select="."/>
1175               </xslo:with-param>
1176             </xslo:call-template>
1177           </xslo:if>
1178         </xslo:for-each>
1179       </xslo:variable>
1180       <xslo:value-of select="normalize-space($raw_heading)"/>
1181     </z:index>
1182   </xslo:template>
1183   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='500']">
1184     <z:index name="Match:w Match:p">
1185       <xslo:variable name="raw_heading">
1186         <xslo:for-each select="marc:subfield">
1187           <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Match:w Match:p">
1188             <xslo:if test="position() &gt; 1">
1189               <xslo:choose>
1190                 <xslo:when test="contains('vxyz', @code)">
1191                   <xslo:choose>
1192                     <xslo:when test="@code = $general_subdivision_subfield">
1193                       <xslo:text> generalsubdiv </xslo:text>
1194                     </xslo:when>
1195                     <xslo:when test="@code = $form_subdivision_subfield">
1196                       <xslo:text> formsubdiv </xslo:text>
1197                     </xslo:when>
1198                     <xslo:when test="@code = $chronological_subdivision_subfield">
1199                       <xslo:text> chronologicalsubdiv </xslo:text>
1200                     </xslo:when>
1201                     <xslo:when test="@code = $geographic_subdivision_subfield">
1202                       <xslo:text> geographicsubdiv </xslo:text>
1203                     </xslo:when>
1204                   </xslo:choose>
1205                 </xslo:when>
1206                 <xslo:otherwise>
1207                   <xslo:value-of select="substring(' ', 1, 1)"/>
1208                 </xslo:otherwise>
1209               </xslo:choose>
1210             </xslo:if>
1211             <xslo:call-template name="chopPunctuation">
1212               <xslo:with-param name="chopString">
1213                 <xslo:value-of select="."/>
1214               </xslo:with-param>
1215             </xslo:call-template>
1216           </xslo:if>
1217         </xslo:for-each>
1218       </xslo:variable>
1219       <xslo:value-of select="normalize-space($raw_heading)"/>
1220     </z:index>
1221   </xslo:template>
1222   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='110']">
1223     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1224       <xslo:variable name="raw_heading">
1225         <xslo:for-each select="marc:subfield">
1226           <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1227             <xslo:if test="position() &gt; 1">
1228               <xslo:choose>
1229                 <xslo:when test="contains('vxyz', @code)">
1230                   <xslo:choose>
1231                     <xslo:when test="@code = $general_subdivision_subfield">
1232                       <xslo:text> generalsubdiv </xslo:text>
1233                     </xslo:when>
1234                     <xslo:when test="@code = $form_subdivision_subfield">
1235                       <xslo:text> formsubdiv </xslo:text>
1236                     </xslo:when>
1237                     <xslo:when test="@code = $chronological_subdivision_subfield">
1238                       <xslo:text> chronologicalsubdiv </xslo:text>
1239                     </xslo:when>
1240                     <xslo:when test="@code = $geographic_subdivision_subfield">
1241                       <xslo:text> geographicsubdiv </xslo:text>
1242                     </xslo:when>
1243                   </xslo:choose>
1244                 </xslo:when>
1245                 <xslo:otherwise>
1246                   <xslo:value-of select="substring(' ', 1, 1)"/>
1247                 </xslo:otherwise>
1248               </xslo:choose>
1249             </xslo:if>
1250             <xslo:call-template name="chopPunctuation">
1251               <xslo:with-param name="chopString">
1252                 <xslo:value-of select="."/>
1253               </xslo:with-param>
1254             </xslo:call-template>
1255           </xslo:if>
1256         </xslo:for-each>
1257       </xslo:variable>
1258       <xslo:value-of select="normalize-space($raw_heading)"/>
1259     </z:index>
1260   </xslo:template>
1261   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='410']">
1262     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1263       <xslo:variable name="raw_heading">
1264         <xslo:for-each select="marc:subfield">
1265           <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1266             <xslo:if test="position() &gt; 1">
1267               <xslo:choose>
1268                 <xslo:when test="contains('vxyz', @code)">
1269                   <xslo:choose>
1270                     <xslo:when test="@code = $general_subdivision_subfield">
1271                       <xslo:text> generalsubdiv </xslo:text>
1272                     </xslo:when>
1273                     <xslo:when test="@code = $form_subdivision_subfield">
1274                       <xslo:text> formsubdiv </xslo:text>
1275                     </xslo:when>
1276                     <xslo:when test="@code = $chronological_subdivision_subfield">
1277                       <xslo:text> chronologicalsubdiv </xslo:text>
1278                     </xslo:when>
1279                     <xslo:when test="@code = $geographic_subdivision_subfield">
1280                       <xslo:text> geographicsubdiv </xslo:text>
1281                     </xslo:when>
1282                   </xslo:choose>
1283                 </xslo:when>
1284                 <xslo:otherwise>
1285                   <xslo:value-of select="substring(' ', 1, 1)"/>
1286                 </xslo:otherwise>
1287               </xslo:choose>
1288             </xslo:if>
1289             <xslo:call-template name="chopPunctuation">
1290               <xslo:with-param name="chopString">
1291                 <xslo:value-of select="."/>
1292               </xslo:with-param>
1293             </xslo:call-template>
1294           </xslo:if>
1295         </xslo:for-each>
1296       </xslo:variable>
1297       <xslo:value-of select="normalize-space($raw_heading)"/>
1298     </z:index>
1299   </xslo:template>
1300   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='510']">
1301     <z:index name="Match:w Match:p">
1302       <xslo:variable name="raw_heading">
1303         <xslo:for-each select="marc:subfield">
1304           <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Match:w Match:p">
1305             <xslo:if test="position() &gt; 1">
1306               <xslo:choose>
1307                 <xslo:when test="contains('vxyz', @code)">
1308                   <xslo:choose>
1309                     <xslo:when test="@code = $general_subdivision_subfield">
1310                       <xslo:text> generalsubdiv </xslo:text>
1311                     </xslo:when>
1312                     <xslo:when test="@code = $form_subdivision_subfield">
1313                       <xslo:text> formsubdiv </xslo:text>
1314                     </xslo:when>
1315                     <xslo:when test="@code = $chronological_subdivision_subfield">
1316                       <xslo:text> chronologicalsubdiv </xslo:text>
1317                     </xslo:when>
1318                     <xslo:when test="@code = $geographic_subdivision_subfield">
1319                       <xslo:text> geographicsubdiv </xslo:text>
1320                     </xslo:when>
1321                   </xslo:choose>
1322                 </xslo:when>
1323                 <xslo:otherwise>
1324                   <xslo:value-of select="substring(' ', 1, 1)"/>
1325                 </xslo:otherwise>
1326               </xslo:choose>
1327             </xslo:if>
1328             <xslo:call-template name="chopPunctuation">
1329               <xslo:with-param name="chopString">
1330                 <xslo:value-of select="."/>
1331               </xslo:with-param>
1332             </xslo:call-template>
1333           </xslo:if>
1334         </xslo:for-each>
1335       </xslo:variable>
1336       <xslo:value-of select="normalize-space($raw_heading)"/>
1337     </z:index>
1338   </xslo:template>
1339   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='111']">
1340     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1341       <xslo:variable name="raw_heading">
1342         <xslo:for-each select="marc:subfield">
1343           <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1344             <xslo:if test="position() &gt; 1">
1345               <xslo:choose>
1346                 <xslo:when test="contains('vxyz', @code)">
1347                   <xslo:choose>
1348                     <xslo:when test="@code = $general_subdivision_subfield">
1349                       <xslo:text> generalsubdiv </xslo:text>
1350                     </xslo:when>
1351                     <xslo:when test="@code = $form_subdivision_subfield">
1352                       <xslo:text> formsubdiv </xslo:text>
1353                     </xslo:when>
1354                     <xslo:when test="@code = $chronological_subdivision_subfield">
1355                       <xslo:text> chronologicalsubdiv </xslo:text>
1356                     </xslo:when>
1357                     <xslo:when test="@code = $geographic_subdivision_subfield">
1358                       <xslo:text> geographicsubdiv </xslo:text>
1359                     </xslo:when>
1360                   </xslo:choose>
1361                 </xslo:when>
1362                 <xslo:otherwise>
1363                   <xslo:value-of select="substring(' ', 1, 1)"/>
1364                 </xslo:otherwise>
1365               </xslo:choose>
1366             </xslo:if>
1367             <xslo:call-template name="chopPunctuation">
1368               <xslo:with-param name="chopString">
1369                 <xslo:value-of select="."/>
1370               </xslo:with-param>
1371             </xslo:call-template>
1372           </xslo:if>
1373         </xslo:for-each>
1374       </xslo:variable>
1375       <xslo:value-of select="normalize-space($raw_heading)"/>
1376     </z:index>
1377   </xslo:template>
1378   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='411']">
1379     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1380       <xslo:variable name="raw_heading">
1381         <xslo:for-each select="marc:subfield">
1382           <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1383             <xslo:if test="position() &gt; 1">
1384               <xslo:choose>
1385                 <xslo:when test="contains('vxyz', @code)">
1386                   <xslo:choose>
1387                     <xslo:when test="@code = $general_subdivision_subfield">
1388                       <xslo:text> generalsubdiv </xslo:text>
1389                     </xslo:when>
1390                     <xslo:when test="@code = $form_subdivision_subfield">
1391                       <xslo:text> formsubdiv </xslo:text>
1392                     </xslo:when>
1393                     <xslo:when test="@code = $chronological_subdivision_subfield">
1394                       <xslo:text> chronologicalsubdiv </xslo:text>
1395                     </xslo:when>
1396                     <xslo:when test="@code = $geographic_subdivision_subfield">
1397                       <xslo:text> geographicsubdiv </xslo:text>
1398                     </xslo:when>
1399                   </xslo:choose>
1400                 </xslo:when>
1401                 <xslo:otherwise>
1402                   <xslo:value-of select="substring(' ', 1, 1)"/>
1403                 </xslo:otherwise>
1404               </xslo:choose>
1405             </xslo:if>
1406             <xslo:call-template name="chopPunctuation">
1407               <xslo:with-param name="chopString">
1408                 <xslo:value-of select="."/>
1409               </xslo:with-param>
1410             </xslo:call-template>
1411           </xslo:if>
1412         </xslo:for-each>
1413       </xslo:variable>
1414       <xslo:value-of select="normalize-space($raw_heading)"/>
1415     </z:index>
1416   </xslo:template>
1417   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='511']">
1418     <z:index name="Match:w Match:p">
1419       <xslo:variable name="raw_heading">
1420         <xslo:for-each select="marc:subfield">
1421           <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Match:w Match:p">
1422             <xslo:if test="position() &gt; 1">
1423               <xslo:choose>
1424                 <xslo:when test="contains('vxyz', @code)">
1425                   <xslo:choose>
1426                     <xslo:when test="@code = $general_subdivision_subfield">
1427                       <xslo:text> generalsubdiv </xslo:text>
1428                     </xslo:when>
1429                     <xslo:when test="@code = $form_subdivision_subfield">
1430                       <xslo:text> formsubdiv </xslo:text>
1431                     </xslo:when>
1432                     <xslo:when test="@code = $chronological_subdivision_subfield">
1433                       <xslo:text> chronologicalsubdiv </xslo:text>
1434                     </xslo:when>
1435                     <xslo:when test="@code = $geographic_subdivision_subfield">
1436                       <xslo:text> geographicsubdiv </xslo:text>
1437                     </xslo:when>
1438                   </xslo:choose>
1439                 </xslo:when>
1440                 <xslo:otherwise>
1441                   <xslo:value-of select="substring(' ', 1, 1)"/>
1442                 </xslo:otherwise>
1443               </xslo:choose>
1444             </xslo:if>
1445             <xslo:call-template name="chopPunctuation">
1446               <xslo:with-param name="chopString">
1447                 <xslo:value-of select="."/>
1448               </xslo:with-param>
1449             </xslo:call-template>
1450           </xslo:if>
1451         </xslo:for-each>
1452       </xslo:variable>
1453       <xslo:value-of select="normalize-space($raw_heading)"/>
1454     </z:index>
1455   </xslo:template>
1456   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='130']">
1457     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1458       <xslo:variable name="raw_heading">
1459         <xslo:for-each select="marc:subfield">
1460           <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1461             <xslo:if test="position() &gt; 1">
1462               <xslo:choose>
1463                 <xslo:when test="contains('vxyz', @code)">
1464                   <xslo:choose>
1465                     <xslo:when test="@code = $general_subdivision_subfield">
1466                       <xslo:text> generalsubdiv </xslo:text>
1467                     </xslo:when>
1468                     <xslo:when test="@code = $form_subdivision_subfield">
1469                       <xslo:text> formsubdiv </xslo:text>
1470                     </xslo:when>
1471                     <xslo:when test="@code = $chronological_subdivision_subfield">
1472                       <xslo:text> chronologicalsubdiv </xslo:text>
1473                     </xslo:when>
1474                     <xslo:when test="@code = $geographic_subdivision_subfield">
1475                       <xslo:text> geographicsubdiv </xslo:text>
1476                     </xslo:when>
1477                   </xslo:choose>
1478                 </xslo:when>
1479                 <xslo:otherwise>
1480                   <xslo:value-of select="substring(' ', 1, 1)"/>
1481                 </xslo:otherwise>
1482               </xslo:choose>
1483             </xslo:if>
1484             <xslo:call-template name="chopPunctuation">
1485               <xslo:with-param name="chopString">
1486                 <xslo:value-of select="."/>
1487               </xslo:with-param>
1488             </xslo:call-template>
1489           </xslo:if>
1490         </xslo:for-each>
1491       </xslo:variable>
1492       <xslo:value-of select="normalize-space($raw_heading)"/>
1493     </z:index>
1494   </xslo:template>
1495   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='430']">
1496     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1497       <xslo:variable name="raw_heading">
1498         <xslo:for-each select="marc:subfield">
1499           <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1500             <xslo:if test="position() &gt; 1">
1501               <xslo:choose>
1502                 <xslo:when test="contains('vxyz', @code)">
1503                   <xslo:choose>
1504                     <xslo:when test="@code = $general_subdivision_subfield">
1505                       <xslo:text> generalsubdiv </xslo:text>
1506                     </xslo:when>
1507                     <xslo:when test="@code = $form_subdivision_subfield">
1508                       <xslo:text> formsubdiv </xslo:text>
1509                     </xslo:when>
1510                     <xslo:when test="@code = $chronological_subdivision_subfield">
1511                       <xslo:text> chronologicalsubdiv </xslo:text>
1512                     </xslo:when>
1513                     <xslo:when test="@code = $geographic_subdivision_subfield">
1514                       <xslo:text> geographicsubdiv </xslo:text>
1515                     </xslo:when>
1516                   </xslo:choose>
1517                 </xslo:when>
1518                 <xslo:otherwise>
1519                   <xslo:value-of select="substring(' ', 1, 1)"/>
1520                 </xslo:otherwise>
1521               </xslo:choose>
1522             </xslo:if>
1523             <xslo:call-template name="chopPunctuation">
1524               <xslo:with-param name="chopString">
1525                 <xslo:value-of select="."/>
1526               </xslo:with-param>
1527             </xslo:call-template>
1528           </xslo:if>
1529         </xslo:for-each>
1530       </xslo:variable>
1531       <xslo:value-of select="normalize-space($raw_heading)"/>
1532     </z:index>
1533   </xslo:template>
1534   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='530']">
1535     <z:index name="Match:w Match:p">
1536       <xslo:variable name="raw_heading">
1537         <xslo:for-each select="marc:subfield">
1538           <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Match:w Match:p">
1539             <xslo:if test="position() &gt; 1">
1540               <xslo:choose>
1541                 <xslo:when test="contains('vxyz', @code)">
1542                   <xslo:choose>
1543                     <xslo:when test="@code = $general_subdivision_subfield">
1544                       <xslo:text> generalsubdiv </xslo:text>
1545                     </xslo:when>
1546                     <xslo:when test="@code = $form_subdivision_subfield">
1547                       <xslo:text> formsubdiv </xslo:text>
1548                     </xslo:when>
1549                     <xslo:when test="@code = $chronological_subdivision_subfield">
1550                       <xslo:text> chronologicalsubdiv </xslo:text>
1551                     </xslo:when>
1552                     <xslo:when test="@code = $geographic_subdivision_subfield">
1553                       <xslo:text> geographicsubdiv </xslo:text>
1554                     </xslo:when>
1555                   </xslo:choose>
1556                 </xslo:when>
1557                 <xslo:otherwise>
1558                   <xslo:value-of select="substring(' ', 1, 1)"/>
1559                 </xslo:otherwise>
1560               </xslo:choose>
1561             </xslo:if>
1562             <xslo:call-template name="chopPunctuation">
1563               <xslo:with-param name="chopString">
1564                 <xslo:value-of select="."/>
1565               </xslo:with-param>
1566             </xslo:call-template>
1567           </xslo:if>
1568         </xslo:for-each>
1569       </xslo:variable>
1570       <xslo:value-of select="normalize-space($raw_heading)"/>
1571     </z:index>
1572   </xslo:template>
1573   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='148']">
1574     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1575       <xslo:variable name="raw_heading">
1576         <xslo:for-each select="marc:subfield">
1577           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1578             <xslo:if test="position() &gt; 1">
1579               <xslo:choose>
1580                 <xslo:when test="contains('vxyz', @code)">
1581                   <xslo:choose>
1582                     <xslo:when test="@code = $general_subdivision_subfield">
1583                       <xslo:text> generalsubdiv </xslo:text>
1584                     </xslo:when>
1585                     <xslo:when test="@code = $form_subdivision_subfield">
1586                       <xslo:text> formsubdiv </xslo:text>
1587                     </xslo:when>
1588                     <xslo:when test="@code = $chronological_subdivision_subfield">
1589                       <xslo:text> chronologicalsubdiv </xslo:text>
1590                     </xslo:when>
1591                     <xslo:when test="@code = $geographic_subdivision_subfield">
1592                       <xslo:text> geographicsubdiv </xslo:text>
1593                     </xslo:when>
1594                   </xslo:choose>
1595                 </xslo:when>
1596                 <xslo:otherwise>
1597                   <xslo:value-of select="substring(' ', 1, 1)"/>
1598                 </xslo:otherwise>
1599               </xslo:choose>
1600             </xslo:if>
1601             <xslo:call-template name="chopPunctuation">
1602               <xslo:with-param name="chopString">
1603                 <xslo:value-of select="."/>
1604               </xslo:with-param>
1605             </xslo:call-template>
1606           </xslo:if>
1607         </xslo:for-each>
1608       </xslo:variable>
1609       <xslo:value-of select="normalize-space($raw_heading)"/>
1610     </z:index>
1611   </xslo:template>
1612   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='448']">
1613     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1614       <xslo:variable name="raw_heading">
1615         <xslo:for-each select="marc:subfield">
1616           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1617             <xslo:if test="position() &gt; 1">
1618               <xslo:choose>
1619                 <xslo:when test="contains('vxyz', @code)">
1620                   <xslo:choose>
1621                     <xslo:when test="@code = $general_subdivision_subfield">
1622                       <xslo:text> generalsubdiv </xslo:text>
1623                     </xslo:when>
1624                     <xslo:when test="@code = $form_subdivision_subfield">
1625                       <xslo:text> formsubdiv </xslo:text>
1626                     </xslo:when>
1627                     <xslo:when test="@code = $chronological_subdivision_subfield">
1628                       <xslo:text> chronologicalsubdiv </xslo:text>
1629                     </xslo:when>
1630                     <xslo:when test="@code = $geographic_subdivision_subfield">
1631                       <xslo:text> geographicsubdiv </xslo:text>
1632                     </xslo:when>
1633                   </xslo:choose>
1634                 </xslo:when>
1635                 <xslo:otherwise>
1636                   <xslo:value-of select="substring(' ', 1, 1)"/>
1637                 </xslo:otherwise>
1638               </xslo:choose>
1639             </xslo:if>
1640             <xslo:call-template name="chopPunctuation">
1641               <xslo:with-param name="chopString">
1642                 <xslo:value-of select="."/>
1643               </xslo:with-param>
1644             </xslo:call-template>
1645           </xslo:if>
1646         </xslo:for-each>
1647       </xslo:variable>
1648       <xslo:value-of select="normalize-space($raw_heading)"/>
1649     </z:index>
1650   </xslo:template>
1651   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='548']">
1652     <z:index name="Match:w Match:p">
1653       <xslo:variable name="raw_heading">
1654         <xslo:for-each select="marc:subfield">
1655           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p">
1656             <xslo:if test="position() &gt; 1">
1657               <xslo:choose>
1658                 <xslo:when test="contains('vxyz', @code)">
1659                   <xslo:choose>
1660                     <xslo:when test="@code = $general_subdivision_subfield">
1661                       <xslo:text> generalsubdiv </xslo:text>
1662                     </xslo:when>
1663                     <xslo:when test="@code = $form_subdivision_subfield">
1664                       <xslo:text> formsubdiv </xslo:text>
1665                     </xslo:when>
1666                     <xslo:when test="@code = $chronological_subdivision_subfield">
1667                       <xslo:text> chronologicalsubdiv </xslo:text>
1668                     </xslo:when>
1669                     <xslo:when test="@code = $geographic_subdivision_subfield">
1670                       <xslo:text> geographicsubdiv </xslo:text>
1671                     </xslo:when>
1672                   </xslo:choose>
1673                 </xslo:when>
1674                 <xslo:otherwise>
1675                   <xslo:value-of select="substring(' ', 1, 1)"/>
1676                 </xslo:otherwise>
1677               </xslo:choose>
1678             </xslo:if>
1679             <xslo:call-template name="chopPunctuation">
1680               <xslo:with-param name="chopString">
1681                 <xslo:value-of select="."/>
1682               </xslo:with-param>
1683             </xslo:call-template>
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='150']">
1691     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1692       <xslo:variable name="raw_heading">
1693         <xslo:for-each select="marc:subfield">
1694           <xslo:if test="contains('abvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading: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:call-template name="chopPunctuation">
1719               <xslo:with-param name="chopString">
1720                 <xslo:value-of select="."/>
1721               </xslo:with-param>
1722             </xslo:call-template>
1723           </xslo:if>
1724         </xslo:for-each>
1725       </xslo:variable>
1726       <xslo:value-of select="normalize-space($raw_heading)"/>
1727     </z:index>
1728   </xslo:template>
1729   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='450']">
1730     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1731       <xslo:variable name="raw_heading">
1732         <xslo:for-each select="marc:subfield">
1733           <xslo:if test="contains('abvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1734             <xslo:if test="position() &gt; 1">
1735               <xslo:choose>
1736                 <xslo:when test="contains('vxyz', @code)">
1737                   <xslo:choose>
1738                     <xslo:when test="@code = $general_subdivision_subfield">
1739                       <xslo:text> generalsubdiv </xslo:text>
1740                     </xslo:when>
1741                     <xslo:when test="@code = $form_subdivision_subfield">
1742                       <xslo:text> formsubdiv </xslo:text>
1743                     </xslo:when>
1744                     <xslo:when test="@code = $chronological_subdivision_subfield">
1745                       <xslo:text> chronologicalsubdiv </xslo:text>
1746                     </xslo:when>
1747                     <xslo:when test="@code = $geographic_subdivision_subfield">
1748                       <xslo:text> geographicsubdiv </xslo:text>
1749                     </xslo:when>
1750                   </xslo:choose>
1751                 </xslo:when>
1752                 <xslo:otherwise>
1753                   <xslo:value-of select="substring(' ', 1, 1)"/>
1754                 </xslo:otherwise>
1755               </xslo:choose>
1756             </xslo:if>
1757             <xslo:call-template name="chopPunctuation">
1758               <xslo:with-param name="chopString">
1759                 <xslo:value-of select="."/>
1760               </xslo:with-param>
1761             </xslo:call-template>
1762           </xslo:if>
1763         </xslo:for-each>
1764       </xslo:variable>
1765       <xslo:value-of select="normalize-space($raw_heading)"/>
1766     </z:index>
1767   </xslo:template>
1768   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='550']">
1769     <z:index name="Match:w Match:p">
1770       <xslo:variable name="raw_heading">
1771         <xslo:for-each select="marc:subfield">
1772           <xslo:if test="contains('abvxyz', @code)" name="Match:w Match:p">
1773             <xslo:if test="position() &gt; 1">
1774               <xslo:choose>
1775                 <xslo:when test="contains('vxyz', @code)">
1776                   <xslo:choose>
1777                     <xslo:when test="@code = $general_subdivision_subfield">
1778                       <xslo:text> generalsubdiv </xslo:text>
1779                     </xslo:when>
1780                     <xslo:when test="@code = $form_subdivision_subfield">
1781                       <xslo:text> formsubdiv </xslo:text>
1782                     </xslo:when>
1783                     <xslo:when test="@code = $chronological_subdivision_subfield">
1784                       <xslo:text> chronologicalsubdiv </xslo:text>
1785                     </xslo:when>
1786                     <xslo:when test="@code = $geographic_subdivision_subfield">
1787                       <xslo:text> geographicsubdiv </xslo:text>
1788                     </xslo:when>
1789                   </xslo:choose>
1790                 </xslo:when>
1791                 <xslo:otherwise>
1792                   <xslo:value-of select="substring(' ', 1, 1)"/>
1793                 </xslo:otherwise>
1794               </xslo:choose>
1795             </xslo:if>
1796             <xslo:call-template name="chopPunctuation">
1797               <xslo:with-param name="chopString">
1798                 <xslo:value-of select="."/>
1799               </xslo:with-param>
1800             </xslo:call-template>
1801           </xslo:if>
1802         </xslo:for-each>
1803       </xslo:variable>
1804       <xslo:value-of select="normalize-space($raw_heading)"/>
1805     </z:index>
1806   </xslo:template>
1807   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='151']">
1808     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1809       <xslo:variable name="raw_heading">
1810         <xslo:for-each select="marc:subfield">
1811           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1812             <xslo:if test="position() &gt; 1">
1813               <xslo:choose>
1814                 <xslo:when test="contains('vxyz', @code)">
1815                   <xslo:choose>
1816                     <xslo:when test="@code = $general_subdivision_subfield">
1817                       <xslo:text> generalsubdiv </xslo:text>
1818                     </xslo:when>
1819                     <xslo:when test="@code = $form_subdivision_subfield">
1820                       <xslo:text> formsubdiv </xslo:text>
1821                     </xslo:when>
1822                     <xslo:when test="@code = $chronological_subdivision_subfield">
1823                       <xslo:text> chronologicalsubdiv </xslo:text>
1824                     </xslo:when>
1825                     <xslo:when test="@code = $geographic_subdivision_subfield">
1826                       <xslo:text> geographicsubdiv </xslo:text>
1827                     </xslo:when>
1828                   </xslo:choose>
1829                 </xslo:when>
1830                 <xslo:otherwise>
1831                   <xslo:value-of select="substring(' ', 1, 1)"/>
1832                 </xslo:otherwise>
1833               </xslo:choose>
1834             </xslo:if>
1835             <xslo:call-template name="chopPunctuation">
1836               <xslo:with-param name="chopString">
1837                 <xslo:value-of select="."/>
1838               </xslo:with-param>
1839             </xslo:call-template>
1840           </xslo:if>
1841         </xslo:for-each>
1842       </xslo:variable>
1843       <xslo:value-of select="normalize-space($raw_heading)"/>
1844     </z:index>
1845   </xslo:template>
1846   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='451']">
1847     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1848       <xslo:variable name="raw_heading">
1849         <xslo:for-each select="marc:subfield">
1850           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1851             <xslo:if test="position() &gt; 1">
1852               <xslo:choose>
1853                 <xslo:when test="contains('vxyz', @code)">
1854                   <xslo:choose>
1855                     <xslo:when test="@code = $general_subdivision_subfield">
1856                       <xslo:text> generalsubdiv </xslo:text>
1857                     </xslo:when>
1858                     <xslo:when test="@code = $form_subdivision_subfield">
1859                       <xslo:text> formsubdiv </xslo:text>
1860                     </xslo:when>
1861                     <xslo:when test="@code = $chronological_subdivision_subfield">
1862                       <xslo:text> chronologicalsubdiv </xslo:text>
1863                     </xslo:when>
1864                     <xslo:when test="@code = $geographic_subdivision_subfield">
1865                       <xslo:text> geographicsubdiv </xslo:text>
1866                     </xslo:when>
1867                   </xslo:choose>
1868                 </xslo:when>
1869                 <xslo:otherwise>
1870                   <xslo:value-of select="substring(' ', 1, 1)"/>
1871                 </xslo:otherwise>
1872               </xslo:choose>
1873             </xslo:if>
1874             <xslo:call-template name="chopPunctuation">
1875               <xslo:with-param name="chopString">
1876                 <xslo:value-of select="."/>
1877               </xslo:with-param>
1878             </xslo:call-template>
1879           </xslo:if>
1880         </xslo:for-each>
1881       </xslo:variable>
1882       <xslo:value-of select="normalize-space($raw_heading)"/>
1883     </z:index>
1884   </xslo:template>
1885   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='551']">
1886     <z:index name="Match:w Match:p">
1887       <xslo:variable name="raw_heading">
1888         <xslo:for-each select="marc:subfield">
1889           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p">
1890             <xslo:if test="position() &gt; 1">
1891               <xslo:choose>
1892                 <xslo:when test="contains('vxyz', @code)">
1893                   <xslo:choose>
1894                     <xslo:when test="@code = $general_subdivision_subfield">
1895                       <xslo:text> generalsubdiv </xslo:text>
1896                     </xslo:when>
1897                     <xslo:when test="@code = $form_subdivision_subfield">
1898                       <xslo:text> formsubdiv </xslo:text>
1899                     </xslo:when>
1900                     <xslo:when test="@code = $chronological_subdivision_subfield">
1901                       <xslo:text> chronologicalsubdiv </xslo:text>
1902                     </xslo:when>
1903                     <xslo:when test="@code = $geographic_subdivision_subfield">
1904                       <xslo:text> geographicsubdiv </xslo:text>
1905                     </xslo:when>
1906                   </xslo:choose>
1907                 </xslo:when>
1908                 <xslo:otherwise>
1909                   <xslo:value-of select="substring(' ', 1, 1)"/>
1910                 </xslo:otherwise>
1911               </xslo:choose>
1912             </xslo:if>
1913             <xslo:call-template name="chopPunctuation">
1914               <xslo:with-param name="chopString">
1915                 <xslo:value-of select="."/>
1916               </xslo:with-param>
1917             </xslo:call-template>
1918           </xslo:if>
1919         </xslo:for-each>
1920       </xslo:variable>
1921       <xslo:value-of select="normalize-space($raw_heading)"/>
1922     </z:index>
1923   </xslo:template>
1924   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='155']">
1925     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1926       <xslo:variable name="raw_heading">
1927         <xslo:for-each select="marc:subfield">
1928           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1929             <xslo:if test="position() &gt; 1">
1930               <xslo:choose>
1931                 <xslo:when test="contains('vxyz', @code)">
1932                   <xslo:choose>
1933                     <xslo:when test="@code = $general_subdivision_subfield">
1934                       <xslo:text> generalsubdiv </xslo:text>
1935                     </xslo:when>
1936                     <xslo:when test="@code = $form_subdivision_subfield">
1937                       <xslo:text> formsubdiv </xslo:text>
1938                     </xslo:when>
1939                     <xslo:when test="@code = $chronological_subdivision_subfield">
1940                       <xslo:text> chronologicalsubdiv </xslo:text>
1941                     </xslo:when>
1942                     <xslo:when test="@code = $geographic_subdivision_subfield">
1943                       <xslo:text> geographicsubdiv </xslo:text>
1944                     </xslo:when>
1945                   </xslo:choose>
1946                 </xslo:when>
1947                 <xslo:otherwise>
1948                   <xslo:value-of select="substring(' ', 1, 1)"/>
1949                 </xslo:otherwise>
1950               </xslo:choose>
1951             </xslo:if>
1952             <xslo:call-template name="chopPunctuation">
1953               <xslo:with-param name="chopString">
1954                 <xslo:value-of select="."/>
1955               </xslo:with-param>
1956             </xslo:call-template>
1957           </xslo:if>
1958         </xslo:for-each>
1959       </xslo:variable>
1960       <xslo:value-of select="normalize-space($raw_heading)"/>
1961     </z:index>
1962   </xslo:template>
1963   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='455']">
1964     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1965       <xslo:variable name="raw_heading">
1966         <xslo:for-each select="marc:subfield">
1967           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1968             <xslo:if test="position() &gt; 1">
1969               <xslo:choose>
1970                 <xslo:when test="contains('vxyz', @code)">
1971                   <xslo:choose>
1972                     <xslo:when test="@code = $general_subdivision_subfield">
1973                       <xslo:text> generalsubdiv </xslo:text>
1974                     </xslo:when>
1975                     <xslo:when test="@code = $form_subdivision_subfield">
1976                       <xslo:text> formsubdiv </xslo:text>
1977                     </xslo:when>
1978                     <xslo:when test="@code = $chronological_subdivision_subfield">
1979                       <xslo:text> chronologicalsubdiv </xslo:text>
1980                     </xslo:when>
1981                     <xslo:when test="@code = $geographic_subdivision_subfield">
1982                       <xslo:text> geographicsubdiv </xslo:text>
1983                     </xslo:when>
1984                   </xslo:choose>
1985                 </xslo:when>
1986                 <xslo:otherwise>
1987                   <xslo:value-of select="substring(' ', 1, 1)"/>
1988                 </xslo:otherwise>
1989               </xslo:choose>
1990             </xslo:if>
1991             <xslo:call-template name="chopPunctuation">
1992               <xslo:with-param name="chopString">
1993                 <xslo:value-of select="."/>
1994               </xslo:with-param>
1995             </xslo:call-template>
1996           </xslo:if>
1997         </xslo:for-each>
1998       </xslo:variable>
1999       <xslo:value-of select="normalize-space($raw_heading)"/>
2000     </z:index>
2001   </xslo:template>
2002   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='555']">
2003     <z:index name="Match:w Match:p">
2004       <xslo:variable name="raw_heading">
2005         <xslo:for-each select="marc:subfield">
2006           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p">
2007             <xslo:if test="position() &gt; 1">
2008               <xslo:choose>
2009                 <xslo:when test="contains('vxyz', @code)">
2010                   <xslo:choose>
2011                     <xslo:when test="@code = $general_subdivision_subfield">
2012                       <xslo:text> generalsubdiv </xslo:text>
2013                     </xslo:when>
2014                     <xslo:when test="@code = $form_subdivision_subfield">
2015                       <xslo:text> formsubdiv </xslo:text>
2016                     </xslo:when>
2017                     <xslo:when test="@code = $chronological_subdivision_subfield">
2018                       <xslo:text> chronologicalsubdiv </xslo:text>
2019                     </xslo:when>
2020                     <xslo:when test="@code = $geographic_subdivision_subfield">
2021                       <xslo:text> geographicsubdiv </xslo:text>
2022                     </xslo:when>
2023                   </xslo:choose>
2024                 </xslo:when>
2025                 <xslo:otherwise>
2026                   <xslo:value-of select="substring(' ', 1, 1)"/>
2027                 </xslo:otherwise>
2028               </xslo:choose>
2029             </xslo:if>
2030             <xslo:call-template name="chopPunctuation">
2031               <xslo:with-param name="chopString">
2032                 <xslo:value-of select="."/>
2033               </xslo:with-param>
2034             </xslo:call-template>
2035           </xslo:if>
2036         </xslo:for-each>
2037       </xslo:variable>
2038       <xslo:value-of select="normalize-space($raw_heading)"/>
2039     </z:index>
2040   </xslo:template>
2041   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='180']">
2042     <z:index name="Match-subdivision:p Match-subdivision:s">
2043       <xslo:variable name="raw_heading">
2044         <xslo:for-each select="marc:subfield">
2045           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision:p Match-subdivision:s">
2046             <xslo:if test="position() &gt; 1">
2047               <xslo:choose>
2048                 <xslo:when test="contains('vxyz', @code)">
2049                   <xslo:choose>
2050                     <xslo:when test="@code = $general_subdivision_subfield">
2051                       <xslo:text> generalsubdiv </xslo:text>
2052                     </xslo:when>
2053                     <xslo:when test="@code = $form_subdivision_subfield">
2054                       <xslo:text> formsubdiv </xslo:text>
2055                     </xslo:when>
2056                     <xslo:when test="@code = $chronological_subdivision_subfield">
2057                       <xslo:text> chronologicalsubdiv </xslo:text>
2058                     </xslo:when>
2059                     <xslo:when test="@code = $geographic_subdivision_subfield">
2060                       <xslo:text> geographicsubdiv </xslo:text>
2061                     </xslo:when>
2062                   </xslo:choose>
2063                 </xslo:when>
2064                 <xslo:otherwise>
2065                   <xslo:value-of select="substring(' ', 1, 1)"/>
2066                 </xslo:otherwise>
2067               </xslo:choose>
2068             </xslo:if>
2069             <xslo:call-template name="chopPunctuation">
2070               <xslo:with-param name="chopString">
2071                 <xslo:value-of select="."/>
2072               </xslo:with-param>
2073             </xslo:call-template>
2074           </xslo:if>
2075         </xslo:for-each>
2076       </xslo:variable>
2077       <xslo:value-of select="normalize-space($raw_heading)"/>
2078     </z:index>
2079   </xslo:template>
2080   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='480']">
2081     <z:index name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2082       <xslo:variable name="raw_heading">
2083         <xslo:for-each select="marc:subfield">
2084           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2085             <xslo:if test="position() &gt; 1">
2086               <xslo:choose>
2087                 <xslo:when test="contains('vxyz', @code)">
2088                   <xslo:choose>
2089                     <xslo:when test="@code = $general_subdivision_subfield">
2090                       <xslo:text> generalsubdiv </xslo:text>
2091                     </xslo:when>
2092                     <xslo:when test="@code = $form_subdivision_subfield">
2093                       <xslo:text> formsubdiv </xslo:text>
2094                     </xslo:when>
2095                     <xslo:when test="@code = $chronological_subdivision_subfield">
2096                       <xslo:text> chronologicalsubdiv </xslo:text>
2097                     </xslo:when>
2098                     <xslo:when test="@code = $geographic_subdivision_subfield">
2099                       <xslo:text> geographicsubdiv </xslo:text>
2100                     </xslo:when>
2101                   </xslo:choose>
2102                 </xslo:when>
2103                 <xslo:otherwise>
2104                   <xslo:value-of select="substring(' ', 1, 1)"/>
2105                 </xslo:otherwise>
2106               </xslo:choose>
2107             </xslo:if>
2108             <xslo:call-template name="chopPunctuation">
2109               <xslo:with-param name="chopString">
2110                 <xslo:value-of select="."/>
2111               </xslo:with-param>
2112             </xslo:call-template>
2113           </xslo:if>
2114         </xslo:for-each>
2115       </xslo:variable>
2116       <xslo:value-of select="normalize-space($raw_heading)"/>
2117     </z:index>
2118   </xslo:template>
2119   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='181']">
2120     <z:index name="Match-subdivision:p Match-subdivision:s">
2121       <xslo:variable name="raw_heading">
2122         <xslo:for-each select="marc:subfield">
2123           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision:p Match-subdivision:s">
2124             <xslo:if test="position() &gt; 1">
2125               <xslo:choose>
2126                 <xslo:when test="contains('vxyz', @code)">
2127                   <xslo:choose>
2128                     <xslo:when test="@code = $general_subdivision_subfield">
2129                       <xslo:text> generalsubdiv </xslo:text>
2130                     </xslo:when>
2131                     <xslo:when test="@code = $form_subdivision_subfield">
2132                       <xslo:text> formsubdiv </xslo:text>
2133                     </xslo:when>
2134                     <xslo:when test="@code = $chronological_subdivision_subfield">
2135                       <xslo:text> chronologicalsubdiv </xslo:text>
2136                     </xslo:when>
2137                     <xslo:when test="@code = $geographic_subdivision_subfield">
2138                       <xslo:text> geographicsubdiv </xslo:text>
2139                     </xslo:when>
2140                   </xslo:choose>
2141                 </xslo:when>
2142                 <xslo:otherwise>
2143                   <xslo:value-of select="substring(' ', 1, 1)"/>
2144                 </xslo:otherwise>
2145               </xslo:choose>
2146             </xslo:if>
2147             <xslo:call-template name="chopPunctuation">
2148               <xslo:with-param name="chopString">
2149                 <xslo:value-of select="."/>
2150               </xslo:with-param>
2151             </xslo:call-template>
2152           </xslo:if>
2153         </xslo:for-each>
2154       </xslo:variable>
2155       <xslo:value-of select="normalize-space($raw_heading)"/>
2156     </z:index>
2157   </xslo:template>
2158   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='481']">
2159     <z:index name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2160       <xslo:variable name="raw_heading">
2161         <xslo:for-each select="marc:subfield">
2162           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2163             <xslo:if test="position() &gt; 1">
2164               <xslo:choose>
2165                 <xslo:when test="contains('vxyz', @code)">
2166                   <xslo:choose>
2167                     <xslo:when test="@code = $general_subdivision_subfield">
2168                       <xslo:text> generalsubdiv </xslo:text>
2169                     </xslo:when>
2170                     <xslo:when test="@code = $form_subdivision_subfield">
2171                       <xslo:text> formsubdiv </xslo:text>
2172                     </xslo:when>
2173                     <xslo:when test="@code = $chronological_subdivision_subfield">
2174                       <xslo:text> chronologicalsubdiv </xslo:text>
2175                     </xslo:when>
2176                     <xslo:when test="@code = $geographic_subdivision_subfield">
2177                       <xslo:text> geographicsubdiv </xslo:text>
2178                     </xslo:when>
2179                   </xslo:choose>
2180                 </xslo:when>
2181                 <xslo:otherwise>
2182                   <xslo:value-of select="substring(' ', 1, 1)"/>
2183                 </xslo:otherwise>
2184               </xslo:choose>
2185             </xslo:if>
2186             <xslo:call-template name="chopPunctuation">
2187               <xslo:with-param name="chopString">
2188                 <xslo:value-of select="."/>
2189               </xslo:with-param>
2190             </xslo:call-template>
2191           </xslo:if>
2192         </xslo:for-each>
2193       </xslo:variable>
2194       <xslo:value-of select="normalize-space($raw_heading)"/>
2195     </z:index>
2196   </xslo:template>
2197   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='182']">
2198     <z:index name="Match-subdivision:p Match-subdivision:s">
2199       <xslo:variable name="raw_heading">
2200         <xslo:for-each select="marc:subfield">
2201           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision:p Match-subdivision:s">
2202             <xslo:if test="position() &gt; 1">
2203               <xslo:choose>
2204                 <xslo:when test="contains('vxyz', @code)">
2205                   <xslo:choose>
2206                     <xslo:when test="@code = $general_subdivision_subfield">
2207                       <xslo:text> generalsubdiv </xslo:text>
2208                     </xslo:when>
2209                     <xslo:when test="@code = $form_subdivision_subfield">
2210                       <xslo:text> formsubdiv </xslo:text>
2211                     </xslo:when>
2212                     <xslo:when test="@code = $chronological_subdivision_subfield">
2213                       <xslo:text> chronologicalsubdiv </xslo:text>
2214                     </xslo:when>
2215                     <xslo:when test="@code = $geographic_subdivision_subfield">
2216                       <xslo:text> geographicsubdiv </xslo:text>
2217                     </xslo:when>
2218                   </xslo:choose>
2219                 </xslo:when>
2220                 <xslo:otherwise>
2221                   <xslo:value-of select="substring(' ', 1, 1)"/>
2222                 </xslo:otherwise>
2223               </xslo:choose>
2224             </xslo:if>
2225             <xslo:call-template name="chopPunctuation">
2226               <xslo:with-param name="chopString">
2227                 <xslo:value-of select="."/>
2228               </xslo:with-param>
2229             </xslo:call-template>
2230           </xslo:if>
2231         </xslo:for-each>
2232       </xslo:variable>
2233       <xslo:value-of select="normalize-space($raw_heading)"/>
2234     </z:index>
2235   </xslo:template>
2236   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='482']">
2237     <z:index name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2238       <xslo:variable name="raw_heading">
2239         <xslo:for-each select="marc:subfield">
2240           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2241             <xslo:if test="position() &gt; 1">
2242               <xslo:choose>
2243                 <xslo:when test="contains('vxyz', @code)">
2244                   <xslo:choose>
2245                     <xslo:when test="@code = $general_subdivision_subfield">
2246                       <xslo:text> generalsubdiv </xslo:text>
2247                     </xslo:when>
2248                     <xslo:when test="@code = $form_subdivision_subfield">
2249                       <xslo:text> formsubdiv </xslo:text>
2250                     </xslo:when>
2251                     <xslo:when test="@code = $chronological_subdivision_subfield">
2252                       <xslo:text> chronologicalsubdiv </xslo:text>
2253                     </xslo:when>
2254                     <xslo:when test="@code = $geographic_subdivision_subfield">
2255                       <xslo:text> geographicsubdiv </xslo:text>
2256                     </xslo:when>
2257                   </xslo:choose>
2258                 </xslo:when>
2259                 <xslo:otherwise>
2260                   <xslo:value-of select="substring(' ', 1, 1)"/>
2261                 </xslo:otherwise>
2262               </xslo:choose>
2263             </xslo:if>
2264             <xslo:call-template name="chopPunctuation">
2265               <xslo:with-param name="chopString">
2266                 <xslo:value-of select="."/>
2267               </xslo:with-param>
2268             </xslo:call-template>
2269           </xslo:if>
2270         </xslo:for-each>
2271       </xslo:variable>
2272       <xslo:value-of select="normalize-space($raw_heading)"/>
2273     </z:index>
2274   </xslo:template>
2275   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='485']">
2276     <z:index name="Match-subdivision:p Match-subdivision:s">
2277       <xslo:variable name="raw_heading">
2278         <xslo:for-each select="marc:subfield">
2279           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision:p Match-subdivision:s">
2280             <xslo:if test="position() &gt; 1">
2281               <xslo:choose>
2282                 <xslo:when test="contains('vxyz', @code)">
2283                   <xslo:choose>
2284                     <xslo:when test="@code = $general_subdivision_subfield">
2285                       <xslo:text> generalsubdiv </xslo:text>
2286                     </xslo:when>
2287                     <xslo:when test="@code = $form_subdivision_subfield">
2288                       <xslo:text> formsubdiv </xslo:text>
2289                     </xslo:when>
2290                     <xslo:when test="@code = $chronological_subdivision_subfield">
2291                       <xslo:text> chronologicalsubdiv </xslo:text>
2292                     </xslo:when>
2293                     <xslo:when test="@code = $geographic_subdivision_subfield">
2294                       <xslo:text> geographicsubdiv </xslo:text>
2295                     </xslo:when>
2296                   </xslo:choose>
2297                 </xslo:when>
2298                 <xslo:otherwise>
2299                   <xslo:value-of select="substring(' ', 1, 1)"/>
2300                 </xslo:otherwise>
2301               </xslo:choose>
2302             </xslo:if>
2303             <xslo:call-template name="chopPunctuation">
2304               <xslo:with-param name="chopString">
2305                 <xslo:value-of select="."/>
2306               </xslo:with-param>
2307             </xslo:call-template>
2308           </xslo:if>
2309         </xslo:for-each>
2310       </xslo:variable>
2311       <xslo:value-of select="normalize-space($raw_heading)"/>
2312     </z:index>
2313   </xslo:template>
2314   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='185']">
2315     <z:index name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2316       <xslo:variable name="raw_heading">
2317         <xslo:for-each select="marc:subfield">
2318           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2319             <xslo:if test="position() &gt; 1">
2320               <xslo:choose>
2321                 <xslo:when test="contains('vxyz', @code)">
2322                   <xslo:choose>
2323                     <xslo:when test="@code = $general_subdivision_subfield">
2324                       <xslo:text> generalsubdiv </xslo:text>
2325                     </xslo:when>
2326                     <xslo:when test="@code = $form_subdivision_subfield">
2327                       <xslo:text> formsubdiv </xslo:text>
2328                     </xslo:when>
2329                     <xslo:when test="@code = $chronological_subdivision_subfield">
2330                       <xslo:text> chronologicalsubdiv </xslo:text>
2331                     </xslo:when>
2332                     <xslo:when test="@code = $geographic_subdivision_subfield">
2333                       <xslo:text> geographicsubdiv </xslo:text>
2334                     </xslo:when>
2335                   </xslo:choose>
2336                 </xslo:when>
2337                 <xslo:otherwise>
2338                   <xslo:value-of select="substring(' ', 1, 1)"/>
2339                 </xslo:otherwise>
2340               </xslo:choose>
2341             </xslo:if>
2342             <xslo:call-template name="chopPunctuation">
2343               <xslo:with-param name="chopString">
2344                 <xslo:value-of select="."/>
2345               </xslo:with-param>
2346             </xslo:call-template>
2347           </xslo:if>
2348         </xslo:for-each>
2349       </xslo:variable>
2350       <xslo:value-of select="normalize-space($raw_heading)"/>
2351     </z:index>
2352   </xslo:template>
2353   <xslo:variable name="form_subdivision_subfield">v</xslo:variable>
2354   <xslo:variable name="general_subdivision_subfield">x</xslo:variable>
2355   <xslo:variable name="chronological_subdivision_subfield">y</xslo:variable>
2356   <xslo:variable name="geographic_subdivision_subfield">z</xslo:variable>
2357   <xslo:template mode="index_subject_thesaurus" match="marc:controlfield[@tag='008']">
2358     <xslo:variable name="thesaurus_code1" select="substring(., 12, 1)"/>
2359     <xslo:variable name="full_thesaurus_code">
2360       <xslo:choose>
2361         <xslo:when test="$thesaurus_code1 = 'a'">
2362           <xslo:text>lcsh</xslo:text>
2363         </xslo:when>
2364         <xslo:when test="$thesaurus_code1 = 'b'">
2365           <xslo:text>lcac</xslo:text>
2366         </xslo:when>
2367         <xslo:when test="$thesaurus_code1 = 'c'">
2368           <xslo:text>mesh</xslo:text>
2369         </xslo:when>
2370         <xslo:when test="$thesaurus_code1 = 'd'">
2371           <xslo:text>nal</xslo:text>
2372         </xslo:when>
2373         <xslo:when test="$thesaurus_code1 = 'k'">
2374           <xslo:text>cash</xslo:text>
2375         </xslo:when>
2376         <xslo:when test="$thesaurus_code1 = 'n'">
2377           <xslo:text>notapplicable</xslo:text>
2378         </xslo:when>
2379         <xslo:when test="$thesaurus_code1 = 'r'">
2380           <xslo:text>aat</xslo:text>
2381         </xslo:when>
2382         <xslo:when test="$thesaurus_code1 = 's'">
2383           <xslo:text>sears</xslo:text>
2384         </xslo:when>
2385         <xslo:when test="$thesaurus_code1 = 'v'">
2386           <xslo:text>rvm</xslo:text>
2387         </xslo:when>
2388         <xslo:when test="$thesaurus_code1 = 'z'">
2389           <xslo:choose>
2390             <xslo:when test="//marc:datafield[@tag='040']/marc:subfield[@code='f']">
2391               <xslo:value-of select="//marc:datafield[@tag='040']/marc:subfield[@code='f']"/>
2392             </xslo:when>
2393             <xslo:otherwise>
2394               <xslo:text>notdefined</xslo:text>
2395             </xslo:otherwise>
2396           </xslo:choose>
2397         </xslo:when>
2398         <xslo:otherwise>
2399           <xslo:text>notdefined</xslo:text>
2400         </xslo:otherwise>
2401       </xslo:choose>
2402     </xslo:variable>
2403     <z:index name="Subject-heading-thesaurus:w">
2404       <xslo:value-of select="$full_thesaurus_code"/>
2405     </z:index>
2406   </xslo:template>
2407   <xslo:template match="*">
2408     <z:index name="Any:w Any:p">
2409       <xslo:value-of select="."/>
2410     </z:index>
2411   </xslo:template>
2412   <xslo:template name="chopPunctuation">
2413     <xslo:param name="chopString"/>
2414     <xslo:variable name="length" select="string-length($chopString)"/>
2415     <xslo:choose>
2416       <xslo:when test="$length=0"/>
2417       <xslo:when test="contains('-,.:=;!%/', substring($chopString,$length,1))">
2418         <xslo:call-template name="chopPunctuation">
2419           <xslo:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
2420         </xslo:call-template>
2421       </xslo:when>
2422       <xslo:when test="not($chopString)"/>
2423       <xslo:otherwise>
2424         <xslo:value-of select="$chopString"/>
2425       </xslo:otherwise>
2426     </xslo:choose>
2427     <xslo:text/>
2428   </xslo:template>
2429 </xslo:stylesheet>