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