Bug 7617: Sort authority results by authid
[koha_gimpoz] / etc / zebradb / marc_defs / marc21 / authorities / authority-zebra-indexdefs.xsl
index c05b711..aa02e70 100644 (file)
@@ -1,4 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+This file has been automatically generated from a Koha index definition file
+with the stylesheet koha-indexdefs-to-zebra.xsl. Do not manually edit this file,
+as it may be overwritten. To regenerate, edit the appropriate Koha index
+definition file (probably something like authority-koha-indexdefs.xml) and run:
+`xsltproc koha-indexdefs-to-zebra.xsl authority-koha-indexdefs.xml >
+authority-zebra-indexdefs.xsl` (substituting the appropriate file names).
+-->
 <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">
   <xslo:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
   <xslo:template match="text()"/>
@@ -38,7 +46,7 @@
     </z:index>
   </xslo:template>
   <xslo:template match="marc:controlfield[@tag='001']">
-    <z:index name="Local-Number:w">
+    <z:index name="Local-Number:w Local-Number:s">
       <xslo:value-of select="."/>
     </z:index>
   </xslo:template>
       </xslo:variable>
       <xslo:value-of select="normalize-space($raw_heading)"/>
     </z:index>
+    <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('', @code)">
+                  <xslo:text>--</xslo:text>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:value-of select="."/>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
   </xslo:template>
   <xslo:template mode="index_heading" match="marc:datafield[@tag='400']">
     <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">
       </xslo:variable>
       <xslo:value-of select="normalize-space($raw_heading)"/>
     </z:index>
+    <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('', @code)">
+                  <xslo:text>--</xslo:text>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:value-of select="."/>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
   </xslo:template>
   <xslo:template mode="index_heading" match="marc:datafield[@tag='410']">
     <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">
       </xslo:variable>
       <xslo:value-of select="normalize-space($raw_heading)"/>
     </z:index>
+    <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('', @code)">
+                  <xslo:text>--</xslo:text>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:value-of select="."/>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
   </xslo:template>
   <xslo:template mode="index_heading" match="marc:datafield[@tag='411']">
     <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">
       </xslo:variable>
       <xslo:value-of select="normalize-space($raw_heading)"/>
     </z:index>
+    <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('', @code)">
+                  <xslo:text>--</xslo:text>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:value-of select="."/>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
   </xslo:template>
   <xslo:template mode="index_heading" match="marc:datafield[@tag='430']">
     <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">
       </xslo:variable>
       <xslo:value-of select="normalize-space($raw_heading)"/>
     </z:index>
+    <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('', @code)">
+                  <xslo:text>--</xslo:text>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:value-of select="."/>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
   </xslo:template>
   <xslo:template mode="index_heading" match="marc:datafield[@tag='448']">
     <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">
       </xslo:variable>
       <xslo:value-of select="normalize-space($raw_heading)"/>
     </z:index>
+    <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('', @code)">
+                  <xslo:text>--</xslo:text>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:value-of select="."/>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
   </xslo:template>
   <xslo:template mode="index_heading" match="marc:datafield[@tag='450']">
     <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">
       </xslo:variable>
       <xslo:value-of select="normalize-space($raw_heading)"/>
     </z:index>
+    <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('', @code)">
+                  <xslo:text>--</xslo:text>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:value-of select="."/>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
   </xslo:template>
   <xslo:template mode="index_heading" match="marc:datafield[@tag='451']">
     <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">
       </xslo:variable>
       <xslo:value-of select="normalize-space($raw_heading)"/>
     </z:index>
