Bug 13383: 100/110/111 changes to XSLT
authorWinona Salesky <wsalesky@gmail.com>
Fri, 5 Jun 2015 02:30:49 +0000 (22:30 -0400)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 28 Aug 2015 12:39:26 +0000 (09:39 -0300)
Test plan:
1) Apply this patch
2) Ensure you are using the default XSLT setting for the staff and opac search results and record details
3) Find or create a record with MARC tags 100,110,111
4) Perform an opac search that would show the record in the search results.
5) Click title to review record.
6) Note the fields updates 100,110,111 to show subfields a,b,c,d,q and t.Multiple fields are separated by span class=separator |. Includes 100$j and handles multiple relator terms/codes.
7) Repeat steps 4 - 6 for the staff interface

Signed-off-by: Nick Clemens <nick@quecheelibrary.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl
koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl
koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl

index 1b3531e..c24a2d0 100644 (file)
         <xsl:for-each select="$authorfield">
         <xsl:choose>
           <xsl:when test="position()&gt;1"/>
-          <xsl:when test="@tag&lt;700">Author(s): </xsl:when>
+          <!-- #13383 -->
+          <xsl:when test="@tag&lt;700">By: </xsl:when>
           <!--#13382 Changed Additional author to contributor -->
           <xsl:otherwise>Contributor(s): </xsl:otherwise>
         </xsl:choose>
             </xsl:otherwise>
         </xsl:choose>
        <xsl:choose>
-          <xsl:when test="@tag=100"><xsl:call-template name="nameABCQ"/></xsl:when>
-          <xsl:when test="@tag=110"><xsl:call-template name="nameABCDN"/></xsl:when>
-          <xsl:when test="@tag=111"><xsl:call-template name="nameACDEQ"/></xsl:when>
+           <xsl:when test="@tag=100 or @tag=110 or @tag=111">
+               <!-- #13383 -->
+               <xsl:call-template name="chopPunctuation">
+                   <xsl:with-param name="chopString">
+                       <xsl:call-template name="subfieldSelect">
+                           <xsl:with-param name="codes">
+                               <xsl:choose>
+                                   <!-- #13383 include subfield e for field 111  -->
+                                   <xsl:when test="@tag=111">abcdeqt</xsl:when>
+                                   <xsl:otherwise>abcdjqt</xsl:otherwise>
+                               </xsl:choose>
+                           </xsl:with-param>
+                       </xsl:call-template>
+                   </xsl:with-param>
+                   <xsl:with-param name="punctuation">
+                       <xsl:text>:,;/ </xsl:text>
+                   </xsl:with-param>
+               </xsl:call-template>
+           </xsl:when>
            <!-- #13382 excludes 700$i and ind2=2, displayed as Related Works -->
            <!--#13382 Added all relevant subfields 4, e, are handled separately -->
            <xsl:when test="@tag=700 or @tag=710 or @tag=711">
        </xsl:choose>
 
        <!-- add relator code too between brackets-->
