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