+    <z:index name="Heading-Main:w Heading-Main:p Heading-Main:s">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('a', @code)" name="Heading-Main:w Heading-Main:p Heading-Main:s">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('', @code)">
+                  <xslo:text>--</xslo:text>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:value-of select="."/>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
   </xslo:template>
   <xslo:template mode="index_heading" match="marc:datafield[@tag='455']">
     <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">
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='100']">
-    <z:index name="Match-heading:p Match-heading:s">
+    <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Match-heading:p Match-heading:s">
+          <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='400']">
-    <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
+    <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
+          <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
+  </xslo:template>
+  <xslo:template mode="index_match_heading" match="marc:datafield[@tag='500']">
+    <z:index name="Match:w Match:p">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)" name="Match:w Match:p">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('vxyz', @code)">
+                  <xslo:choose>
+                    <xslo:when test="@code = $general_subdivision_subfield">
+                      <xslo:text> generalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $form_subdivision_subfield">
+                      <xslo:text> formsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $chronological_subdivision_subfield">
+                      <xslo:text> chronologicalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $geographic_subdivision_subfield">
+                      <xslo:text> geographicsubdiv </xslo:text>
+                    </xslo:when>
+                  </xslo:choose>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='110']">
-    <z:index name="Match-heading:p Match-heading:s">
+    <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Match-heading:p Match-heading:s">
+          <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='410']">
-    <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
+    <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
+          <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
+  </xslo:template>
+  <xslo:template mode="index_match_heading" match="marc:datafield[@tag='510']">
+    <z:index name="Match:w Match:p">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('abcdefghklmnoprstvxyz', @code)" name="Match:w Match:p">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('vxyz', @code)">
+                  <xslo:choose>
+                    <xslo:when test="@code = $general_subdivision_subfield">
+                      <xslo:text> generalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $form_subdivision_subfield">
+                      <xslo:text> formsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $chronological_subdivision_subfield">
+                      <xslo:text> chronologicalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $geographic_subdivision_subfield">
+                      <xslo:text> geographicsubdiv </xslo:text>
+                    </xslo:when>
+                  </xslo:choose>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='111']">
-    <z:index name="Match-heading:p Match-heading:s">
+    <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Match-heading:p Match-heading:s">
+          <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='411']">
-    <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
+    <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
+          <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
+  </xslo:template>
+  <xslo:template mode="index_match_heading" match="marc:datafield[@tag='511']">
+    <z:index name="Match:w Match:p">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('acdefghjklnpqstvxyz', @code)" name="Match:w Match:p">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('vxyz', @code)">
+                  <xslo:choose>
+                    <xslo:when test="@code = $general_subdivision_subfield">
+                      <xslo:text> generalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $form_subdivision_subfield">
+                      <xslo:text> formsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $chronological_subdivision_subfield">
+                      <xslo:text> chronologicalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $geographic_subdivision_subfield">
+                      <xslo:text> geographicsubdiv </xslo:text>
+                    </xslo:when>
+                  </xslo:choose>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='130']">
-    <z:index name="Match-heading:p Match-heading:s">
+    <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Match-heading:p Match-heading:s">
+          <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='430']">
-    <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
+    <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
+          <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
+  </xslo:template>
+  <xslo:template mode="index_match_heading" match="marc:datafield[@tag='530']">
+    <z:index name="Match:w Match:p">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('adfghklmnoprstvxyz', @code)" name="Match:w Match:p">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('vxyz', @code)">
+                  <xslo:choose>
+                    <xslo:when test="@code = $general_subdivision_subfield">
+                      <xslo:text> generalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $form_subdivision_subfield">
+                      <xslo:text> formsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $chronological_subdivision_subfield">
+                      <xslo:text> chronologicalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $geographic_subdivision_subfield">
+                      <xslo:text> geographicsubdiv </xslo:text>
+                    </xslo:when>
+                  </xslo:choose>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='148']">
-    <z:index name="Match-heading:p Match-heading:s">
+    <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('avxyz', @code)" name="Match-heading:p Match-heading:s">
+          <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='448']">
-    <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
+    <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('avxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
+          <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
+  </xslo:template>
+  <xslo:template mode="index_match_heading" match="marc:datafield[@tag='548']">
+    <z:index name="Match:w Match:p">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('vxyz', @code)">
+                  <xslo:choose>
+                    <xslo:when test="@code = $general_subdivision_subfield">
+                      <xslo:text> generalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $form_subdivision_subfield">
+                      <xslo:text> formsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $chronological_subdivision_subfield">
+                      <xslo:text> chronologicalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $geographic_subdivision_subfield">
+                      <xslo:text> geographicsubdiv </xslo:text>
+                    </xslo:when>
+                  </xslo:choose>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='150']">
-    <z:index name="Match-heading:p Match-heading:s">
+    <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('abvxyz', @code)" name="Match-heading:p Match-heading:s">
+          <xslo:if test="contains('abvxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='450']">
-    <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
+    <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('abvxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
+          <xslo:if test="contains('abvxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
+  </xslo:template>
+  <xslo:template mode="index_match_heading" match="marc:datafield[@tag='550']">
+    <z:index name="Match:w Match:p">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('abvxyz', @code)" name="Match:w Match:p">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('vxyz', @code)">
+                  <xslo:choose>
+                    <xslo:when test="@code = $general_subdivision_subfield">
+                      <xslo:text> generalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $form_subdivision_subfield">
+                      <xslo:text> formsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $chronological_subdivision_subfield">
+                      <xslo:text> chronologicalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $geographic_subdivision_subfield">
+                      <xslo:text> geographicsubdiv </xslo:text>
+                    </xslo:when>
+                  </xslo:choose>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='151']">
-    <z:index name="Match-heading:p Match-heading:s">
+    <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('avxyz', @code)" name="Match-heading:p Match-heading:s">
+          <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='451']">
-    <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
+    <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('avxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
+          <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
+  </xslo:template>
+  <xslo:template mode="index_match_heading" match="marc:datafield[@tag='551']">
+    <z:index name="Match:w Match:p">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('vxyz', @code)">
+                  <xslo:choose>
+                    <xslo:when test="@code = $general_subdivision_subfield">
+                      <xslo:text> generalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $form_subdivision_subfield">
+                      <xslo:text> formsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $chronological_subdivision_subfield">
+                      <xslo:text> chronologicalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $geographic_subdivision_subfield">
+                      <xslo:text> geographicsubdiv </xslo:text>
+                    </xslo:when>
+                  </xslo:choose>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='155']">
-    <z:index name="Match-heading:p Match-heading:s">
+    <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('avxyz', @code)" name="Match-heading:p Match-heading:s">
+          <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading:p Match-heading:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='455']">
-    <z:index name="Match-heading-see-from:p Match-heading-see-from:s">
+    <z:index name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
       <xslo:variable name="raw_heading">
         <xslo:for-each select="marc:subfield">
