Bug 9123: Authorities search ordered by authid does not work
[koha.git] / etc / zebradb / marc_defs / marc21 / authorities / authority-zebra-indexdefs.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 This file has been automatically generated from a Koha index definition file
4 with the stylesheet koha-indexdefs-to-zebra.xsl. Do not manually edit this file,
5 as it may be overwritten. To regenerate, edit the appropriate Koha index
6 definition file (probably something like {biblio,authority}-koha-indexdefs.xml) and run:
7 `xsltproc koha-indexdefs-to-zebra.xsl {biblio,authority}-koha-indexdefs.xml >
8 {biblio,authority}-zebra-indexdefs.xsl` (substituting the appropriate file names).
9 -->
10 <xslo:stylesheet xmlns:xslo="http://www.w3.org/1999/XSL/Transform" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:z="http://indexdata.com/zebra-2.0" xmlns:kohaidx="http://www.koha-community.org/schemas/index-defs" version="1.0">
11   <xslo:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
12   <xslo:template match="text()"/>
13   <xslo:template match="text()" mode="index_subfields"/>
14   <xslo:template match="text()" mode="index_data_field"/>
15   <xslo:template match="text()" mode="index_heading"/>
16   <xslo:template match="text()" mode="index_heading_conditional"/>
17   <xslo:template match="text()" mode="index_match_heading"/>
18   <xslo:template match="text()" mode="index_subject_thesaurus"/>
19   <xslo:template match="/">
20     <xslo:if test="marc:collection">
21       <collection>
22         <xslo:apply-templates select="marc:collection/marc:record"/>
23       </collection>
24     </xslo:if>
25     <xslo:if test="marc:record">
26       <xslo:apply-templates select="marc:record"/>
27     </xslo:if>
28   </xslo:template>
29   <xslo:template match="marc:record">
30     <xslo:variable name="idfield" select="normalize-space(marc:controlfield[@tag='001'])"/>
31     <z:record type="update">
32       <xslo:attribute name="z:id">
33         <xslo:value-of select="$idfield"/>
34       </xslo:attribute>
35       <xslo:apply-templates/>
36       <xslo:apply-templates mode="index_subfields"/>
37       <xslo:apply-templates mode="index_data_field"/>
38       <xslo:apply-templates mode="index_heading"/>
39       <xslo:apply-templates mode="index_heading_conditional"/>
40       <xslo:apply-templates mode="index_match_heading"/>
41       <xslo:apply-templates mode="index_subject_thesaurus"/>
42     </z:record>
43   </xslo:template>
44   <xslo:template match="marc:leader">
45     <z:index name="Record-status:w">
46       <xslo:value-of select="substring(., 6, 1)"/>
47     </z:index>
48     <z:index name="Encoding-level:w">
49       <xslo:value-of select="substring(., 18, 1)"/>
50     </z:index>
51   </xslo:template>
52   <xslo:template match="marc:controlfield[@tag='001']">
53     <z:index name="Local-Number:w Local-Number:n Local-Number:s">
54       <xslo:value-of select="."/>
55     </z:index>
56   </xslo:template>
57   <xslo:template match="marc:controlfield[@tag='008']">
58     <z:index name="Kind-of-record:w">
59       <xslo:value-of select="substring(., 10, 1)"/>
60     </z:index>
61     <z:index name="Descriptive-cataloging-rules:w">
62       <xslo:value-of select="substring(., 11, 1)"/>
63     </z:index>
64     <z:index name="Heading-use-main-or-added-entry:w">
65       <xslo:value-of select="substring(., 15, 1)"/>
66     </z:index>
67     <z:index name="Heading-use-subject-added-entry:w">
68       <xslo:value-of select="substring(., 16, 1)"/>
69     </z:index>
70     <z:index name="Heading-use-series-added-entry:w">
71       <xslo:value-of select="substring(., 17, 1)"/>
72     </z:index>
73   </xslo:template>
74   <xslo:template mode="index_subfields" match="marc:datafield[@tag='010']">
75     <xslo:for-each select="marc:subfield">
76       <xslo:if test="contains('az', @code)">
77         <z:index name="LC-card-number:w LC-card-number:p">
78           <xslo:value-of select="."/>
79         </z:index>
80       </xslo:if>
81     </xslo:for-each>
82   </xslo:template>
83   <xslo:template mode="index_subfields" match="marc:datafield[@tag='040']">
84     <xslo:for-each select="marc:subfield">
85       <xslo:if test="contains('acd', @code)">
86         <z:index name="Record-source:w Record-source:p">
87           <xslo:value-of select="."/>
88         </z:index>
89       </xslo:if>
90     </xslo:for-each>
91   </xslo:template>
92   <xslo:template mode="index_subfields" match="marc:datafield[@tag='100']">
93     <xslo:for-each select="marc:subfield">
94       <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)">
95         <z:index name="Personal-name:w Personal-name:p Personal-name:s">
96           <xslo:value-of select="."/>
97         </z:index>
98       </xslo:if>
99     </xslo:for-each>
100   </xslo:template>
101   <xslo:template mode="index_subfields" match="marc:datafield[@tag='110']">
102     <xslo:for-each select="marc:subfield">
103       <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)">
104         <z:index name="Corporate-name:w Corporate-name:p">
105           <xslo:value-of select="."/>
106         </z:index>
107       </xslo:if>
108     </xslo:for-each>
109   </xslo:template>
110   <xslo:template mode="index_subfields" match="marc:datafield[@tag='111']">
111     <xslo:for-each select="marc:subfield">
112       <xslo:if test="contains('acdefghjklnpqstvxyz', @code)">
113         <z:index name="Meeting-name:w Meeting-name:p">
114           <xslo:value-of select="."/>
115         </z:index>
116       </xslo:if>
117     </xslo:for-each>
118   </xslo:template>
119   <xslo:template mode="index_subfields" match="marc:datafield[@tag='130']">
120     <xslo:for-each select="marc:subfield">
121       <xslo:if test="contains('adfghklmnoprstvxyz', @code)">
122         <z:index name="Title-uniform:w Title-uniform:p">
123           <xslo:value-of select="."/>
124         </z:index>
125       </xslo:if>
126     </xslo:for-each>
127   </xslo:template>
128   <xslo:template mode="index_subfields" match="marc:datafield[@tag='148']">
129     <xslo:for-each select="marc:subfield">
130       <xslo:if test="contains('avxyz', @code)">
131         <z:index name="Chronological-term:w Chronological-term:p">
132           <xslo:value-of select="."/>
133         </z:index>
134       </xslo:if>
135     </xslo:for-each>
136   </xslo:template>
137   <xslo:template mode="index_subfields" match="marc:datafield[@tag='150']">
138     <xslo:for-each select="marc:subfield">
139       <xslo:if test="contains('abvxyz', @code)">
140         <z:index name="Subject-topical:w Subject-topical:p">
141           <xslo:value-of select="."/>
142         </z:index>
143       </xslo:if>
144     </xslo:for-each>
145   </xslo:template>
146   <xslo:template mode="index_subfields" match="marc:datafield[@tag='151']">
147     <xslo:for-each select="marc:subfield">
148       <xslo:if test="contains('avxyz', @code)">
149         <z:index name="Name-geographic:w Name-geographic:p">
150           <xslo:value-of select="."/>
151         </z:index>
152       </xslo:if>
153     </xslo:for-each>
154   </xslo:template>
155   <xslo:template mode="index_subfields" match="marc:datafield[@tag='155']">
156     <xslo:for-each select="marc:subfield">
157       <xslo:if test="contains('avxyz', @code)">
158         <z:index name="Term-genre-form:w Term-genre-form:p">
159           <xslo:value-of select="."/>
160         </z:index>
161       </xslo:if>
162     </xslo:for-each>
163   </xslo:template>
164   <xslo:template mode="index_subfields" match="marc:datafield[@tag='942']">
165     <xslo:for-each select="marc:subfield">
166       <xslo:if test="contains('a', @code)">
167         <z:index name="authtype:w">
168           <xslo:value-of select="."/>
169         </z:index>
170       </xslo:if>
171     </xslo:for-each>
172   </xslo:template>
173   <xslo:template mode="index_heading" match="marc:datafield[@tag='100']">
174     <z:index name="Personal-name-heading:w Personal-name-heading:p Personal-name-heading:s Heading:w Heading:p Heading:s">
175       <xslo:variable name="raw_heading">
176         <xslo:for-each select="marc:subfield">
177           <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">
178             <xslo:if test="position() &gt; 1">
179               <xslo:choose>
180                 <xslo:when test="contains('vxyz', @code)">
181                   <xslo:text>--</xslo:text>
182                 </xslo:when>
183                 <xslo:otherwise>
184                   <xslo:value-of select="substring(' ', 1, 1)"/>
185                 </xslo:otherwise>
186               </xslo:choose>
187             </xslo:if>
188             <xslo:value-of select="."/>
189           </xslo:if>
190         </xslo:for-each>
191       </xslo:variable>
192       <xslo:value-of select="normalize-space($raw_heading)"/>
193     </z:index>
194     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
195       <xslo:variable name="raw_heading">
196         <xslo:for-each select="marc:subfield">
197           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
198             <xslo:if test="position() &gt; 1">
199               <xslo:choose>
200                 <xslo:when test="contains('', @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='400']">
216     <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">
217       <xslo:variable name="raw_heading">
218         <xslo:for-each select="marc:subfield">
219           <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">
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='500']">
238     <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">
239       <xslo:variable name="raw_heading">
240         <xslo:for-each select="marc:subfield">
241           <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">
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   </xslo:template>
259   <xslo:template mode="index_heading" match="marc:datafield[@tag='110']">
260     <z:index name="Corporate-name-heading:w Corporate-name-heading:p Corporate-name-heading:s Heading:w Heading:p Heading:s">
261       <xslo:variable name="raw_heading">
262         <xslo:for-each select="marc:subfield">
263           <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">
264             <xslo:if test="position() &gt; 1">
265               <xslo:choose>
266                 <xslo:when test="contains('vxyz', @code)">
267                   <xslo:text>--</xslo:text>
268                 </xslo:when>
269                 <xslo:otherwise>
270                   <xslo:value-of select="substring(' ', 1, 1)"/>
271                 </xslo:otherwise>
272               </xslo:choose>
273             </xslo:if>
274             <xslo:value-of select="."/>
275           </xslo:if>
276         </xslo:for-each>
277       </xslo:variable>
278       <xslo:value-of select="normalize-space($raw_heading)"/>
279     </z:index>
280     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
281       <xslo:variable name="raw_heading">
282         <xslo:for-each select="marc:subfield">
283           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
284             <xslo:if test="position() &gt; 1">
285               <xslo:choose>
286                 <xslo:when test="contains('', @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='410']">
302     <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">
303       <xslo:variable name="raw_heading">
304         <xslo:for-each select="marc:subfield">
305           <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">
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='510']">
324     <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">
325       <xslo:variable name="raw_heading">
326         <xslo:for-each select="marc:subfield">
327           <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">
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   </xslo:template>
345   <xslo:template mode="index_heading" match="marc:datafield[@tag='111']">
346     <z:index name="Meeting-name-heading:w Meeting-name-heading:p Meeting-name-heading:s Heading:w Heading:p Heading:s">
347       <xslo:variable name="raw_heading">
348         <xslo:for-each select="marc:subfield">
349           <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">
350             <xslo:if test="position() &gt; 1">
351               <xslo:choose>
352                 <xslo:when test="contains('vxyz', @code)">
353                   <xslo:text>--</xslo:text>
354                 </xslo:when>
355                 <xslo:otherwise>
356                   <xslo:value-of select="substring(' ', 1, 1)"/>
357                 </xslo:otherwise>
358               </xslo:choose>
359             </xslo:if>
360             <xslo:value-of select="."/>
361           </xslo:if>
362         </xslo:for-each>
363       </xslo:variable>
364       <xslo:value-of select="normalize-space($raw_heading)"/>
365     </z:index>
366     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
367       <xslo:variable name="raw_heading">
368         <xslo:for-each select="marc:subfield">
369           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
370             <xslo:if test="position() &gt; 1">
371               <xslo:choose>
372                 <xslo:when test="contains('', @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='411']">
388     <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">
389       <xslo:variable name="raw_heading">
390         <xslo:for-each select="marc:subfield">
391           <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">
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='511']">
410     <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">
411       <xslo:variable name="raw_heading">
412         <xslo:for-each select="marc:subfield">
413           <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">
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   </xslo:template>
431   <xslo:template mode="index_heading" match="marc:datafield[@tag='130']">
432     <z:index name="Title-uniform-heading:w Title-uniform-heading:p Title-uniform-heading:s Heading:w Heading:p Heading:s">
433       <xslo:variable name="raw_heading">
434         <xslo:for-each select="marc:subfield">
435           <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">
436             <xslo:if test="position() &gt; 1">
437               <xslo:choose>
438                 <xslo:when test="contains('vxyz', @code)">
439                   <xslo:text>--</xslo:text>
440                 </xslo:when>
441                 <xslo:otherwise>
442                   <xslo:value-of select="substring(' ', 1, 1)"/>
443                 </xslo:otherwise>
444               </xslo:choose>
445             </xslo:if>
446             <xslo:value-of select="."/>
447           </xslo:if>
448         </xslo:for-each>
449       </xslo:variable>
450       <xslo:value-of select="normalize-space($raw_heading)"/>
451     </z:index>
452     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
453       <xslo:variable name="raw_heading">
454         <xslo:for-each select="marc:subfield">
455           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
456             <xslo:if test="position() &gt; 1">
457               <xslo:choose>
458                 <xslo:when test="contains('', @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='430']">
474     <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">
475       <xslo:variable name="raw_heading">
476         <xslo:for-each select="marc:subfield">
477           <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">
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='530']">
496     <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">
497       <xslo:variable name="raw_heading">
498         <xslo:for-each select="marc:subfield">
499           <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">
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   </xslo:template>
517   <xslo:template mode="index_heading" match="marc:datafield[@tag='148']">
518     <z:index name="Chronological-term-heading:w Chronological-term-heading:p Chronological-term-heading:s Heading:w Heading:p Heading:s">
519       <xslo:variable name="raw_heading">
520         <xslo:for-each select="marc:subfield">
521           <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">
522             <xslo:if test="position() &gt; 1">
523               <xslo:choose>
524                 <xslo:when test="contains('vxyz', @code)">
525                   <xslo:text>--</xslo:text>
526                 </xslo:when>
527                 <xslo:otherwise>
528                   <xslo:value-of select="substring(' ', 1, 1)"/>
529                 </xslo:otherwise>
530               </xslo:choose>
531             </xslo:if>
532             <xslo:value-of select="."/>
533           </xslo:if>
534         </xslo:for-each>
535       </xslo:variable>
536       <xslo:value-of select="normalize-space($raw_heading)"/>
537     </z:index>
538     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
539       <xslo:variable name="raw_heading">
540         <xslo:for-each select="marc:subfield">
541           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
542             <xslo:if test="position() &gt; 1">
543               <xslo:choose>
544                 <xslo:when test="contains('', @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='448']">
560     <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">
561       <xslo:variable name="raw_heading">
562         <xslo:for-each select="marc:subfield">
563           <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">
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='548']">
582     <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">
583       <xslo:variable name="raw_heading">
584         <xslo:for-each select="marc:subfield">
585           <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">
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   </xslo:template>
603   <xslo:template mode="index_heading" match="marc:datafield[@tag='150']">
604     <z:index name="Subject-topical-heading:w Subject-topical-heading:p Subject-topical-heading:s Heading:w Heading:p Heading:s">
605       <xslo:variable name="raw_heading">
606         <xslo:for-each select="marc:subfield">
607           <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">
608             <xslo:if test="position() &gt; 1">
609               <xslo:choose>
610                 <xslo:when test="contains('vxyz', @code)">
611                   <xslo:text>--</xslo:text>
612                 </xslo:when>
613                 <xslo:otherwise>
614                   <xslo:value-of select="substring(' ', 1, 1)"/>
615                 </xslo:otherwise>
616               </xslo:choose>
617             </xslo:if>
618             <xslo:value-of select="."/>
619           </xslo:if>
620         </xslo:for-each>
621       </xslo:variable>
622       <xslo:value-of select="normalize-space($raw_heading)"/>
623     </z:index>
624     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
625       <xslo:variable name="raw_heading">
626         <xslo:for-each select="marc:subfield">
627           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
628             <xslo:if test="position() &gt; 1">
629               <xslo:choose>
630                 <xslo:when test="contains('', @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='450']">
646     <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">
647       <xslo:variable name="raw_heading">
648         <xslo:for-each select="marc:subfield">
649           <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">
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='550']">
668     <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">
669       <xslo:variable name="raw_heading">
670         <xslo:for-each select="marc:subfield">
671           <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">
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   </xslo:template>
689   <xslo:template mode="index_heading" match="marc:datafield[@tag='151']">
690     <z:index name="Name-geographic-heading:w Name-geographic-heading:p Name-geographic-heading:s Heading:w Heading:p Heading:s">
691       <xslo:variable name="raw_heading">
692         <xslo:for-each select="marc:subfield">
693           <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">
694             <xslo:if test="position() &gt; 1">
695               <xslo:choose>
696                 <xslo:when test="contains('vxyz', @code)">
697                   <xslo:text>--</xslo:text>
698                 </xslo:when>
699                 <xslo:otherwise>
700                   <xslo:value-of select="substring(' ', 1, 1)"/>
701                 </xslo:otherwise>
702               </xslo:choose>
703             </xslo:if>
704             <xslo:value-of select="."/>
705           </xslo:if>
706         </xslo:for-each>
707       </xslo:variable>
708       <xslo:value-of select="normalize-space($raw_heading)"/>
709     </z:index>
710     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
711       <xslo:variable name="raw_heading">
712         <xslo:for-each select="marc:subfield">
713           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
714             <xslo:if test="position() &gt; 1">
715               <xslo:choose>
716                 <xslo:when test="contains('', @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='451']">
732     <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">
733       <xslo:variable name="raw_heading">
734         <xslo:for-each select="marc:subfield">
735           <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">
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='551']">
754     <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">
755       <xslo:variable name="raw_heading">
756         <xslo:for-each select="marc:subfield">
757           <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">
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   </xslo:template>
775   <xslo:template mode="index_heading" match="marc:datafield[@tag='155']">
776     <z:index name="Term-genre-form-heading:w Term-genre-form-heading:p Term-genre-form-heading:s Heading:w Heading:p Heading:s">
777       <xslo:variable name="raw_heading">
778         <xslo:for-each select="marc:subfield">
779           <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">
780             <xslo:if test="position() &gt; 1">
781               <xslo:choose>
782                 <xslo:when test="contains('vxyz', @code)">
783                   <xslo:text>--</xslo:text>
784                 </xslo:when>
785                 <xslo:otherwise>
786                   <xslo:value-of select="substring(' ', 1, 1)"/>
787                 </xslo:otherwise>
788               </xslo:choose>
789             </xslo:if>
790             <xslo:value-of select="."/>
791           </xslo:if>
792         </xslo:for-each>
793       </xslo:variable>
794       <xslo:value-of select="normalize-space($raw_heading)"/>
795     </z:index>
796     <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
797       <xslo:variable name="raw_heading">
798         <xslo:for-each select="marc:subfield">
799           <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
800             <xslo:if test="position() &gt; 1">
801               <xslo:choose>
802                 <xslo:when test="contains('', @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='455']">
818     <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">
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-from:w Term-genre-form-see-from:p Term-genre-form-see-from:s See-from:w See-from:p See-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='555']">
840     <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">
841       <xslo:variable name="raw_heading">
842         <xslo:for-each select="marc:subfield">
843           <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">
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='180']">
862     <z:index name="General-subdivision:w General-subdivision:p General-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
863       <xslo:variable name="raw_heading">
864         <xslo:for-each select="marc:subfield">
865           <xslo:if test="contains('vxyz', @code)" name="General-subdivision:w General-subdivision:p General-subdivision:s Subdivision:w Subdivision:p Subdivision: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='480']">
884     <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">
885       <xslo:variable name="raw_heading">
886         <xslo:for-each select="marc:subfield">
887           <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">
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='580']">
906     <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">
907       <xslo:variable name="raw_heading">
908         <xslo:for-each select="marc:subfield">
909           <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">
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='181']">
928     <z:index name="Geographic-subdivision:w Geographic-subdivision:p Geographic-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
929       <xslo:variable name="raw_heading">
930         <xslo:for-each select="marc:subfield">
931           <xslo:if test="contains('vxyz', @code)" name="Geographic-subdivision:w Geographic-subdivision:p Geographic-subdivision:s Subdivision:w Subdivision:p Subdivision: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='481']">
950     <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">
951       <xslo:variable name="raw_heading">
952         <xslo:for-each select="marc:subfield">
953           <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">
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='581']">
972     <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">
973       <xslo:variable name="raw_heading">
974         <xslo:for-each select="marc:subfield">
975           <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">
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='182']">
994     <z:index name="Chronological-subdivision:w Chronological-subdivision:p Chronological-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
995       <xslo:variable name="raw_heading">
996         <xslo:for-each select="marc:subfield">
997           <xslo:if test="contains('vxyz', @code)" name="Chronological-subdivision:w Chronological-subdivision:p Chronological-subdivision:s Subdivision:w Subdivision:p Subdivision: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='482']">
1016     <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">
1017       <xslo:variable name="raw_heading">
1018         <xslo:for-each select="marc:subfield">
1019           <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">
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='582']">
1038     <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">
1039       <xslo:variable name="raw_heading">
1040         <xslo:for-each select="marc:subfield">
1041           <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">
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='185']">
1060     <z:index name="Form-subdivision:w Form-subdivision:p Form-subdivision:s Subdivision:w Subdivision:p Subdivision:s">
1061       <xslo:variable name="raw_heading">
1062         <xslo:for-each select="marc:subfield">
1063           <xslo:if test="contains('vxyz', @code)" name="Form-subdivision:w Form-subdivision:p Form-subdivision:s Subdivision:w Subdivision:p Subdivision: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='485']">
1082     <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">
1083       <xslo:variable name="raw_heading">
1084         <xslo:for-each select="marc:subfield">
1085           <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">
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_heading" match="marc:datafield[@tag='585']">
1104     <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">
1105       <xslo:variable name="raw_heading">
1106         <xslo:for-each select="marc:subfield">
1107           <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">
1108             <xslo:if test="position() &gt; 1">
1109               <xslo:choose>
1110                 <xslo:when test="contains('vxyz', @code)">
1111                   <xslo:text>--</xslo:text>
1112                 </xslo:when>
1113                 <xslo:otherwise>
1114                   <xslo:value-of select="substring(' ', 1, 1)"/>
1115                 </xslo:otherwise>
1116               </xslo:choose>
1117             </xslo:if>
1118             <xslo:value-of select="."/>
1119           </xslo:if>
1120         </xslo:for-each>
1121       </xslo:variable>
1122       <xslo:value-of select="normalize-space($raw_heading)"/>
1123     </z:index>
1124   </xslo:template>
1125   <xslo:template mode="index_heading_conditional" match="marc:datafield[@tag='450']">
1126     <xslo:if test="substring(marc:subfield[@code='w']/text(), 2, 1)">
1127       <z:index name="Previous-heading-see-from:p">
1128         <xslo:variable name="raw_heading">
1129           <xslo:for-each select="marc:subfield">
1130             <xslo:if test="contains('abvxyz', @code)" name="Previous-heading-see-from:p">
1131               <xslo:if test="position() &gt; 1">
1132                 <xslo:choose>
1133                   <xslo:when test="contains('vxyz', @code)">
1134                     <xslo:text>--</xslo:text>
1135                   </xslo:when>
1136                   <xslo:otherwise>
1137                     <xslo:value-of select="substring(' ', 1, 1)"/>
1138                   </xslo:otherwise>
1139                 </xslo:choose>
1140               </xslo:if>
1141               <xslo:value-of select="."/>
1142             </xslo:if>
1143           </xslo:for-each>
1144         </xslo:variable>
1145         <xslo:value-of select="normalize-space($raw_heading)"/>
1146       </z:index>
1147     </xslo:if>
1148   </xslo:template>
1149   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='100']">
1150     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1151       <xslo:variable name="raw_heading">
1152         <xslo:for-each select="marc:subfield">
1153           <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1154             <xslo:if test="position() &gt; 1">
1155               <xslo:choose>
1156                 <xslo:when test="contains('vxyz', @code)">
1157                   <xslo:choose>
1158                     <xslo:when test="@code = $general_subdivision_subfield">
1159                       <xslo:text> generalsubdiv </xslo:text>
1160                     </xslo:when>
1161                     <xslo:when test="@code = $form_subdivision_subfield">
1162                       <xslo:text> formsubdiv </xslo:text>
1163                     </xslo:when>
1164                     <xslo:when test="@code = $chronological_subdivision_subfield">
1165                       <xslo:text> chronologicalsubdiv </xslo:text>
1166                     </xslo:when>
1167                     <xslo:when test="@code = $geographic_subdivision_subfield">
1168                       <xslo:text> geographicsubdiv </xslo:text>
1169                     </xslo:when>
1170                   </xslo:choose>
1171                 </xslo:when>
1172                 <xslo:otherwise>
1173                   <xslo:value-of select="substring(' ', 1, 1)"/>
1174                 </xslo:otherwise>
1175               </xslo:choose>
1176             </xslo:if>
1177             <xslo:call-template name="chopPunctuation">
1178               <xslo:with-param name="chopString">
1179                 <xslo:value-of select="."/>
1180               </xslo:with-param>
1181             </xslo:call-template>
1182           </xslo:if>
1183         </xslo:for-each>
1184       </xslo:variable>
1185       <xslo:value-of select="normalize-space($raw_heading)"/>
1186     </z:index>
1187   </xslo:template>
1188   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='400']">
1189     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1190       <xslo:variable name="raw_heading">
1191         <xslo:for-each select="marc:subfield">
1192           <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1193             <xslo:if test="position() &gt; 1">
1194               <xslo:choose>
1195                 <xslo:when test="contains('vxyz', @code)">
1196                   <xslo:choose>
1197                     <xslo:when test="@code = $general_subdivision_subfield">
1198                       <xslo:text> generalsubdiv </xslo:text>
1199                     </xslo:when>
1200                     <xslo:when test="@code = $form_subdivision_subfield">
1201                       <xslo:text> formsubdiv </xslo:text>
1202                     </xslo:when>
1203                     <xslo:when test="@code = $chronological_subdivision_subfield">
1204                       <xslo:text> chronologicalsubdiv </xslo:text>
1205                     </xslo:when>
1206                     <xslo:when test="@code = $geographic_subdivision_subfield">
1207                       <xslo:text> geographicsubdiv </xslo:text>
1208                     </xslo:when>
1209                   </xslo:choose>
1210                 </xslo:when>
1211                 <xslo:otherwise>
1212                   <xslo:value-of select="substring(' ', 1, 1)"/>
1213                 </xslo:otherwise>
1214               </xslo:choose>
1215             </xslo:if>
1216             <xslo:call-template name="chopPunctuation">
1217               <xslo:with-param name="chopString">
1218                 <xslo:value-of select="."/>
1219               </xslo:with-param>
1220             </xslo:call-template>
1221           </xslo:if>
1222         </xslo:for-each>
1223       </xslo:variable>
1224       <xslo:value-of select="normalize-space($raw_heading)"/>
1225     </z:index>
1226   </xslo:template>
1227   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='500']">
1228     <z:index name="Match:w Match:p">
1229       <xslo:variable name="raw_heading">
1230         <xslo:for-each select="marc:subfield">
1231           <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Match:w Match:p">
1232             <xslo:if test="position() &gt; 1">
1233               <xslo:choose>
1234                 <xslo:when test="contains('vxyz', @code)">
1235                   <xslo:choose>
1236                     <xslo:when test="@code = $general_subdivision_subfield">
1237                       <xslo:text> generalsubdiv </xslo:text>
1238                     </xslo:when>
1239                     <xslo:when test="@code = $form_subdivision_subfield">
1240                       <xslo:text> formsubdiv </xslo:text>
1241                     </xslo:when>
1242                     <xslo:when test="@code = $chronological_subdivision_subfield">
1243                       <xslo:text> chronologicalsubdiv </xslo:text>
1244                     </xslo:when>
1245                     <xslo:when test="@code = $geographic_subdivision_subfield">
1246                       <xslo:text> geographicsubdiv </xslo:text>
1247                     </xslo:when>
1248                   </xslo:choose>
1249                 </xslo:when>
1250                 <xslo:otherwise>
1251                   <xslo:value-of select="substring(' ', 1, 1)"/>
1252                 </xslo:otherwise>
1253               </xslo:choose>
1254             </xslo:if>
1255             <xslo:call-template name="chopPunctuation">
1256               <xslo:with-param name="chopString">
1257                 <xslo:value-of select="."/>
1258               </xslo:with-param>
1259             </xslo:call-template>
1260           </xslo:if>
1261         </xslo:for-each>
1262       </xslo:variable>
1263       <xslo:value-of select="normalize-space($raw_heading)"/>
1264     </z:index>
1265   </xslo:template>
1266   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='110']">
1267     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1268       <xslo:variable name="raw_heading">
1269         <xslo:for-each select="marc:subfield">
1270           <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1271             <xslo:if test="position() &gt; 1">
1272               <xslo:choose>
1273                 <xslo:when test="contains('vxyz', @code)">
1274                   <xslo:choose>
1275                     <xslo:when test="@code = $general_subdivision_subfield">
1276                       <xslo:text> generalsubdiv </xslo:text>
1277                     </xslo:when>
1278                     <xslo:when test="@code = $form_subdivision_subfield">
1279                       <xslo:text> formsubdiv </xslo:text>
1280                     </xslo:when>
1281                     <xslo:when test="@code = $chronological_subdivision_subfield">
1282                       <xslo:text> chronologicalsubdiv </xslo:text>
1283                     </xslo:when>
1284                     <xslo:when test="@code = $geographic_subdivision_subfield">
1285                       <xslo:text> geographicsubdiv </xslo:text>
1286                     </xslo:when>
1287                   </xslo:choose>
1288                 </xslo:when>
1289                 <xslo:otherwise>
1290                   <xslo:value-of select="substring(' ', 1, 1)"/>
1291                 </xslo:otherwise>
1292               </xslo:choose>
1293             </xslo:if>
1294             <xslo:call-template name="chopPunctuation">
1295               <xslo:with-param name="chopString">
1296                 <xslo:value-of select="."/>
1297               </xslo:with-param>
1298             </xslo:call-template>
1299           </xslo:if>
1300         </xslo:for-each>
1301       </xslo:variable>
1302       <xslo:value-of select="normalize-space($raw_heading)"/>
1303     </z:index>
1304   </xslo:template>
1305   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='410']">
1306     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1307       <xslo:variable name="raw_heading">
1308         <xslo:for-each select="marc:subfield">
1309           <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1310             <xslo:if test="position() &gt; 1">
1311               <xslo:choose>
1312                 <xslo:when test="contains('vxyz', @code)">
1313                   <xslo:choose>
1314                     <xslo:when test="@code = $general_subdivision_subfield">
1315                       <xslo:text> generalsubdiv </xslo:text>
1316                     </xslo:when>
1317                     <xslo:when test="@code = $form_subdivision_subfield">
1318                       <xslo:text> formsubdiv </xslo:text>
1319                     </xslo:when>
1320                     <xslo:when test="@code = $chronological_subdivision_subfield">
1321                       <xslo:text> chronologicalsubdiv </xslo:text>
1322                     </xslo:when>
1323                     <xslo:when test="@code = $geographic_subdivision_subfield">
1324                       <xslo:text> geographicsubdiv </xslo:text>
1325                     </xslo:when>
1326                   </xslo:choose>
1327                 </xslo:when>
1328                 <xslo:otherwise>
1329                   <xslo:value-of select="substring(' ', 1, 1)"/>
1330                 </xslo:otherwise>
1331               </xslo:choose>
1332             </xslo:if>
1333             <xslo:call-template name="chopPunctuation">
1334               <xslo:with-param name="chopString">
1335                 <xslo:value-of select="."/>
1336               </xslo:with-param>
1337             </xslo:call-template>
1338           </xslo:if>
1339         </xslo:for-each>
1340       </xslo:variable>
1341       <xslo:value-of select="normalize-space($raw_heading)"/>
1342     </z:index>
1343   </xslo:template>
1344   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='510']">
1345     <z:index name="Match:w Match:p">
1346       <xslo:variable name="raw_heading">
1347         <xslo:for-each select="marc:subfield">
1348           <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Match:w Match:p">
1349             <xslo:if test="position() &gt; 1">
1350               <xslo:choose>
1351                 <xslo:when test="contains('vxyz', @code)">
1352                   <xslo:choose>
1353                     <xslo:when test="@code = $general_subdivision_subfield">
1354                       <xslo:text> generalsubdiv </xslo:text>
1355                     </xslo:when>
1356                     <xslo:when test="@code = $form_subdivision_subfield">
1357                       <xslo:text> formsubdiv </xslo:text>
1358                     </xslo:when>
1359                     <xslo:when test="@code = $chronological_subdivision_subfield">
1360                       <xslo:text> chronologicalsubdiv </xslo:text>
1361                     </xslo:when>
1362                     <xslo:when test="@code = $geographic_subdivision_subfield">
1363                       <xslo:text> geographicsubdiv </xslo:text>
1364                     </xslo:when>
1365                   </xslo:choose>
1366                 </xslo:when>
1367                 <xslo:otherwise>
1368                   <xslo:value-of select="substring(' ', 1, 1)"/>
1369                 </xslo:otherwise>
1370               </xslo:choose>
1371             </xslo:if>
1372             <xslo:call-template name="chopPunctuation">
1373               <xslo:with-param name="chopString">
1374                 <xslo:value-of select="."/>
1375               </xslo:with-param>
1376             </xslo:call-template>
1377           </xslo:if>
1378         </xslo:for-each>
1379       </xslo:variable>
1380       <xslo:value-of select="normalize-space($raw_heading)"/>
1381     </z:index>
1382   </xslo:template>
1383   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='111']">
1384     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1385       <xslo:variable name="raw_heading">
1386         <xslo:for-each select="marc:subfield">
1387           <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1388             <xslo:if test="position() &gt; 1">
1389               <xslo:choose>
1390                 <xslo:when test="contains('vxyz', @code)">
1391                   <xslo:choose>
1392                     <xslo:when test="@code = $general_subdivision_subfield">
1393                       <xslo:text> generalsubdiv </xslo:text>
1394                     </xslo:when>
1395                     <xslo:when test="@code = $form_subdivision_subfield">
1396                       <xslo:text> formsubdiv </xslo:text>
1397                     </xslo:when>
1398                     <xslo:when test="@code = $chronological_subdivision_subfield">
1399                       <xslo:text> chronologicalsubdiv </xslo:text>
1400                     </xslo:when>
1401                     <xslo:when test="@code = $geographic_subdivision_subfield">
1402                       <xslo:text> geographicsubdiv </xslo:text>
1403                     </xslo:when>
1404                   </xslo:choose>
1405                 </xslo:when>
1406                 <xslo:otherwise>
1407                   <xslo:value-of select="substring(' ', 1, 1)"/>
1408                 </xslo:otherwise>
1409               </xslo:choose>
1410             </xslo:if>
1411             <xslo:call-template name="chopPunctuation">
1412               <xslo:with-param name="chopString">
1413                 <xslo:value-of select="."/>
1414               </xslo:with-param>
1415             </xslo:call-template>
1416           </xslo:if>
1417         </xslo:for-each>
1418       </xslo:variable>
1419       <xslo:value-of select="normalize-space($raw_heading)"/>
1420     </z:index>
1421   </xslo:template>
1422   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='411']">
1423     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1424       <xslo:variable name="raw_heading">
1425         <xslo:for-each select="marc:subfield">
1426           <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1427             <xslo:if test="position() &gt; 1">
1428               <xslo:choose>
1429                 <xslo:when test="contains('vxyz', @code)">
1430                   <xslo:choose>
1431                     <xslo:when test="@code = $general_subdivision_subfield">
1432                       <xslo:text> generalsubdiv </xslo:text>
1433                     </xslo:when>
1434                     <xslo:when test="@code = $form_subdivision_subfield">
1435                       <xslo:text> formsubdiv </xslo:text>
1436                     </xslo:when>
1437                     <xslo:when test="@code = $chronological_subdivision_subfield">
1438                       <xslo:text> chronologicalsubdiv </xslo:text>
1439                     </xslo:when>
1440                     <xslo:when test="@code = $geographic_subdivision_subfield">
1441                       <xslo:text> geographicsubdiv </xslo:text>
1442                     </xslo:when>
1443                   </xslo:choose>
1444                 </xslo:when>
1445                 <xslo:otherwise>
1446                   <xslo:value-of select="substring(' ', 1, 1)"/>
1447                 </xslo:otherwise>
1448               </xslo:choose>
1449             </xslo:if>
1450             <xslo:call-template name="chopPunctuation">
1451               <xslo:with-param name="chopString">
1452                 <xslo:value-of select="."/>
1453               </xslo:with-param>
1454             </xslo:call-template>
1455           </xslo:if>
1456         </xslo:for-each>
1457       </xslo:variable>
1458       <xslo:value-of select="normalize-space($raw_heading)"/>
1459     </z:index>
1460   </xslo:template>
1461   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='511']">
1462     <z:index name="Match:w Match:p">
1463       <xslo:variable name="raw_heading">
1464         <xslo:for-each select="marc:subfield">
1465           <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Match:w Match:p">
1466             <xslo:if test="position() &gt; 1">
1467               <xslo:choose>
1468                 <xslo:when test="contains('vxyz', @code)">
1469                   <xslo:choose>
1470                     <xslo:when test="@code = $general_subdivision_subfield">
1471                       <xslo:text> generalsubdiv </xslo:text>
1472                     </xslo:when>
1473                     <xslo:when test="@code = $form_subdivision_subfield">
1474                       <xslo:text> formsubdiv </xslo:text>
1475                     </xslo:when>
1476                     <xslo:when test="@code = $chronological_subdivision_subfield">
1477                       <xslo:text> chronologicalsubdiv </xslo:text>
1478                     </xslo:when>
1479                     <xslo:when test="@code = $geographic_subdivision_subfield">
1480                       <xslo:text> geographicsubdiv </xslo:text>
1481                     </xslo:when>
1482                   </xslo:choose>
1483                 </xslo:when>
1484                 <xslo:otherwise>
1485                   <xslo:value-of select="substring(' ', 1, 1)"/>
1486                 </xslo:otherwise>
1487               </xslo:choose>
1488             </xslo:if>
1489             <xslo:call-template name="chopPunctuation">
1490               <xslo:with-param name="chopString">
1491                 <xslo:value-of select="."/>
1492               </xslo:with-param>
1493             </xslo:call-template>
1494           </xslo:if>
1495         </xslo:for-each>
1496       </xslo:variable>
1497       <xslo:value-of select="normalize-space($raw_heading)"/>
1498     </z:index>
1499   </xslo:template>
1500   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='130']">
1501     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1502       <xslo:variable name="raw_heading">
1503         <xslo:for-each select="marc:subfield">
1504           <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1505             <xslo:if test="position() &gt; 1">
1506               <xslo:choose>
1507                 <xslo:when test="contains('vxyz', @code)">
1508                   <xslo:choose>
1509                     <xslo:when test="@code = $general_subdivision_subfield">
1510                       <xslo:text> generalsubdiv </xslo:text>
1511                     </xslo:when>
1512                     <xslo:when test="@code = $form_subdivision_subfield">
1513                       <xslo:text> formsubdiv </xslo:text>
1514                     </xslo:when>
1515                     <xslo:when test="@code = $chronological_subdivision_subfield">
1516                       <xslo:text> chronologicalsubdiv </xslo:text>
1517                     </xslo:when>
1518                     <xslo:when test="@code = $geographic_subdivision_subfield">
1519                       <xslo:text> geographicsubdiv </xslo:text>
1520                     </xslo:when>
1521                   </xslo:choose>
1522                 </xslo:when>
1523                 <xslo:otherwise>
1524                   <xslo:value-of select="substring(' ', 1, 1)"/>
1525                 </xslo:otherwise>
1526               </xslo:choose>
1527             </xslo:if>
1528             <xslo:call-template name="chopPunctuation">
1529               <xslo:with-param name="chopString">
1530                 <xslo:value-of select="."/>
1531               </xslo:with-param>
1532             </xslo:call-template>
1533           </xslo:if>
1534         </xslo:for-each>
1535       </xslo:variable>
1536       <xslo:value-of select="normalize-space($raw_heading)"/>
1537     </z:index>
1538   </xslo:template>
1539   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='430']">
1540     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1541       <xslo:variable name="raw_heading">
1542         <xslo:for-each select="marc:subfield">
1543           <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1544             <xslo:if test="position() &gt; 1">
1545               <xslo:choose>
1546                 <xslo:when test="contains('vxyz', @code)">
1547                   <xslo:choose>
1548                     <xslo:when test="@code = $general_subdivision_subfield">
1549                       <xslo:text> generalsubdiv </xslo:text>
1550                     </xslo:when>
1551                     <xslo:when test="@code = $form_subdivision_subfield">
1552                       <xslo:text> formsubdiv </xslo:text>
1553                     </xslo:when>
1554                     <xslo:when test="@code = $chronological_subdivision_subfield">
1555                       <xslo:text> chronologicalsubdiv </xslo:text>
1556                     </xslo:when>
1557                     <xslo:when test="@code = $geographic_subdivision_subfield">
1558                       <xslo:text> geographicsubdiv </xslo:text>
1559                     </xslo:when>
1560                   </xslo:choose>
1561                 </xslo:when>
1562                 <xslo:otherwise>
1563                   <xslo:value-of select="substring(' ', 1, 1)"/>
1564                 </xslo:otherwise>
1565               </xslo:choose>
1566             </xslo:if>
1567             <xslo:call-template name="chopPunctuation">
1568               <xslo:with-param name="chopString">
1569                 <xslo:value-of select="."/>
1570               </xslo:with-param>
1571             </xslo:call-template>
1572           </xslo:if>
1573         </xslo:for-each>
1574       </xslo:variable>
1575       <xslo:value-of select="normalize-space($raw_heading)"/>
1576     </z:index>
1577   </xslo:template>
1578   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='530']">
1579     <z:index name="Match:w Match:p">
1580       <xslo:variable name="raw_heading">
1581         <xslo:for-each select="marc:subfield">
1582           <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Match:w Match:p">
1583             <xslo:if test="position() &gt; 1">
1584               <xslo:choose>
1585                 <xslo:when test="contains('vxyz', @code)">
1586                   <xslo:choose>
1587                     <xslo:when test="@code = $general_subdivision_subfield">
1588                       <xslo:text> generalsubdiv </xslo:text>
1589                     </xslo:when>
1590                     <xslo:when test="@code = $form_subdivision_subfield">
1591                       <xslo:text> formsubdiv </xslo:text>
1592                     </xslo:when>
1593                     <xslo:when test="@code = $chronological_subdivision_subfield">
1594                       <xslo:text> chronologicalsubdiv </xslo:text>
1595                     </xslo:when>
1596                     <xslo:when test="@code = $geographic_subdivision_subfield">
1597                       <xslo:text> geographicsubdiv </xslo:text>
1598                     </xslo:when>
1599                   </xslo:choose>
1600                 </xslo:when>
1601                 <xslo:otherwise>
1602                   <xslo:value-of select="substring(' ', 1, 1)"/>
1603                 </xslo:otherwise>
1604               </xslo:choose>
1605             </xslo:if>
1606             <xslo:call-template name="chopPunctuation">
1607               <xslo:with-param name="chopString">
1608                 <xslo:value-of select="."/>
1609               </xslo:with-param>
1610             </xslo:call-template>
1611           </xslo:if>
1612         </xslo:for-each>
1613       </xslo:variable>
1614       <xslo:value-of select="normalize-space($raw_heading)"/>
1615     </z:index>
1616   </xslo:template>
1617   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='148']">
1618     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1619       <xslo:variable name="raw_heading">
1620         <xslo:for-each select="marc:subfield">
1621           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1622             <xslo:if test="position() &gt; 1">
1623               <xslo:choose>
1624                 <xslo:when test="contains('vxyz', @code)">
1625                   <xslo:choose>
1626                     <xslo:when test="@code = $general_subdivision_subfield">
1627                       <xslo:text> generalsubdiv </xslo:text>
1628                     </xslo:when>
1629                     <xslo:when test="@code = $form_subdivision_subfield">
1630                       <xslo:text> formsubdiv </xslo:text>
1631                     </xslo:when>
1632                     <xslo:when test="@code = $chronological_subdivision_subfield">
1633                       <xslo:text> chronologicalsubdiv </xslo:text>
1634                     </xslo:when>
1635                     <xslo:when test="@code = $geographic_subdivision_subfield">
1636                       <xslo:text> geographicsubdiv </xslo:text>
1637                     </xslo:when>
1638                   </xslo:choose>
1639                 </xslo:when>
1640                 <xslo:otherwise>
1641                   <xslo:value-of select="substring(' ', 1, 1)"/>
1642                 </xslo:otherwise>
1643               </xslo:choose>
1644             </xslo:if>
1645             <xslo:call-template name="chopPunctuation">
1646               <xslo:with-param name="chopString">
1647                 <xslo:value-of select="."/>
1648               </xslo:with-param>
1649             </xslo:call-template>
1650           </xslo:if>
1651         </xslo:for-each>
1652       </xslo:variable>
1653       <xslo:value-of select="normalize-space($raw_heading)"/>
1654     </z:index>
1655   </xslo:template>
1656   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='448']">
1657     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1658       <xslo:variable name="raw_heading">
1659         <xslo:for-each select="marc:subfield">
1660           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1661             <xslo:if test="position() &gt; 1">
1662               <xslo:choose>
1663                 <xslo:when test="contains('vxyz', @code)">
1664                   <xslo:choose>
1665                     <xslo:when test="@code = $general_subdivision_subfield">
1666                       <xslo:text> generalsubdiv </xslo:text>
1667                     </xslo:when>
1668                     <xslo:when test="@code = $form_subdivision_subfield">
1669                       <xslo:text> formsubdiv </xslo:text>
1670                     </xslo:when>
1671                     <xslo:when test="@code = $chronological_subdivision_subfield">
1672                       <xslo:text> chronologicalsubdiv </xslo:text>
1673                     </xslo:when>
1674                     <xslo:when test="@code = $geographic_subdivision_subfield">
1675                       <xslo:text> geographicsubdiv </xslo:text>
1676                     </xslo:when>
1677                   </xslo:choose>
1678                 </xslo:when>
1679                 <xslo:otherwise>
1680                   <xslo:value-of select="substring(' ', 1, 1)"/>
1681                 </xslo:otherwise>
1682               </xslo:choose>
1683             </xslo:if>
1684             <xslo:call-template name="chopPunctuation">
1685               <xslo:with-param name="chopString">
1686                 <xslo:value-of select="."/>
1687               </xslo:with-param>
1688             </xslo:call-template>
1689           </xslo:if>
1690         </xslo:for-each>
1691       </xslo:variable>
1692       <xslo:value-of select="normalize-space($raw_heading)"/>
1693     </z:index>
1694   </xslo:template>
1695   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='548']">
1696     <z:index name="Match:w Match:p">
1697       <xslo:variable name="raw_heading">
1698         <xslo:for-each select="marc:subfield">
1699           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p">
1700             <xslo:if test="position() &gt; 1">
1701               <xslo:choose>
1702                 <xslo:when test="contains('vxyz', @code)">
1703                   <xslo:choose>
1704                     <xslo:when test="@code = $general_subdivision_subfield">
1705                       <xslo:text> generalsubdiv </xslo:text>
1706                     </xslo:when>
1707                     <xslo:when test="@code = $form_subdivision_subfield">
1708                       <xslo:text> formsubdiv </xslo:text>
1709                     </xslo:when>
1710                     <xslo:when test="@code = $chronological_subdivision_subfield">
1711                       <xslo:text> chronologicalsubdiv </xslo:text>
1712                     </xslo:when>
1713                     <xslo:when test="@code = $geographic_subdivision_subfield">
1714                       <xslo:text> geographicsubdiv </xslo:text>
1715                     </xslo:when>
1716                   </xslo:choose>
1717                 </xslo:when>
1718                 <xslo:otherwise>
1719                   <xslo:value-of select="substring(' ', 1, 1)"/>
1720                 </xslo:otherwise>
1721               </xslo:choose>
1722             </xslo:if>
1723             <xslo:call-template name="chopPunctuation">
1724               <xslo:with-param name="chopString">
1725                 <xslo:value-of select="."/>
1726               </xslo:with-param>
1727             </xslo:call-template>
1728           </xslo:if>
1729         </xslo:for-each>
1730       </xslo:variable>
1731       <xslo:value-of select="normalize-space($raw_heading)"/>
1732     </z:index>
1733   </xslo:template>
1734   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='150']">
1735     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1736       <xslo:variable name="raw_heading">
1737         <xslo:for-each select="marc:subfield">
1738           <xslo:if test="contains('abvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1739             <xslo:if test="position() &gt; 1">
1740               <xslo:choose>
1741                 <xslo:when test="contains('vxyz', @code)">
1742                   <xslo:choose>
1743                     <xslo:when test="@code = $general_subdivision_subfield">
1744                       <xslo:text> generalsubdiv </xslo:text>
1745                     </xslo:when>
1746                     <xslo:when test="@code = $form_subdivision_subfield">
1747                       <xslo:text> formsubdiv </xslo:text>
1748                     </xslo:when>
1749                     <xslo:when test="@code = $chronological_subdivision_subfield">
1750                       <xslo:text> chronologicalsubdiv </xslo:text>
1751                     </xslo:when>
1752                     <xslo:when test="@code = $geographic_subdivision_subfield">
1753                       <xslo:text> geographicsubdiv </xslo:text>
1754                     </xslo:when>
1755                   </xslo:choose>
1756                 </xslo:when>
1757                 <xslo:otherwise>
1758                   <xslo:value-of select="substring(' ', 1, 1)"/>
1759                 </xslo:otherwise>
1760               </xslo:choose>
1761             </xslo:if>
1762             <xslo:call-template name="chopPunctuation">
1763               <xslo:with-param name="chopString">
1764                 <xslo:value-of select="."/>
1765               </xslo:with-param>
1766             </xslo:call-template>
1767           </xslo:if>
1768         </xslo:for-each>
1769       </xslo:variable>
1770       <xslo:value-of select="normalize-space($raw_heading)"/>
1771     </z:index>
1772   </xslo:template>
1773   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='450']">
1774     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1775       <xslo:variable name="raw_heading">
1776         <xslo:for-each select="marc:subfield">
1777           <xslo:if test="contains('abvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1778             <xslo:if test="position() &gt; 1">
1779               <xslo:choose>
1780                 <xslo:when test="contains('vxyz', @code)">
1781                   <xslo:choose>
1782                     <xslo:when test="@code = $general_subdivision_subfield">
1783                       <xslo:text> generalsubdiv </xslo:text>
1784                     </xslo:when>
1785                     <xslo:when test="@code = $form_subdivision_subfield">
1786                       <xslo:text> formsubdiv </xslo:text>
1787                     </xslo:when>
1788                     <xslo:when test="@code = $chronological_subdivision_subfield">
1789                       <xslo:text> chronologicalsubdiv </xslo:text>
1790                     </xslo:when>
1791                     <xslo:when test="@code = $geographic_subdivision_subfield">
1792                       <xslo:text> geographicsubdiv </xslo:text>
1793                     </xslo:when>
1794                   </xslo:choose>
1795                 </xslo:when>
1796                 <xslo:otherwise>
1797                   <xslo:value-of select="substring(' ', 1, 1)"/>
1798                 </xslo:otherwise>
1799               </xslo:choose>
1800             </xslo:if>
1801             <xslo:call-template name="chopPunctuation">
1802               <xslo:with-param name="chopString">
1803                 <xslo:value-of select="."/>
1804               </xslo:with-param>
1805             </xslo:call-template>
1806           </xslo:if>
1807         </xslo:for-each>
1808       </xslo:variable>
1809       <xslo:value-of select="normalize-space($raw_heading)"/>
1810     </z:index>
1811   </xslo:template>
1812   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='550']">
1813     <z:index name="Match:w Match:p">
1814       <xslo:variable name="raw_heading">
1815         <xslo:for-each select="marc:subfield">
1816           <xslo:if test="contains('abvxyz', @code)" name="Match:w Match:p">
1817             <xslo:if test="position() &gt; 1">
1818               <xslo:choose>
1819                 <xslo:when test="contains('vxyz', @code)">
1820                   <xslo:choose>
1821                     <xslo:when test="@code = $general_subdivision_subfield">
1822                       <xslo:text> generalsubdiv </xslo:text>
1823                     </xslo:when>
1824                     <xslo:when test="@code = $form_subdivision_subfield">
1825                       <xslo:text> formsubdiv </xslo:text>
1826                     </xslo:when>
1827                     <xslo:when test="@code = $chronological_subdivision_subfield">
1828                       <xslo:text> chronologicalsubdiv </xslo:text>
1829                     </xslo:when>
1830                     <xslo:when test="@code = $geographic_subdivision_subfield">
1831                       <xslo:text> geographicsubdiv </xslo:text>
1832                     </xslo:when>
1833                   </xslo:choose>
1834                 </xslo:when>
1835                 <xslo:otherwise>
1836                   <xslo:value-of select="substring(' ', 1, 1)"/>
1837                 </xslo:otherwise>
1838               </xslo:choose>
1839             </xslo:if>
1840             <xslo:call-template name="chopPunctuation">
1841               <xslo:with-param name="chopString">
1842                 <xslo:value-of select="."/>
1843               </xslo:with-param>
1844             </xslo:call-template>
1845           </xslo:if>
1846         </xslo:for-each>
1847       </xslo:variable>
1848       <xslo:value-of select="normalize-space($raw_heading)"/>
1849     </z:index>
1850   </xslo:template>
1851   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='151']">
1852     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1853       <xslo:variable name="raw_heading">
1854         <xslo:for-each select="marc:subfield">
1855           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1856             <xslo:if test="position() &gt; 1">
1857               <xslo:choose>
1858                 <xslo:when test="contains('vxyz', @code)">
1859                   <xslo:choose>
1860                     <xslo:when test="@code = $general_subdivision_subfield">
1861                       <xslo:text> generalsubdiv </xslo:text>
1862                     </xslo:when>
1863                     <xslo:when test="@code = $form_subdivision_subfield">
1864                       <xslo:text> formsubdiv </xslo:text>
1865                     </xslo:when>
1866                     <xslo:when test="@code = $chronological_subdivision_subfield">
1867                       <xslo:text> chronologicalsubdiv </xslo:text>
1868                     </xslo:when>
1869                     <xslo:when test="@code = $geographic_subdivision_subfield">
1870                       <xslo:text> geographicsubdiv </xslo:text>
1871                     </xslo:when>
1872                   </xslo:choose>
1873                 </xslo:when>
1874                 <xslo:otherwise>
1875                   <xslo:value-of select="substring(' ', 1, 1)"/>
1876                 </xslo:otherwise>
1877               </xslo:choose>
1878             </xslo:if>
1879             <xslo:call-template name="chopPunctuation">
1880               <xslo:with-param name="chopString">
1881                 <xslo:value-of select="."/>
1882               </xslo:with-param>
1883             </xslo:call-template>
1884           </xslo:if>
1885         </xslo:for-each>
1886       </xslo:variable>
1887       <xslo:value-of select="normalize-space($raw_heading)"/>
1888     </z:index>
1889   </xslo:template>
1890   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='451']">
1891     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1892       <xslo:variable name="raw_heading">
1893         <xslo:for-each select="marc:subfield">
1894           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
1895             <xslo:if test="position() &gt; 1">
1896               <xslo:choose>
1897                 <xslo:when test="contains('vxyz', @code)">
1898                   <xslo:choose>
1899                     <xslo:when test="@code = $general_subdivision_subfield">
1900                       <xslo:text> generalsubdiv </xslo:text>
1901                     </xslo:when>
1902                     <xslo:when test="@code = $form_subdivision_subfield">
1903                       <xslo:text> formsubdiv </xslo:text>
1904                     </xslo:when>
1905                     <xslo:when test="@code = $chronological_subdivision_subfield">
1906                       <xslo:text> chronologicalsubdiv </xslo:text>
1907                     </xslo:when>
1908                     <xslo:when test="@code = $geographic_subdivision_subfield">
1909                       <xslo:text> geographicsubdiv </xslo:text>
1910                     </xslo:when>
1911                   </xslo:choose>
1912                 </xslo:when>
1913                 <xslo:otherwise>
1914                   <xslo:value-of select="substring(' ', 1, 1)"/>
1915                 </xslo:otherwise>
1916               </xslo:choose>
1917             </xslo:if>
1918             <xslo:call-template name="chopPunctuation">
1919               <xslo:with-param name="chopString">
1920                 <xslo:value-of select="."/>
1921               </xslo:with-param>
1922             </xslo:call-template>
1923           </xslo:if>
1924         </xslo:for-each>
1925       </xslo:variable>
1926       <xslo:value-of select="normalize-space($raw_heading)"/>
1927     </z:index>
1928   </xslo:template>
1929   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='551']">
1930     <z:index name="Match:w Match:p">
1931       <xslo:variable name="raw_heading">
1932         <xslo:for-each select="marc:subfield">
1933           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p">
1934             <xslo:if test="position() &gt; 1">
1935               <xslo:choose>
1936                 <xslo:when test="contains('vxyz', @code)">
1937                   <xslo:choose>
1938                     <xslo:when test="@code = $general_subdivision_subfield">
1939                       <xslo:text> generalsubdiv </xslo:text>
1940                     </xslo:when>
1941                     <xslo:when test="@code = $form_subdivision_subfield">
1942                       <xslo:text> formsubdiv </xslo:text>
1943                     </xslo:when>
1944                     <xslo:when test="@code = $chronological_subdivision_subfield">
1945                       <xslo:text> chronologicalsubdiv </xslo:text>
1946                     </xslo:when>
1947                     <xslo:when test="@code = $geographic_subdivision_subfield">
1948                       <xslo:text> geographicsubdiv </xslo:text>
1949                     </xslo:when>
1950                   </xslo:choose>
1951                 </xslo:when>
1952                 <xslo:otherwise>
1953                   <xslo:value-of select="substring(' ', 1, 1)"/>
1954                 </xslo:otherwise>
1955               </xslo:choose>
1956             </xslo:if>
1957             <xslo:call-template name="chopPunctuation">
1958               <xslo:with-param name="chopString">
1959                 <xslo:value-of select="."/>
1960               </xslo:with-param>
1961             </xslo:call-template>
1962           </xslo:if>
1963         </xslo:for-each>
1964       </xslo:variable>
1965       <xslo:value-of select="normalize-space($raw_heading)"/>
1966     </z:index>
1967   </xslo:template>
1968   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='155']">
1969     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
1970       <xslo:variable name="raw_heading">
1971         <xslo:for-each select="marc:subfield">
1972           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
1973             <xslo:if test="position() &gt; 1">
1974               <xslo:choose>
1975                 <xslo:when test="contains('vxyz', @code)">
1976                   <xslo:choose>
1977                     <xslo:when test="@code = $general_subdivision_subfield">
1978                       <xslo:text> generalsubdiv </xslo:text>
1979                     </xslo:when>
1980                     <xslo:when test="@code = $form_subdivision_subfield">
1981                       <xslo:text> formsubdiv </xslo:text>
1982                     </xslo:when>
1983                     <xslo:when test="@code = $chronological_subdivision_subfield">
1984                       <xslo:text> chronologicalsubdiv </xslo:text>
1985                     </xslo:when>
1986                     <xslo:when test="@code = $geographic_subdivision_subfield">
1987                       <xslo:text> geographicsubdiv </xslo:text>
1988                     </xslo:when>
1989                   </xslo:choose>
1990                 </xslo:when>
1991                 <xslo:otherwise>
1992                   <xslo:value-of select="substring(' ', 1, 1)"/>
1993                 </xslo:otherwise>
1994               </xslo:choose>
1995             </xslo:if>
1996             <xslo:call-template name="chopPunctuation">
1997               <xslo:with-param name="chopString">
1998                 <xslo:value-of select="."/>
1999               </xslo:with-param>
2000             </xslo:call-template>
2001           </xslo:if>
2002         </xslo:for-each>
2003       </xslo:variable>
2004       <xslo:value-of select="normalize-space($raw_heading)"/>
2005     </z:index>
2006   </xslo:template>
2007   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='455']">
2008     <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
2009       <xslo:variable name="raw_heading">
2010         <xslo:for-each select="marc:subfield">
2011           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
2012             <xslo:if test="position() &gt; 1">
2013               <xslo:choose>
2014                 <xslo:when test="contains('vxyz', @code)">
2015                   <xslo:choose>
2016                     <xslo:when test="@code = $general_subdivision_subfield">
2017                       <xslo:text> generalsubdiv </xslo:text>
2018                     </xslo:when>
2019                     <xslo:when test="@code = $form_subdivision_subfield">
2020                       <xslo:text> formsubdiv </xslo:text>
2021                     </xslo:when>
2022                     <xslo:when test="@code = $chronological_subdivision_subfield">
2023                       <xslo:text> chronologicalsubdiv </xslo:text>
2024                     </xslo:when>
2025                     <xslo:when test="@code = $geographic_subdivision_subfield">
2026                       <xslo:text> geographicsubdiv </xslo:text>
2027                     </xslo:when>
2028                   </xslo:choose>
2029                 </xslo:when>
2030                 <xslo:otherwise>
2031                   <xslo:value-of select="substring(' ', 1, 1)"/>
2032                 </xslo:otherwise>
2033               </xslo:choose>
2034             </xslo:if>
2035             <xslo:call-template name="chopPunctuation">
2036               <xslo:with-param name="chopString">
2037                 <xslo:value-of select="."/>
2038               </xslo:with-param>
2039             </xslo:call-template>
2040           </xslo:if>
2041         </xslo:for-each>
2042       </xslo:variable>
2043       <xslo:value-of select="normalize-space($raw_heading)"/>
2044     </z:index>
2045   </xslo:template>
2046   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='555']">
2047     <z:index name="Match:w Match:p">
2048       <xslo:variable name="raw_heading">
2049         <xslo:for-each select="marc:subfield">
2050           <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p">
2051             <xslo:if test="position() &gt; 1">
2052               <xslo:choose>
2053                 <xslo:when test="contains('vxyz', @code)">
2054                   <xslo:choose>
2055                     <xslo:when test="@code = $general_subdivision_subfield">
2056                       <xslo:text> generalsubdiv </xslo:text>
2057                     </xslo:when>
2058                     <xslo:when test="@code = $form_subdivision_subfield">
2059                       <xslo:text> formsubdiv </xslo:text>
2060                     </xslo:when>
2061                     <xslo:when test="@code = $chronological_subdivision_subfield">
2062                       <xslo:text> chronologicalsubdiv </xslo:text>
2063                     </xslo:when>
2064                     <xslo:when test="@code = $geographic_subdivision_subfield">
2065                       <xslo:text> geographicsubdiv </xslo:text>
2066                     </xslo:when>
2067                   </xslo:choose>
2068                 </xslo:when>
2069                 <xslo:otherwise>
2070                   <xslo:value-of select="substring(' ', 1, 1)"/>
2071                 </xslo:otherwise>
2072               </xslo:choose>
2073             </xslo:if>
2074             <xslo:call-template name="chopPunctuation">
2075               <xslo:with-param name="chopString">
2076                 <xslo:value-of select="."/>
2077               </xslo:with-param>
2078             </xslo:call-template>
2079           </xslo:if>
2080         </xslo:for-each>
2081       </xslo:variable>
2082       <xslo:value-of select="normalize-space($raw_heading)"/>
2083     </z:index>
2084   </xslo:template>
2085   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='180']">
2086     <z:index name="Match-subdivision:p Match-subdivision:s">
2087       <xslo:variable name="raw_heading">
2088         <xslo:for-each select="marc:subfield">
2089           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision:p Match-subdivision:s">
2090             <xslo:if test="position() &gt; 1">
2091               <xslo:choose>
2092                 <xslo:when test="contains('vxyz', @code)">
2093                   <xslo:choose>
2094                     <xslo:when test="@code = $general_subdivision_subfield">
2095                       <xslo:text> generalsubdiv </xslo:text>
2096                     </xslo:when>
2097                     <xslo:when test="@code = $form_subdivision_subfield">
2098                       <xslo:text> formsubdiv </xslo:text>
2099                     </xslo:when>
2100                     <xslo:when test="@code = $chronological_subdivision_subfield">
2101                       <xslo:text> chronologicalsubdiv </xslo:text>
2102                     </xslo:when>
2103                     <xslo:when test="@code = $geographic_subdivision_subfield">
2104                       <xslo:text> geographicsubdiv </xslo:text>
2105                     </xslo:when>
2106                   </xslo:choose>
2107                 </xslo:when>
2108                 <xslo:otherwise>
2109                   <xslo:value-of select="substring(' ', 1, 1)"/>
2110                 </xslo:otherwise>
2111               </xslo:choose>
2112             </xslo:if>
2113             <xslo:call-template name="chopPunctuation">
2114               <xslo:with-param name="chopString">
2115                 <xslo:value-of select="."/>
2116               </xslo:with-param>
2117             </xslo:call-template>
2118           </xslo:if>
2119         </xslo:for-each>
2120       </xslo:variable>
2121       <xslo:value-of select="normalize-space($raw_heading)"/>
2122     </z:index>
2123   </xslo:template>
2124   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='480']">
2125     <z:index name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2126       <xslo:variable name="raw_heading">
2127         <xslo:for-each select="marc:subfield">
2128           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2129             <xslo:if test="position() &gt; 1">
2130               <xslo:choose>
2131                 <xslo:when test="contains('vxyz', @code)">
2132                   <xslo:choose>
2133                     <xslo:when test="@code = $general_subdivision_subfield">
2134                       <xslo:text> generalsubdiv </xslo:text>
2135                     </xslo:when>
2136                     <xslo:when test="@code = $form_subdivision_subfield">
2137                       <xslo:text> formsubdiv </xslo:text>
2138                     </xslo:when>
2139                     <xslo:when test="@code = $chronological_subdivision_subfield">
2140                       <xslo:text> chronologicalsubdiv </xslo:text>
2141                     </xslo:when>
2142                     <xslo:when test="@code = $geographic_subdivision_subfield">
2143                       <xslo:text> geographicsubdiv </xslo:text>
2144                     </xslo:when>
2145                   </xslo:choose>
2146                 </xslo:when>
2147                 <xslo:otherwise>
2148                   <xslo:value-of select="substring(' ', 1, 1)"/>
2149                 </xslo:otherwise>
2150               </xslo:choose>
2151             </xslo:if>
2152             <xslo:call-template name="chopPunctuation">
2153               <xslo:with-param name="chopString">
2154                 <xslo:value-of select="."/>
2155               </xslo:with-param>
2156             </xslo:call-template>
2157           </xslo:if>
2158         </xslo:for-each>
2159       </xslo:variable>
2160       <xslo:value-of select="normalize-space($raw_heading)"/>
2161     </z:index>
2162   </xslo:template>
2163   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='181']">
2164     <z:index name="Match-subdivision:p Match-subdivision:s">
2165       <xslo:variable name="raw_heading">
2166         <xslo:for-each select="marc:subfield">
2167           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision:p Match-subdivision:s">
2168             <xslo:if test="position() &gt; 1">
2169               <xslo:choose>
2170                 <xslo:when test="contains('vxyz', @code)">
2171                   <xslo:choose>
2172                     <xslo:when test="@code = $general_subdivision_subfield">
2173                       <xslo:text> generalsubdiv </xslo:text>
2174                     </xslo:when>
2175                     <xslo:when test="@code = $form_subdivision_subfield">
2176                       <xslo:text> formsubdiv </xslo:text>
2177                     </xslo:when>
2178                     <xslo:when test="@code = $chronological_subdivision_subfield">
2179                       <xslo:text> chronologicalsubdiv </xslo:text>
2180                     </xslo:when>
2181                     <xslo:when test="@code = $geographic_subdivision_subfield">
2182                       <xslo:text> geographicsubdiv </xslo:text>
2183                     </xslo:when>
2184                   </xslo:choose>
2185                 </xslo:when>
2186                 <xslo:otherwise>
2187                   <xslo:value-of select="substring(' ', 1, 1)"/>
2188                 </xslo:otherwise>
2189               </xslo:choose>
2190             </xslo:if>
2191             <xslo:call-template name="chopPunctuation">
2192               <xslo:with-param name="chopString">
2193                 <xslo:value-of select="."/>
2194               </xslo:with-param>
2195             </xslo:call-template>
2196           </xslo:if>
2197         </xslo:for-each>
2198       </xslo:variable>
2199       <xslo:value-of select="normalize-space($raw_heading)"/>
2200     </z:index>
2201   </xslo:template>
2202   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='481']">
2203     <z:index name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2204       <xslo:variable name="raw_heading">
2205         <xslo:for-each select="marc:subfield">
2206           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2207             <xslo:if test="position() &gt; 1">
2208               <xslo:choose>
2209                 <xslo:when test="contains('vxyz', @code)">
2210                   <xslo:choose>
2211                     <xslo:when test="@code = $general_subdivision_subfield">
2212                       <xslo:text> generalsubdiv </xslo:text>
2213                     </xslo:when>
2214                     <xslo:when test="@code = $form_subdivision_subfield">
2215                       <xslo:text> formsubdiv </xslo:text>
2216                     </xslo:when>
2217                     <xslo:when test="@code = $chronological_subdivision_subfield">
2218                       <xslo:text> chronologicalsubdiv </xslo:text>
2219                     </xslo:when>
2220                     <xslo:when test="@code = $geographic_subdivision_subfield">
2221                       <xslo:text> geographicsubdiv </xslo:text>
2222                     </xslo:when>
2223                   </xslo:choose>
2224                 </xslo:when>
2225                 <xslo:otherwise>
2226                   <xslo:value-of select="substring(' ', 1, 1)"/>
2227                 </xslo:otherwise>
2228               </xslo:choose>
2229             </xslo:if>
2230             <xslo:call-template name="chopPunctuation">
2231               <xslo:with-param name="chopString">
2232                 <xslo:value-of select="."/>
2233               </xslo:with-param>
2234             </xslo:call-template>
2235           </xslo:if>
2236         </xslo:for-each>
2237       </xslo:variable>
2238       <xslo:value-of select="normalize-space($raw_heading)"/>
2239     </z:index>
2240   </xslo:template>
2241   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='182']">
2242     <z:index name="Match-subdivision:p Match-subdivision:s">
2243       <xslo:variable name="raw_heading">
2244         <xslo:for-each select="marc:subfield">
2245           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision:p Match-subdivision:s">
2246             <xslo:if test="position() &gt; 1">
2247               <xslo:choose>
2248                 <xslo:when test="contains('vxyz', @code)">
2249                   <xslo:choose>
2250                     <xslo:when test="@code = $general_subdivision_subfield">
2251                       <xslo:text> generalsubdiv </xslo:text>
2252                     </xslo:when>
2253                     <xslo:when test="@code = $form_subdivision_subfield">
2254                       <xslo:text> formsubdiv </xslo:text>
2255                     </xslo:when>
2256                     <xslo:when test="@code = $chronological_subdivision_subfield">
2257                       <xslo:text> chronologicalsubdiv </xslo:text>
2258                     </xslo:when>
2259                     <xslo:when test="@code = $geographic_subdivision_subfield">
2260                       <xslo:text> geographicsubdiv </xslo:text>
2261                     </xslo:when>
2262                   </xslo:choose>
2263                 </xslo:when>
2264                 <xslo:otherwise>
2265                   <xslo:value-of select="substring(' ', 1, 1)"/>
2266                 </xslo:otherwise>
2267               </xslo:choose>
2268             </xslo:if>
2269             <xslo:call-template name="chopPunctuation">
2270               <xslo:with-param name="chopString">
2271                 <xslo:value-of select="."/>
2272               </xslo:with-param>
2273             </xslo:call-template>
2274           </xslo:if>
2275         </xslo:for-each>
2276       </xslo:variable>
2277       <xslo:value-of select="normalize-space($raw_heading)"/>
2278     </z:index>
2279   </xslo:template>
2280   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='482']">
2281     <z:index name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2282       <xslo:variable name="raw_heading">
2283         <xslo:for-each select="marc:subfield">
2284           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2285             <xslo:if test="position() &gt; 1">
2286               <xslo:choose>
2287                 <xslo:when test="contains('vxyz', @code)">
2288                   <xslo:choose>
2289                     <xslo:when test="@code = $general_subdivision_subfield">
2290                       <xslo:text> generalsubdiv </xslo:text>
2291                     </xslo:when>
2292                     <xslo:when test="@code = $form_subdivision_subfield">
2293                       <xslo:text> formsubdiv </xslo:text>
2294                     </xslo:when>
2295                     <xslo:when test="@code = $chronological_subdivision_subfield">
2296                       <xslo:text> chronologicalsubdiv </xslo:text>
2297                     </xslo:when>
2298                     <xslo:when test="@code = $geographic_subdivision_subfield">
2299                       <xslo:text> geographicsubdiv </xslo:text>
2300                     </xslo:when>
2301                   </xslo:choose>
2302                 </xslo:when>
2303                 <xslo:otherwise>
2304                   <xslo:value-of select="substring(' ', 1, 1)"/>
2305                 </xslo:otherwise>
2306               </xslo:choose>
2307             </xslo:if>
2308             <xslo:call-template name="chopPunctuation">
2309               <xslo:with-param name="chopString">
2310                 <xslo:value-of select="."/>
2311               </xslo:with-param>
2312             </xslo:call-template>
2313           </xslo:if>
2314         </xslo:for-each>
2315       </xslo:variable>
2316       <xslo:value-of select="normalize-space($raw_heading)"/>
2317     </z:index>
2318   </xslo:template>
2319   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='485']">
2320     <z:index name="Match-subdivision:p Match-subdivision:s">
2321       <xslo:variable name="raw_heading">
2322         <xslo:for-each select="marc:subfield">
2323           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision:p Match-subdivision:s">
2324             <xslo:if test="position() &gt; 1">
2325               <xslo:choose>
2326                 <xslo:when test="contains('vxyz', @code)">
2327                   <xslo:choose>
2328                     <xslo:when test="@code = $general_subdivision_subfield">
2329                       <xslo:text> generalsubdiv </xslo:text>
2330                     </xslo:when>
2331                     <xslo:when test="@code = $form_subdivision_subfield">
2332                       <xslo:text> formsubdiv </xslo:text>
2333                     </xslo:when>
2334                     <xslo:when test="@code = $chronological_subdivision_subfield">
2335                       <xslo:text> chronologicalsubdiv </xslo:text>
2336                     </xslo:when>
2337                     <xslo:when test="@code = $geographic_subdivision_subfield">
2338                       <xslo:text> geographicsubdiv </xslo:text>
2339                     </xslo:when>
2340                   </xslo:choose>
2341                 </xslo:when>
2342                 <xslo:otherwise>
2343                   <xslo:value-of select="substring(' ', 1, 1)"/>
2344                 </xslo:otherwise>
2345               </xslo:choose>
2346             </xslo:if>
2347             <xslo:call-template name="chopPunctuation">
2348               <xslo:with-param name="chopString">
2349                 <xslo:value-of select="."/>
2350               </xslo:with-param>
2351             </xslo:call-template>
2352           </xslo:if>
2353         </xslo:for-each>
2354       </xslo:variable>
2355       <xslo:value-of select="normalize-space($raw_heading)"/>
2356     </z:index>
2357   </xslo:template>
2358   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='185']">
2359     <z:index name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2360       <xslo:variable name="raw_heading">
2361         <xslo:for-each select="marc:subfield">
2362           <xslo:if test="contains('vxyz', @code)" name="Match-subdivision-see-from:p Match-subdivision-see-from:s">
2363             <xslo:if test="position() &gt; 1">
2364               <xslo:choose>
2365                 <xslo:when test="contains('vxyz', @code)">
2366                   <xslo:choose>
2367                     <xslo:when test="@code = $general_subdivision_subfield">
2368                       <xslo:text> generalsubdiv </xslo:text>
2369                     </xslo:when>
2370                     <xslo:when test="@code = $form_subdivision_subfield">
2371                       <xslo:text> formsubdiv </xslo:text>
2372                     </xslo:when>
2373                     <xslo:when test="@code = $chronological_subdivision_subfield">
2374                       <xslo:text> chronologicalsubdiv </xslo:text>
2375                     </xslo:when>
2376                     <xslo:when test="@code = $geographic_subdivision_subfield">
2377                       <xslo:text> geographicsubdiv </xslo:text>
2378                     </xslo:when>
2379                   </xslo:choose>
2380                 </xslo:when>
2381                 <xslo:otherwise>
2382                   <xslo:value-of select="substring(' ', 1, 1)"/>
2383                 </xslo:otherwise>
2384               </xslo:choose>
2385             </xslo:if>
2386             <xslo:call-template name="chopPunctuation">
2387               <xslo:with-param name="chopString">
2388                 <xslo:value-of select="."/>
2389               </xslo:with-param>
2390             </xslo:call-template>
2391           </xslo:if>
2392         </xslo:for-each>
2393       </xslo:variable>
2394       <xslo:value-of select="normalize-space($raw_heading)"/>
2395     </z:index>
2396   </xslo:template>
2397   <xslo:variable name="form_subdivision_subfield">v</xslo:variable>
2398   <xslo:variable name="general_subdivision_subfield">x</xslo:variable>
2399   <xslo:variable name="chronological_subdivision_subfield">y</xslo:variable>
2400   <xslo:variable name="geographic_subdivision_subfield">z</xslo:variable>
2401   <xslo:template mode="index_subject_thesaurus" match="marc:controlfield[@tag='008']">
2402     <xslo:variable name="thesaurus_code1" select="substring(., 12, 1)"/>
2403     <xslo:variable name="full_thesaurus_code">
2404       <xslo:choose>
2405         <xslo:when test="$thesaurus_code1 = 'a'">
2406           <xslo:text>lcsh</xslo:text>
2407         </xslo:when>
2408         <xslo:when test="$thesaurus_code1 = 'b'">
2409           <xslo:text>lcac</xslo:text>
2410         </xslo:when>
2411         <xslo:when test="$thesaurus_code1 = 'c'">
2412           <xslo:text>mesh</xslo:text>
2413         </xslo:when>
2414         <xslo:when test="$thesaurus_code1 = 'd'">
2415           <xslo:text>nal</xslo:text>
2416         </xslo:when>
2417         <xslo:when test="$thesaurus_code1 = 'k'">
2418           <xslo:text>cash</xslo:text>
2419         </xslo:when>
2420         <xslo:when test="$thesaurus_code1 = 'n'">
2421           <xslo:text>notapplicable</xslo:text>
2422         </xslo:when>
2423         <xslo:when test="$thesaurus_code1 = 'r'">
2424           <xslo:text>aat</xslo:text>
2425         </xslo:when>
2426         <xslo:when test="$thesaurus_code1 = 's'">
2427           <xslo:text>sears</xslo:text>
2428         </xslo:when>
2429         <xslo:when test="$thesaurus_code1 = 'v'">
2430           <xslo:text>rvm</xslo:text>
2431         </xslo:when>
2432         <xslo:when test="$thesaurus_code1 = 'z'">
2433           <xslo:choose>
2434             <xslo:when test="//marc:datafield[@tag='040']/marc:subfield[@code='f']">
2435               <xslo:value-of select="//marc:datafield[@tag='040']/marc:subfield[@code='f']"/>
2436             </xslo:when>
2437             <xslo:otherwise>
2438               <xslo:text>notdefined</xslo:text>
2439             </xslo:otherwise>
2440           </xslo:choose>
2441         </xslo:when>
2442         <xslo:otherwise>
2443           <xslo:text>notdefined</xslo:text>
2444         </xslo:otherwise>
2445       </xslo:choose>
2446     </xslo:variable>
2447     <z:index name="Subject-heading-thesaurus:w">
2448       <xslo:value-of select="$full_thesaurus_code"/>
2449     </z:index>
2450   </xslo:template>
2451   <xslo:template match="*">
2452     <z:index name="Any:w Any:p">
2453       <xslo:value-of select="."/>
2454     </z:index>
2455   </xslo:template>
2456   <xslo:template name="chopPunctuation">
2457     <xslo:param name="chopString"/>
2458     <xslo:variable name="length" select="string-length($chopString)"/>
2459     <xslo:choose>
2460       <xslo:when test="$length=0"/>
2461       <xslo:when test="contains('-,.:=;!%/', substring($chopString,$length,1))">
2462         <xslo:call-template name="chopPunctuation">
2463           <xslo:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
2464         </xslo:call-template>
2465       </xslo:when>
2466       <xslo:when test="not($chopString)"/>
2467       <xslo:otherwise>
2468         <xslo:value-of select="$chopString"/>
2469       </xslo:otherwise>
2470     </xslo:choose>
2471     <xslo:text/>
2472   </xslo:template>
2473 </xslo:stylesheet>