-    <xsl:if test="marc:subfield[@code='4' or @code='e']">
-      <span class="relatorcode">
-      <xsl:text> [</xsl:text>
-         <xsl:choose>
-           <xsl:when test="marc:subfield[@code='e']">
-               <xsl:for-each select="marc:subfield[@code='e']">
-                   <xsl:value-of select="."/>
-                   <xsl:if test="position() != last()">, </xsl:if>
-               </xsl:for-each>
-           </xsl:when>
-           <xsl:otherwise>
-               <xsl:for-each select="marc:subfield[@code=4]">
-                   <xsl:value-of select="."/>
-                   <xsl:if test="position() != last()">, </xsl:if>
-               </xsl:for-each>
-           </xsl:otherwise>
-         </xsl:choose>
-         <xsl:text>]</xsl:text>
-      </span>
-       </xsl:if>
+    <!-- #13383 include relator code j for field 111 -->
+            <xsl:if test="marc:subfield[@code='4' or @code='e'][not(parent::*[@tag=111])] or (self::*[@tag=111] and marc:subfield[@code='4' or @code='j'][. != ''])">
+                <span class="relatorcode">
+                    <xsl:text> [</xsl:text>
+                    <xsl:choose>
+                        <xsl:when test="@tag=111">
+                            <xsl:choose>
+                                <!-- Prefer j over 4 -->
+                                <xsl:when test="marc:subfield[@code='j']">
+                                    <xsl:for-each select="marc:subfield[@code='j']">
+                                        <xsl:value-of select="."/>
+                                        <xsl:if test="position() != last()">, </xsl:if>
+                                    </xsl:for-each>
+                                </xsl:when>
+                                <xsl:otherwise>
+                                    <xsl:for-each select="marc:subfield[@code=4]">
+                                        <xsl:value-of select="."/>
+                                        <xsl:if test="position() != last()">, </xsl:if>
+                                    </xsl:for-each>
+                                </xsl:otherwise>
+                            </xsl:choose>
+                        </xsl:when>
+                        <!-- Prefer e over 4 -->
+                        <xsl:when test="marc:subfield[@code='e']">
+                            <xsl:for-each select="marc:subfield[@code='e']">
+                                <xsl:value-of select="."/>
+                                <xsl:if test="position() != last()">, </xsl:if>
+                            </xsl:for-each>
+                        </xsl:when>
+                        <xsl:otherwise>
+                            <xsl:for-each select="marc:subfield[@code=4]">
+                                <xsl:value-of select="."/>
+                                <xsl:if test="position() != last()">, </xsl:if>
+                            </xsl:for-each>
+                        </xsl:otherwise>
+                    </xsl:choose>
+                    <xsl:text>]</xsl:text>
+                </span>
+            </xsl:if>
        </a>
         <xsl:choose>
             <xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><span class="separator"><xsl:text> | </xsl:text></span></xsl:otherwise>
index 1f82eff..e913ce5 100644 (file)
     <xsl:choose>
     <xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]">
     <p class="author">by