-          <xslo:if test="contains('avxyz', @code)" name="Match-heading-see-from:p Match-heading-see-from:s">
+          <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p Match-heading-see-from:p Match-heading-see-from:s">
             <xslo:if test="position() &gt; 1">
               <xslo:choose>
                 <xslo:when test="contains('vxyz', @code)">
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
+          </xslo:if>
+        </xslo:for-each>
+      </xslo:variable>
+      <xslo:value-of select="normalize-space($raw_heading)"/>
+    </z:index>
+  </xslo:template>
+  <xslo:template mode="index_match_heading" match="marc:datafield[@tag='555']">
+    <z:index name="Match:w Match:p">
+      <xslo:variable name="raw_heading">
+        <xslo:for-each select="marc:subfield">
+          <xslo:if test="contains('avxyz', @code)" name="Match:w Match:p">
+            <xslo:if test="position() &gt; 1">
+              <xslo:choose>
+                <xslo:when test="contains('vxyz', @code)">
+                  <xslo:choose>
+                    <xslo:when test="@code = $general_subdivision_subfield">
+                      <xslo:text> generalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $form_subdivision_subfield">
+                      <xslo:text> formsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $chronological_subdivision_subfield">
+                      <xslo:text> chronologicalsubdiv </xslo:text>
+                    </xslo:when>
+                    <xslo:when test="@code = $geographic_subdivision_subfield">
+                      <xslo:text> geographicsubdiv </xslo:text>
+                    </xslo:when>
+                  </xslo:choose>
+                </xslo:when>
+                <xslo:otherwise>
+                  <xslo:value-of select="substring(' ', 1, 1)"/>
+                </xslo:otherwise>
+              </xslo:choose>
+            </xslo:if>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
                 </xslo:otherwise>
               </xslo:choose>
             </xslo:if>
-            <xslo:value-of select="."/>
+            <xslo:call-template name="chopPunctuation">
+              <xslo:with-param name="chopString">
+                <xslo:value-of select="."/>
+              </xslo:with-param>
+            </xslo:call-template>
           </xslo:if>
         </xslo:for-each>
       </xslo:variable>
       <xslo:value-of select="$full_thesaurus_code"/>
     </z:index>
   </xslo:template>
+  <xslo:template match="*">
+    <z:index name="Any:w Any:p">
+      <xslo:value-of select="."/>
+    </z:index>
+  </xslo:template>
+  <xslo:template name="chopPunctuation">
+    <xslo:param name="chopString"/>
+    <xslo:variable name="length" select="string-length($chopString)"/>
+    <xslo:choose>
+      <xslo:when test="$length=0"/>
+      <xslo:when test="contains('-,.:=;!%/', substring($chopString,$length,1))">
+        <xslo:call-template name="chopPunctuation">
+          <xslo:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
+        </xslo:call-template>
+      </xslo:when>
+      <xslo:when test="not($chopString)"/>
+      <xslo:otherwise>
+        <xslo:value-of select="$chopString"/>
+      </xslo:otherwise>
+    </xslo:choose>
+    <xslo:text/>
+  </xslo:template>
 </xslo:stylesheet>