Merge remote-tracking branch 'kc/new/enh/bug_5579' into kcmaster
[koha.git] / etc / zebradb / marc_defs / marc21 / authorities / authority-zebra-indexdefs.xsl
index a062279..5c37bc6 100644 (file)
@@ -1,5 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<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.org/schemas/index-defs" version="1.0">
+<!--
+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()"/>
   <xslo:template match="text()" mode="index_subfields"/>
     </z:record>
   </xslo:template>
   <xslo:template match="marc:leader">
-    <z:index name="Record-status">
+    <z:index name="Record-status:w">
       <xslo:value-of select="substring(., 6, 1)"/>
     </z:index>
-    <z:index name="Encoding-level">
+    <z:index name="Encoding-level:w">
       <xslo:value-of select="substring(., 18, 1)"/>
     </z:index>
   </xslo:template>
   <xslo:template match="marc:controlfield[@tag='001']">
-    <z:index name="Local-Number">
+    <z:index name="Local-Number:w">
       <xslo:value-of select="."/>
     </z:index>
   </xslo:template>
   <xslo:template match="marc:controlfield[@tag='008']">
-    <z:index name="Kind-of-record">
+    <z:index name="Kind-of-record:w">
       <xslo:value-of select="substring(., 10, 1)"/>
     </z:index>
-    <z:index name="Descriptive-cataloging-rules">
+    <z:index name="Descriptive-cataloging-rules:w">
       <xslo:value-of select="substring(., 11, 1)"/>
     </z:index>
-    <z:index name="Heading-use-main-or-added-entry">
+    <z:index name="Heading-use-main-or-added-entry:w">
       <xslo:value-of select="substring(., 15, 1)"/>
     </z:index>
-    <z:index name="Heading-use-subject-added-entry">
+    <z:index name="Heading-use-subject-added-entry:w">
       <xslo:value-of select="substring(., 16, 1)"/>
     </z:index>
-    <z:index name="Heading-use-series-added-entry">
+    <z:index name="Heading-use-series-added-entry:w">
       <xslo:value-of select="substring(., 17, 1)"/>
     </z:index>
   </xslo:template>
   <xslo:template mode="index_subfields" match="marc:datafield[@tag='942']">
     <xslo:for-each select="marc:subfield">
       <xslo:if test="contains('a', @code)">
-        <z:index name="authtype">
+        <z:index name="authtype:w">
           <xslo:value-of select="."/>
         </z:index>
       </xslo:if>
       </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">
         </xslo:otherwise>
       </xslo:choose>
     </xslo:variable>
-    <z:index name="Subject-heading-thesaurus">
+    <z:index name="Subject-heading-thesaurus:w">
       <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:stylesheet>