-    <xsl:for-each select="marc:datafield[(@tag=100 or @tag=700) and @ind1!='z']">
-    <a>
-    <xsl:choose>
-        <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
-            <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
-        </xsl:when>
-        <xsl:otherwise>
-        <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=au:"<xsl:value-of select="marc:subfield[@code='a']"/>"</xsl:attribute>
-        </xsl:otherwise>
-    </xsl:choose>
-    <xsl:call-template name="nameABCQ"/></a>
-    <xsl:choose>
-    <xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
-    </xsl:for-each>
-
-    <xsl:for-each select="marc:datafield[(@tag=110 or @tag=710) and @ind1!='z']">
-    <a>
-    <xsl:choose>
-        <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
-            <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
-        </xsl:when>
-        <xsl:otherwise>
-        <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=au:"<xsl:value-of select="marc:subfield[@code='a']"/>"</xsl:attribute>
-        </xsl:otherwise>
-    </xsl:choose>
-    <xsl:call-template name="nameABCDN"/></a>
-    <xsl:choose><xsl:when test="position()=last()"><xsl:text> </xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
-    </xsl:for-each>
-
-    <xsl:for-each select="marc:datafield[(@tag=111 or @tag=711) and @ind1!='z']">
-        <xsl:choose>
-        <xsl:when test="marc:subfield[@code='n']">
-           <xsl:text> </xsl:text>
-           <xsl:call-template name="subfieldSelect">
-              <xsl:with-param name="codes">n</xsl:with-param>                              </xsl:call-template>
-           <xsl:text> </xsl:text>
-        </xsl:when>
-        </xsl:choose>
-    <a>
-    <xsl:choose>
-        <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
-            <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
-        </xsl:when>
-        <xsl:otherwise>
-        <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=au:"<xsl:value-of select="marc:subfield[@code='a']"/>"</xsl:attribute>
-        </xsl:otherwise>
-    </xsl:choose>
-    <xsl:call-template name="nameACDEQ"/></a>
-    <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
-
-    </xsl:for-each>
+        <!-- #13383 -->
+        <xsl:for-each select="marc:datafield[(@tag=100 or @tag=700 or @tag=110 or @tag=710 or @tag=111 or @tag=711) and @ind1!='z']">
+            <xsl:if test="@tag=111 or @tag=711 and marc:subfield[@code='n']">
+                <xsl:text> </xsl:text>
+                <xsl:call-template name="subfieldSelect">
+                    <xsl:with-param name="codes">n</xsl:with-param>
+                </xsl:call-template>
+                <xsl:text> </xsl:text>
+            </xsl:if>
+            <a>
+                <xsl:choose>
+                    <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
+                        <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=au:"<xsl:value-of select="marc:subfield[@code='a']"/>"</xsl:attribute>
+                    </xsl:otherwise>
+                </xsl:choose>
+                <xsl:call-template name="chopPunctuation">
+                    <xsl:with-param name="chopString">
+                        <xsl:call-template name="subfieldSelect">
+                            <xsl:with-param name="codes">
+                                <xsl:choose>
+                                    <!-- #13383 include subfield e for field 111  -->
+                                    <xsl:when test="@tag=111">abcdeqt</xsl:when>
+                                    <xsl:otherwise>abcdjqt</xsl:otherwise>
+                                </xsl:choose>
+                            </xsl:with-param>
+                        </xsl:call-template>
+                    </xsl:with-param>
+                    <xsl:with-param name="punctuation">
+                        <xsl:text>:,;/ </xsl:text>
+                    </xsl:with-param>
+                </xsl:call-template>
+            </a>
+            <xsl:if test="marc:subfield[@code='4' or @code='e'][not(parent::*[@tag=111])] or (self::*[@tag=111] and marc:subfield[@code='4' or @code='j'][. != ''])">
+                <span class="relatorcode">
+                    <xsl:text> [</xsl:text>
+                    <xsl:choose>
+                        <xsl:when test="@tag=111">
+                            <xsl:choose>
+                                <!-- Prefer j over 4 -->
+                                <xsl:when test="marc:subfield[@code='j']">
+                                    <xsl:for-each select="marc:subfield[@code='j']">
+                                        <xsl:value-of select="."/>
+                                        <xsl:if test="position() != last()">, </xsl:if>
+                                    </xsl:for-each>
+                                </xsl:when>
+                                <xsl:otherwise>
+                                    <xsl:for-each select="marc:subfield[@code=4]">
+                                        <xsl:value-of select="."/>
+                                        <xsl:if test="position() != last()">, </xsl:if>
+                                    </xsl:for-each>
+                                </xsl:otherwise>
+                            </xsl:choose>
+                        </xsl:when>
+                        <!-- Prefer e over 4 -->
+                        <xsl:when test="marc:subfield[@code='e']">
+                            <xsl:for-each select="marc:subfield[@code='e']">
+                                <xsl:value-of select="."/>
+                                <xsl:if test="position() != last()">, </xsl:if>
+                            </xsl:for-each>
+                        </xsl:when>
+                        <xsl:otherwise>
+                            <xsl:for-each select="marc:subfield[@code=4]">
+                                <xsl:value-of select="."/>
+                                <xsl:if test="position() != last()">, </xsl:if>
+                            </xsl:for-each>
+                        </xsl:otherwise>
+                    </xsl:choose>
+                    <xsl:text>]</xsl:text>
+                </span>
+            </xsl:if>
+            <xsl:choose>
+                <xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><span class="separator"><xsl:text> | </xsl:text></span></xsl:otherwise>
+            </xsl:choose>
+        </xsl:for-each>
     </p>
     </xsl:when>
     </xsl:choose>
index 8c128ab..dcfc521 100644 (file)
             <xsl:for-each select="$authorfield">
                 <xsl:choose>
                     <xsl:when test="position()&gt;1"/>
-                    <xsl:when test="@tag&lt;700">Author(s): </xsl:when>
+                    <!-- #13383 -->
+                    <xsl:when test="@tag&lt;700">By: </xsl:when>
                     <!--#13382 Changed Additional author to contributor -->
                     <xsl:otherwise>Contributor(s): </xsl:otherwise>
                 </xsl:choose>
                     </xsl:choose>
                 <span property="name">
                 <xsl:choose>
