Merge branch 'bug_8945' into 3.12-master
[koha.git] / etc / zebradb / marc_defs / marc21 / authorities / authority-zebra-indexdefs.xsl
index aa02e70..02509b3 100644 (file)
@@ -3,15 +3,17 @@
 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).
+definition file (probably something like {biblio,authority}-koha-indexdefs.xml) and run:
+`xsltproc koha-indexdefs-to-zebra.xsl {biblio,authority}-koha-indexdefs.xml >
+{biblio,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"/>
+  <xslo:template match="text()" mode="index_data_field"/>
   <xslo:template match="text()" mode="index_heading"/>
+  <xslo:template match="text()" mode="index_heading_conditional"/>
   <xslo:template match="text()" mode="index_match_heading"/>
   <xslo:template match="text()" mode="index_subject_thesaurus"/>
   <xslo:template match="/">
@@ -25,14 +27,16 @@ authority-zebra-indexdefs.xsl` (substituting the appropriate file names).
     </xslo:if>
   </xslo:template>
   <xslo:template match="marc:record">
-    <xslo:variable name="controlField001" select="normalize-space(marc:controlfield[@tag='001'])"/>
+    <xslo:variable name="idfield" select="normalize-space(marc:controlfield[@tag='001'])"/>
     <z:record type="update">
       <xslo:attribute name="z:id">
-        <xslo:value-of select="$controlField001"/>
+        <xslo:value-of select="$idfield"/>
       </xslo:attribute>
       <xslo:apply-templates/>
       <xslo:apply-templates mode="index_subfields"/>
+      <xslo:apply-templates mode="index_data_field"/>
       <xslo:apply-templates mode="index_heading"/>
+      <xslo:apply-templates mode="index_heading_conditional"/>
       <xslo:apply-templates mode="index_match_heading"/>
       <xslo:apply-templates mode="index_subject_thesaurus"/>
     </z:record>
@@ -67,6 +71,24 @@ authority-zebra-indexdefs.xsl` (substituting the appropriate file names).
       <xslo:value-of select="substring(., 17, 1)"/>
     </z:index>
   </xslo:template>
+  <xslo:template mode="index_subfields" match="marc:datafield[@tag='010']">
+    <xslo:for-each select="marc:subfield">
+      <xslo:if test="contains('az', @code)">
+        <z:index name="LC-card-number:w LC-card-number:p">
+          <xslo:value-of select="."/>
+        </z:index>
+      </xslo:if>
+    </xslo:for-each>
+  </xslo:template>
+  <xslo:template mode="index_subfields" match="marc:datafield[@tag='040']">
+    <xslo:for-each select="marc:subfield">
+      <xslo:if test="contains('acd', @code)">
+        <z:index name="Record-source:w Record-source:p">
+          <xslo:value-of select="."/>
+        </z:index>
+      </xslo:if>
+    </xslo:for-each>
+  </xslo:template>
   <xslo:template mode="index_subfields" match="marc:datafield[@tag='100']">
     <xslo:for-each select="marc:subfield">
       <xslo:if test="contains('abcdefghjklmnopqrstvxyz', @code)">
@@ -1100,6 +1122,30 @@ authority-zebra-indexdefs.xsl` (substituting the appropriate file names).
       <xslo:value-of select="normalize-space($raw_heading)"/>
     </z:index>
   </xslo:template>
+  <xslo:template mode="index_heading_conditional" match="marc:datafield[@tag='450']">
+    <xslo:if test="substring(marc:subfield[@code='w']/text(), 2, 1)">
+      <z:index name="Previous-heading-see-from:p">
+        <xslo:variable name="raw_heading">
+          <xslo:for-each select="marc:subfield">
+            <xslo:if test="contains('abvxyz', @code)" name="Previous-heading-see-from:p">
+              <xslo:if test="position() &gt; 1">
+                <xslo:choose>
+                  <xslo:when test="contains('vxyz', @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:if>
+  </xslo:template>
   <xslo:template mode="index_match_heading" match="marc:datafield[@tag='100']">
     <z:index name="Match:w Match:p Match-heading:p Match-heading:s">
       <xslo:variable name="raw_heading">