-                    <xsl:when test="@tag=100"><xsl:call-template name="nameABCQ"/></xsl:when>
-                    <xsl:when test="@tag=110"><xsl:call-template name="nameABCDN"/></xsl:when>
-                    <xsl:when test="@tag=111"><xsl:call-template name="nameACDEQ"/></xsl:when>
+                    <xsl:when test="@tag=100 or @tag=110 or @tag=111">
+                        <!-- #13383 -->
+                        <xsl:call-template name="chopPunctuation">
+                            <xsl:with-param name="chopString">
+                                <xsl:call-template name="subfieldSelect">
+                                    <xsl:with-param name="codes">
+                                        <xsl:choose>
+                                            <!-- #13383 include subfield e for field 111  -->
+                                            <xsl:when test="@tag=111">abcdeqt</xsl:when>
+                                            <xsl:otherwise>abcdjqt</xsl:otherwise>
+                                        </xsl:choose>
+                                    </xsl:with-param>
+                                </xsl:call-template>
+                            </xsl:with-param>
+                            <xsl:with-param name="punctuation">
+                                <xsl:text>:,;/ </xsl:text>
+                            </xsl:with-param>
+                        </xsl:call-template>
+                    </xsl:when>
                     <!-- #13382 excludes 700$i and ind2=2, displayed as Related Works -->
                     <!--#13382 Added all relevant subfields 4, e, are handled separately -->
                     <xsl:when test="@tag=700 or @tag=710 or @tag=711">
                     </xsl:when>
                 </xsl:choose>
                 </span></span></span>
-                <!-- add relator code too between brackets-->
-                <xsl:if test="marc:subfield[@code='4' or @code='e']">
+                <!-- #13383 include relator code j for field 111 -->
+                <xsl:if test="marc:subfield[@code='4' or @code='e'][not(parent::*[@tag=111])] or (self::*[@tag=111] and marc:subfield[@code='4' or @code='j'][. != ''])">
                     <span class="relatorcode">
                         <xsl:text> [</xsl:text>
                         <xsl:choose>
+                            <xsl:when test="@tag=111">
+                                <xsl:choose>
+                                    <!-- Prefer j over 4 -->
+                                    <xsl:when test="marc:subfield[@code='j']">
+                                        <xsl:for-each select="marc:subfield[@code='j']">
+                                            <xsl:value-of select="."/>
+                                            <xsl:if test="position() != last()">, </xsl:if>
+                                        </xsl:for-each>
+                                    </xsl:when>
+                                    <xsl:otherwise>
+                                        <xsl:for-each select="marc:subfield[@code=4]">
+                                            <xsl:value-of select="."/>
+                                            <xsl:if test="position() != last()">, </xsl:if>
+                                        </xsl:for-each>
+                                    </xsl:otherwise>
+                                </xsl:choose>
+                            </xsl:when>
+                            <!-- Prefer e over 4 -->
                             <xsl:when test="marc:subfield[@code='e']">
                                 <xsl:for-each select="marc:subfield[@code='e']">
                                     <xsl:value-of select="."/>
                     </xsl:element>
                 </a>
             </xsl:if>
-        </xsl:for-each>
-            <xsl:choose>
-                <xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><span class="separator"><xsl:text> | </xsl:text></span></xsl:otherwise>
-            </xsl:choose>
+                <xsl:choose>
+                    <xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><span class="separator"><xsl:text> | </xsl:text></span></xsl:otherwise>
+                </xsl:choose>
+            </xsl:for-each>
         </h5>
         </xsl:if>
     </xsl:template>
index 167f46d..4623dff 100644 (file)
     <xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]">
 
     by <span class="author">
-        <xsl:for-each select="marc:datafield[(@tag=100 or @tag=700) and @ind1!='z']">
-            <xsl:choose>
-            <xsl:when test="position()=last()">
-                <xsl:call-template name="nameABCQ"/>.
-            </xsl:when>
-            <xsl:otherwise>
-                <xsl:call-template name="nameABCQ"/>;
-            </xsl:otherwise>
-            </xsl:choose>
-        </xsl:for-each>
-
-        <xsl:for-each select="marc:datafield[(@tag=110 or @tag=710) and @ind1!='z']">
-            <xsl:choose>
-            <xsl:when test="position()=1">
-               <xsl:text> -- </xsl:text>
-            </xsl:when>
-            </xsl:choose>
+        <!-- #13383 -->
+        <xsl:for-each select="marc:datafield[(@tag=100 or @tag=700 or @tag=110 or @tag=710 or @tag=111 or @tag=711) and @ind1!='z']">
+            <xsl:if test="@tag=111 or @tag=711 and marc:subfield[@code='n']">
+                <xsl:text> </xsl:text>
+                <xsl:call-template name="subfieldSelect">
+                    <xsl:with-param name="codes">n</xsl:with-param>
+                </xsl:call-template>
+                <xsl:text> </xsl:text>
+            </xsl:if>
+            <xsl:call-template name="chopPunctuation">
+                <xsl:with-param name="chopString">
+                    <xsl:call-template name="subfieldSelect">
+                        <xsl:with-param name="codes">
+                            <xsl:choose>
+                                <!-- #13383 include subfield e for field 111  -->
+                                <xsl:when test="@tag=111">abcdeqt</xsl:when>
+                                <xsl:otherwise>abcdjqt</xsl:otherwise>
+                            </xsl:choose>
+                        </xsl:with-param>
+                    </xsl:call-template>
+                </xsl:with-param>
+                <xsl:with-param name="punctuation">
+                    <xsl:text>:,;/ </xsl:text>
+                </xsl:with-param>
+            </xsl:call-template>
+            <xsl:if test="marc:subfield[@code='4' or @code='e'][not(parent::*[@tag=111])] or (self::*[@tag=111] and marc:subfield[@code='4' or @code='j'][. != ''])">
+                <span class="relatorcode">
+                    <xsl:text> [</xsl:text>
+                    <xsl:choose>
+                        <xsl:when test="@tag=111">
+                            <xsl:choose>
+                                <!-- Prefer j over 4 -->
+                                <xsl:when test="marc:subfield[@code='j']">
+                                    <xsl:for-each select="marc:subfield[@code='j']">
+                                        <xsl:value-of select="."/>
+                                        <xsl:if test="position() != last()">, </xsl:if>
+                                    </xsl:for-each>
+                                </xsl:when>
+                                <xsl:otherwise>
+                                    <xsl:for-each select="marc:subfield[@code=4]">
+                                        <xsl:value-of select="."/>
+                                        <xsl:if test="position() != last()">, </xsl:if>
+                                    </xsl:for-each>
+                                </xsl:otherwise>
+                            </xsl:choose>
+                        </xsl:when>
+                        <!-- Prefer e over 4 -->
+                        <xsl:when test="marc:subfield[@code='e']">
+                            <xsl:for-each select="marc:subfield[@code='e']">
+                                <xsl:value-of select="."/>
+                                <xsl:if test="position() != last()">, </xsl:if>
+                            </xsl:for-each>
+                        </xsl:when>
+                        <xsl:otherwise>
+                            <xsl:for-each select="marc:subfield[@code=4]">
+                                <xsl:value-of select="."/>
+                                <xsl:if test="position() != last()">, </xsl:if>
+                            </xsl:for-each>
+                        </xsl:otherwise>
+                    </xsl:choose>
+                    <xsl:text>]</xsl:text>
+                </span>
+            </xsl:if>
             <xsl:choose>
-            <xsl:when test="position()=last()">
-                <xsl:call-template name="nameABCDN"/>
-            </xsl:when>
-            <xsl:otherwise>
-                <xsl:call-template name="nameABCDN"/>;
-            </xsl:otherwise>
+                <xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><span class="separator"><xsl:text> | </xsl:text></span></xsl:otherwise>
             </xsl:choose>
         </xsl:for-each>
 
-        <xsl:for-each select="marc:datafield[(@tag=111 or @tag=711) and @ind1!='z']">
-            <xsl:choose>
-            <xsl:when test="position()=1">
-               <xsl:text> -- </xsl:text>
-            </xsl:when>
-            </xsl:choose>
-            <xsl:choose>
-            <xsl:when test="marc:subfield[@code='n']">
-               <xsl:text> </xsl:text>
-               <xsl:call-template name="subfieldSelect">
-                  <xsl:with-param name="codes">n</xsl:with-param>
-               </xsl:call-template>
-               <xsl:text> </xsl:text>
-            </xsl:when>
-            </xsl:choose>
-            <xsl:choose>
-            <xsl:when test="position()=last()">
-                <xsl:call-template name="nameACDEQ"/>.
-            </xsl:when>
-            <xsl:otherwise>
-                <xsl:call-template name="nameACDEQ"/>;
-            </xsl:otherwise>
-            </xsl:choose>
-        </xsl:for-each>
     </span>
     </xsl:when>
     </xsl:choose>