Bug 21887: 856 link problem in XSLT result lists and detail page
[koha-ffzg.git] / koha-tmpl / intranet-tmpl / prog / en / xslt / MARC21slim2intranetDetail.xsl
index a2f7a0c..a4d97a0 100644 (file)
@@ -8,7 +8,8 @@
   xmlns:marc="http://www.loc.gov/MARC21/slim"
   xmlns:items="http://www.koha-community.org/items"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-  exclude-result-prefixes="marc items">
+  xmlns:str="http://exslt.org/strings"
+  exclude-result-prefixes="marc items str">
     <xsl:import href="MARC21slimUtils.xsl"/>
     <xsl:output method = "html" indent="yes" omit-xml-declaration = "yes" encoding="UTF-8"/>
     <xsl:template match="/">
@@ -27,6 +28,7 @@
         <xsl:variable name="TraceSubjectSubdivisions" select="marc:sysprefs/marc:syspref[@name='TraceSubjectSubdivisions']"/>
         <xsl:variable name="Show856uAsImage" select="marc:sysprefs/marc:syspref[@name='Display856uAsImage']"/>
         <xsl:variable name="DisplayIconsXSLT" select="marc:sysprefs/marc:syspref[@name='DisplayIconsXSLT']"/>
+        <xsl:variable name="OpacSuppression" select="marc:sysprefs/marc:syspref[@name='OpacSuppression']"/>
         <xsl:variable name="TracingQuotesLeft">
            <xsl:choose>
              <xsl:when test="marc:sysprefs/marc:syspref[@name='UseICU']='1'">{</xsl:when>
@@ -39,6 +41,7 @@
             <xsl:otherwise>"</xsl:otherwise>
           </xsl:choose>
         </xsl:variable>
+
         <xsl:variable name="leader" select="marc:leader"/>
         <xsl:variable name="leader6" select="substring($leader,7,1)"/>
         <xsl:variable name="leader7" select="substring($leader,8,1)"/>
             </xsl:choose>
         </xsl:variable>
 
+        <!-- Indicate if record is suppressed in OPAC -->
+        <xsl:if test="$OpacSuppression = 1">
+            <xsl:if test="marc:datafield[@tag=942][marc:subfield[@code='n'] = '1']">
+                <span class="results_summary suppressed_opac">Suppressed in OPAC</span>
+            </xsl:if>
+        </xsl:if>
+
         <!-- Title Statement -->
         <!-- Alternate Graphic Representation (MARC 880) -->
         <xsl:if test="$display880">
                     </xsl:call-template>
                     <xsl:text> </xsl:text>
                     <!-- 13381 add additional subfields-->
-                    <xsl:for-each select="marc:subfield[contains('bchknps', @code)]">
+                    <!-- bz 17625 adding subfields f and g -->
+                    <xsl:for-each select="marc:subfield[contains('bcfghknps', @code)]">
                         <xsl:choose>
                             <xsl:when test="@code='h'">
                                 <!--  13381 Span class around subfield h so it can be suppressed via css -->
-                                <span class="title_medium"><xsl:apply-templates/> </span>
+                                <span class="title_medium"><xsl:apply-templates/> <xsl:text> </xsl:text> </span>
                             </xsl:when>
                             <xsl:when test="@code='c'">
                                 <!--  13381 Span class around subfield c so it can be suppressed via css -->
-                                <span class="title_resp_stmt"><xsl:apply-templates/> </span>
+                                <span class="title_resp_stmt"><xsl:apply-templates/> <xsl:text> </xsl:text> </span>
                             </xsl:when>
                             <xsl:otherwise>
                                 <xsl:apply-templates/>
                     <xsl:with-param name="codes">abc</xsl:with-param>
                     <xsl:with-param name="index">au</xsl:with-param>
                     <xsl:with-param name="UseAuthoritiesForTracings" select="$UseAuthoritiesForTracings"/>
-                    <!-- do not use label 'by ' here, it would be repeated for every occurence of 100,110,111,700,710,711 -->
+                    <!-- do not use label 'by ' here, it would be repeated for every occurrence of 100,110,111,700,710,711 -->
                 </xsl:call-template>
             </h5>
         </xsl:if>
 
     <xsl:if test="$DisplayIconsXSLT!='0' and $materialTypeCode!=''">
         <span class="results_summary type"><span class="label">Material type: </span>
-        <xsl:element name="img"><xsl:attribute name="src">/intranet-tmpl/prog/img/famfamfam/<xsl:value-of select="$materialTypeCode"/>.png</xsl:attribute><xsl:attribute name="alt"></xsl:attribute></xsl:element>
+    <xsl:element name="img"><xsl:attribute name="class">materialtype mt_icon_<xsl:value-of select="$materialTypeCode"/></xsl:attribute><xsl:attribute name="src">/intranet-tmpl/prog/img/famfamfam/<xsl:value-of select="$materialTypeCode"/>.png</xsl:attribute><xsl:attribute name="alt"></xsl:attribute></xsl:element>
         <xsl:text> </xsl:text>
         <xsl:value-of select="$materialTypeLabel"/>
         </span>
         <span class="results_summary series"><span class="label">Series: </span>
         <!-- 440 -->
         <xsl:for-each select="marc:datafield[@tag=440]">
-            <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=se,phr:"<xsl:value-of select="marc:subfield[@code='a']"/>"</xsl:attribute>
+            <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=se,phr:"<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>"</xsl:attribute>
             <xsl:call-template name="chopPunctuation">
                             <xsl:with-param name="chopString">
                                 <xsl:call-template name="subfieldSelect">
 
         <!-- 490 Series not traced, Ind1 = 0 -->
         <xsl:for-each select="marc:datafield[@tag=490][@ind1!=1]">
-            <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=se,phr:"<xsl:value-of select="marc:subfield[@code='a']"/>"</xsl:attribute>
+            <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=se,phr:"<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>"</xsl:attribute>
                         <xsl:call-template name="chopPunctuation">
                             <xsl:with-param name="chopString">
                                 <xsl:call-template name="subfieldSelect">
         </xsl:for-each>
         <!-- 490 Series traced, Ind1 = 1 -->
         <xsl:if test="marc:datafield[@tag=490][@ind1=1]">
-            <xsl:for-each select="marc:datafield[@tag=800 or @tag=810 or @tag=811 or @tag=830]">
+            <xsl:for-each select="marc:datafield[@tag=800 or @tag=810 or @tag=811]">
+                <xsl:choose>
+                    <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
+                        <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=rcn:<xsl:value-of select="str:encode-uri(marc:subfield[@code='w'], true())"/></xsl:attribute>
+                            <xsl:call-template name="chopPunctuation">
+                                <xsl:with-param name="chopString">
+                                    <xsl:call-template name="subfieldSelect">
+                                        <xsl:with-param name="codes">a_t</xsl:with-param>
+                                    </xsl:call-template>
+                                </xsl:with-param>
+                            </xsl:call-template>
+                        </a>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=se,phr:"<xsl:value-of select="str:encode-uri(marc:subfield[@code='t'], true())"/>"&amp;q=au:"<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>"</xsl:attribute>
+                            <xsl:call-template name="chopPunctuation">
+                                <xsl:with-param name="chopString">
+                                    <xsl:call-template name="subfieldSelect">
+                                        <xsl:with-param name="codes">a_t</xsl:with-param>
+                                    </xsl:call-template>
+                                </xsl:with-param>
+                            </xsl:call-template>
+                        </a>
+                        <xsl:call-template name="part"/>
+                    </xsl:otherwise>
+                </xsl:choose>
+                <xsl:text>: </xsl:text>
+                <xsl:value-of  select="marc:subfield[@code='v']" />
+            <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=830]">
                 <xsl:choose>
                     <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
                         <a href="/cgi-bin/koha/catalogue/search.pl?q=rcn:{marc:subfield[@code='w']}">
             <a>
             <xsl:choose>
             <xsl:when test="$UseControlNumber = '1' and marc:controlfield[@tag=001]">
-                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=rcn:<xsl:value-of select="marc:controlfield[@tag=001]"/>+and+(bib-level:a+or+bib-level:b)</xsl:attribute>
+                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=rcn:<xsl:value-of select="str:encode-uri(marc:controlfield[@tag=001], true())"/>+and+(bib-level:a+or+bib-level:b)</xsl:attribute>
             </xsl:when>
             <xsl:otherwise>
-                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Host-item:<xsl:value-of select="translate(marc:datafield[@tag=245]/marc:subfield[@code='a'], '/', '')"/></xsl:attribute>
+                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Host-item:<xsl:value-of select="str:encode-uri(translate(marc:datafield[@tag=245]/marc:subfield[@code='a'], '/', ''), true())"/></xsl:attribute>
             </xsl:otherwise>
             </xsl:choose>
             <xsl:text>Show analytics</xsl:text>
             <a>
             <xsl:choose>
             <xsl:when test="$UseControlNumber = '1' and marc:controlfield[@tag=001]">
-                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=rcn:<xsl:value-of select="marc:controlfield[@tag=001]"/>+not+(bib-level:a+or+bib-level:b)</xsl:attribute>
+                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=rcn:<xsl:value-of select="str:encode-uri(marc:controlfield[@tag=001], true())"/>+not+(bib-level:a+or+bib-level:b)</xsl:attribute>
             </xsl:when>
             <xsl:otherwise>
-                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="translate(marc:datafield[@tag=245]/marc:subfield[@code='a'], '/', '')"/></xsl:attribute>
+                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="str:encode-uri(translate(marc:datafield[@tag=245]/marc:subfield[@code='a'], '/', ''), true())"/></xsl:attribute>
             </xsl:otherwise>
             </xsl:choose>
             <xsl:text>Show volumes</xsl:text>
                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
             </xsl:when>
             <xsl:otherwise>
-                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="translate(//marc:datafield[@tag=245]/marc:subfield[@code='a'], '.', '')"/></xsl:attribute>
+                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="str:encode-uri(translate(//marc:datafield[@tag=245]/marc:subfield[@code='a'], '.', ''), true())"/></xsl:attribute>
             </xsl:otherwise>
             </xsl:choose>
             <xsl:value-of select="translate(//marc:datafield[@tag=245]/marc:subfield[@code='a'], '.', '')" />
         <!-- Publisher info and RDA related info from tags 260, 264 -->
         <xsl:choose>
             <xsl:when test="marc:datafield[@tag=264]">
-                <xsl:call-template name="showRDAtag264"/>
+                <xsl:call-template name="showRDAtag264">
+                   <xsl:with-param name="show_url">1</xsl:with-param>
+                </xsl:call-template>
             </xsl:when>
             <xsl:when test="marc:datafield[@tag=260]">
                 <span class="results_summary publisher"><span class="label">Publisher: </span>
                         </xsl:if>
                         <xsl:text> </xsl:text>
                         <xsl:if test="marc:subfield[@code='b']">
-                        <a href="/cgi-bin/koha/catalogue/search.pl?q=pb:{marc:subfield[@code='b']}">
+                        <a>
+                            <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Provider:"<xsl:value-of select="str:encode-uri(marc:subfield[@code='b'], true())"/>"</xsl:attribute>
                             <xsl:call-template name="subfieldSelect">
                                 <xsl:with-param name="codes">b</xsl:with-param>
                             </xsl:call-template>
                 <xsl:call-template name="chopPunctuation">
                   <xsl:with-param name="chopString">
                     <xsl:call-template name="subfieldSelect">
-                        <xsl:with-param name="codes">abceg</xsl:with-param>
+                        <xsl:with-param name="codes">abcefg</xsl:with-param>
                     </xsl:call-template>
                    </xsl:with-param>
                </xsl:call-template>
         </xsl:if>
 
 
-        <!-- Build ISBN -->
-        <xsl:if test="marc:datafield[@tag=020]/marc:subfield[@code='a']">
-          <span class="results_summary isbn"><span class="label">ISBN: </span>
-            <xsl:for-each select="marc:datafield[@tag=020]/marc:subfield[@code='a']">
-              <span property="isbn">
-                <xsl:value-of select="."/>
-                <xsl:choose>
-                  <xsl:when test="position()=last()">
-                    <xsl:text>.</xsl:text>
-                  </xsl:when>
-                  <xsl:otherwise>
-                    <xsl:text>; </xsl:text>
-                  </xsl:otherwise>
-                </xsl:choose>
-              </span>
-            </xsl:for-each>
-          </span>
-        </xsl:if>
-
-        <!-- Build ISSN -->
-        <xsl:if test="marc:datafield[@tag=022]/marc:subfield[@code='a']">
-          <span class="results_summary issn"><span class="label">ISSN: </span>
-            <xsl:for-each select="marc:datafield[@tag=022]/marc:subfield[@code='a']">
-              <span property="issn">
-                <xsl:value-of select="."/>
-                <xsl:choose>
-                  <xsl:when test="position()=last()">
-                    <xsl:text>.</xsl:text>
-                  </xsl:when>
-                  <xsl:otherwise>
-                    <xsl:text>; </xsl:text>
-                  </xsl:otherwise>
-                </xsl:choose>
-              </span>
-            </xsl:for-each>
-          </span>
-        </xsl:if>
+        <xsl:call-template name="showISBNISSN"/>
 
         <xsl:if test="marc:datafield[@tag=013]">
             <span class="results_summary patent_info">
             <xsl:choose>
             <!-- #1807 Strip unwanted parenthesis from subjects for searching -->
             <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:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="str:encode-uri(marc:subfield[@code=9], true())"/></xsl:attribute>
             </xsl:when>
             <xsl:when test="$TraceSubjectSubdivisions='1'">
                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:call-template name="subfieldSelectSubject">
                         <xsl:with-param name="delimeter"> AND </xsl:with-param>
                         <xsl:with-param name="prefix">(su<xsl:value-of select="$SubjectModifier"/>:<xsl:value-of select="$TracingQuotesLeft"/></xsl:with-param>
                         <xsl:with-param name="suffix"><xsl:value-of select="$TracingQuotesRight"/>)</xsl:with-param>
+                        <xsl:with-param name="urlencode">1</xsl:with-param>
                     </xsl:call-template>
                 </xsl:attribute>
             </xsl:when>
+
             <!-- #1807 Strip unwanted parenthesis from subjects for searching -->
             <xsl:otherwise>
-                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=su<xsl:value-of select="$SubjectModifier"/>:<xsl:value-of select="$TracingQuotesLeft"/><xsl:value-of select="translate(marc:subfield[@code='a'],'()','')"/><xsl:value-of select="$TracingQuotesRight"/></xsl:attribute>
+                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=su<xsl:value-of select="$SubjectModifier"/>:<xsl:value-of select="$TracingQuotesLeft"/><xsl:value-of select="str:encode-uri(translate(marc:subfield[@code='a'],'()',''), true())"/><xsl:value-of select="$TracingQuotesRight"/></xsl:attribute>
             </xsl:otherwise>
             </xsl:choose>
+
             <xsl:call-template name="chopPunctuation">
                 <xsl:with-param name="chopString">
                     <xsl:call-template name="subfieldSelect">
                 </xsl:with-param>
             </xsl:call-template>
             </a>
+
+            <xsl:if test="marc:subfield[@code=9]">
+                <xsl:text> </xsl:text>
+                <a class='authlink'>
+                    <xsl:attribute name="href">/cgi-bin/koha/authorities/detail.pl?authid=<xsl:value-of select="str:encode-uri(marc:subfield[@code=9], true())"/></xsl:attribute>
+                    <xsl:element name="img">
+                        <xsl:attribute name="src">/intranet-tmpl/prog/img/filefind.png</xsl:attribute>
+                        <xsl:attribute name="alt"></xsl:attribute>
+                        <xsl:attribute name="height">15</xsl:attribute>
+                        <xsl:attribute name="width">15</xsl:attribute>
+                    </xsl:element>
+                </a>
+            </xsl:if>
+
             <xsl:choose>
             <xsl:when test="position()=last()"></xsl:when>
             <xsl:otherwise> | </xsl:otherwise>
                     <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:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="str:encode-uri(marc:subfield[@code=9], true())"/></xsl:attribute>
                             </xsl:when>
                             <xsl:when test="$TraceSubjectSubdivisions='1'">
                                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:call-template name="subfieldSelect">
                                     <xsl:with-param name="delimeter"> AND </xsl:with-param>
                                     <xsl:with-param name="prefix">(su<xsl:value-of select="$SubjectModifier"/>:<xsl:value-of select="$TracingQuotesLeft"/></xsl:with-param>
                                     <xsl:with-param name="suffix"><xsl:value-of select="$TracingQuotesRight"/>)</xsl:with-param>
+                                    <xsl:with-param name="urlencode">1</xsl:with-param>
                                 </xsl:call-template>
                                 </xsl:attribute>
                             </xsl:when>
                         <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
                     </xsl:call-template>
                     </a>
+
+                    <xsl:if test="marc:subfield[@code=9]">
+                        <xsl:text> </xsl:text>
+                        <a class='authlink'>
+                            <xsl:attribute name="href">/cgi-bin/koha/authorities/detail.pl?authid=<xsl:value-of select="str:encode-uri(marc:subfield[@code=9], true())"/></xsl:attribute>
+                            <xsl:element name="img">
+                                <xsl:attribute name="src">/intranet-tmpl/prog/img/filefind.png</xsl:attribute>
+                                <xsl:attribute name="alt"></xsl:attribute>
+                                <xsl:attribute name="height">15</xsl:attribute>
+                                <xsl:attribute name="width">15</xsl:attribute>
+                            </xsl:element>
+                        </a>
+                    </xsl:if>
                     <xsl:if test="position()!=last()"><span class="separator"> | </span></xsl:if>
                 </xsl:for-each>
             </span>
         </xsl:if>
 
+<!-- MARC21 776 Additional Physical Form Entry -->
+    <xsl:if test="marc:datafield[@tag=776]">
+        <span class="results_summary add_physical_form">
+            <span class="label">Additional physical formats: </span>
+            <xsl:for-each select="marc:datafield[@tag=776]">
+                <xsl:variable name="linktext">
+                    <xsl:choose>
+                    <xsl:when test="marc:subfield[@code='t']">
+                        <xsl:value-of select="marc:subfield[@code='t']"/>
+                    </xsl:when>
+                    <xsl:when test="marc:subfield[@code='a']">
+                        <xsl:value-of select="marc:subfield[@code='a']"/>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:text>No title</xsl:text>
+                    </xsl:otherwise>
+                    </xsl:choose>
+                </xsl:variable>
+                <xsl:if test="@ind2=8 and marc:subfield[@code='i']">
+                    <xsl:call-template name="subfieldSelect">
+                        <xsl:with-param name="codes">i</xsl:with-param>
+                    </xsl:call-template>
+                    <xsl:text>: </xsl:text>
+                </xsl:if>
+                <xsl:choose>
+                <xsl:when test="marc:subfield[@code='w']">
+                    <a>
+                    <xsl:attribute name="href">
+                        <xsl:text>/cgi-bin/koha/catalogue/search.pl?q=control-number:</xsl:text>
+                        <xsl:call-template name="extractControlNumber">
+                            <xsl:with-param name="subfieldW">
+                                <xsl:value-of select="marc:subfield[@code='w']"/>
+                            </xsl:with-param>
+                        </xsl:call-template>
+                    </xsl:attribute>
+                    <xsl:value-of select="$linktext"/>
+                    </a>
+                </xsl:when>
+                <xsl:otherwise>
+                    <xsl:value-of select="$linktext"/>
+                </xsl:otherwise>
+                </xsl:choose>
+                <xsl:if test="position() != last()">
+                    <xsl:text>; </xsl:text>
+                </xsl:if>
+            </xsl:for-each>
+        </span>
+    </xsl:if>
+
 <!-- DDC classification -->
     <xsl:if test="marc:datafield[@tag=082]">
         <span class="results_summary ddc">
         </span>
     </xsl:if>
 
-        <xsl:if test="marc:datafield[@tag=856]">
+<!-- Other classification -->
+    <xsl:if test="marc:datafield[@tag=084]">
+       <span class="results_summary oc">
+           <span class="label">Other classification: </span>
+          <xsl:for-each select="marc:datafield[@tag=084]">
+                <xsl:call-template name="subfieldSelect">
+                   <xsl:with-param name="codes">a</xsl:with-param>
+                   <xsl:with-param name="delimeter"><xsl:text> | </xsl:text></xsl:with-param>
+                </xsl:call-template>
+                <xsl:choose>
+                   <xsl:when test="position()=last()"><xsl:text>  </xsl:text></xsl:when>
+                   <xsl:otherwise> | </xsl:otherwise>
+                </xsl:choose>
+          </xsl:for-each>
+       </span>
+    </xsl:if>
+
+    <xsl:if test="marc:datafield[@tag=856]">
         <span class="results_summary online_resources"><span class="label">Online resources: </span>
         <xsl:for-each select="marc:datafield[@tag=856]">
-                                   <xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
-                                   <a><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
-                                    <xsl:choose>
-                                    <xsl:when test="($Show856uAsImage='Details' or $Show856uAsImage='Both') and (substring($SubqText,1,6)='image/' or $SubqText='img' or $SubqText='bmp' or $SubqText='cod' or $SubqText='gif' or $SubqText='ief' or $SubqText='jpe' or $SubqText='jpeg' or $SubqText='jpg' or $SubqText='jfif' or $SubqText='png' or $SubqText='svg' or $SubqText='tif' or $SubqText='tiff' or $SubqText='ras' or $SubqText='cmx' or $SubqText='ico' or $SubqText='pnm' or $SubqText='pbm' or $SubqText='pgm' or $SubqText='ppm' or $SubqText='rgb' or $SubqText='xbm' or $SubqText='xpm' or $SubqText='xwd')">
-                                        <xsl:element name="img"><xsl:attribute name="src"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute><xsl:attribute name="alt"><xsl:value-of select="marc:subfield[@code='y']"/></xsl:attribute><xsl:attribute name="height">100</xsl:attribute></xsl:element><xsl:text></xsl:text>
-                                    </xsl:when>
-                                    <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
-                                        <xsl:call-template name="subfieldSelect">
-                                        <xsl:with-param name="codes">y3z</xsl:with-param>
-                                        </xsl:call-template>
-                                    </xsl:when>
-                                    <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
-                                        <xsl:choose>
-                                        <xsl:when test="$URLLinkText!=''">
-                                                <xsl:value-of select="$URLLinkText"/>
-                                        </xsl:when>
-                                        <xsl:otherwise>
-                                                <xsl:text>Click here to access online</xsl:text>
-                                        </xsl:otherwise>
-                                        </xsl:choose>
-                                    </xsl:when>
-                                    </xsl:choose>
-                                    </a>
-                                    <xsl:choose>
-                                    <xsl:when test="position()=last()"><xsl:text>  </xsl:text></xsl:when>
-                                    <xsl:otherwise> | </xsl:otherwise>
-                                    </xsl:choose>
+            <xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
+            <a>
+                <xsl:attribute name="href">
+                    <xsl:if test="not(contains(marc:subfield[@code='u'],'://'))">
+                        <xsl:choose>
+                            <xsl:when test="@ind1=7">
+                                <xsl:value-of select="marc:subfield[@code='2']"/><xsl:text>://</xsl:text>
+                            </xsl:when>
+                            <xsl:when test="@ind1=1">
+                                <xsl:text>ftp://</xsl:text>
+                            </xsl:when>
+                            <xsl:otherwise>
+                                <xsl:text>http://</xsl:text>
+                            </xsl:otherwise>
+                        </xsl:choose>
+                    </xsl:if>
+                    <xsl:value-of select="marc:subfield[@code='u']"/>
+                </xsl:attribute>
+                <xsl:choose>
+                    <xsl:when test="($Show856uAsImage='Details' or $Show856uAsImage='Both') and (substring($SubqText,1,6)='image/' or $SubqText='img' or $SubqText='bmp' or $SubqText='cod' or $SubqText='gif' or $SubqText='ief' or $SubqText='jpe' or $SubqText='jpeg' or $SubqText='jpg' or $SubqText='jfif' or $SubqText='png' or $SubqText='svg' or $SubqText='tif' or $SubqText='tiff' or $SubqText='ras' or $SubqText='cmx' or $SubqText='ico' or $SubqText='pnm' or $SubqText='pbm' or $SubqText='pgm' or $SubqText='ppm' or $SubqText='rgb' or $SubqText='xbm' or $SubqText='xpm' or $SubqText='xwd')">
+                        <xsl:element name="img"><xsl:attribute name="src"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute><xsl:attribute name="alt"><xsl:value-of select="marc:subfield[@code='y']"/></xsl:attribute><xsl:attribute name="height">100</xsl:attribute></xsl:element><xsl:text></xsl:text>
+                    </xsl:when>
+                    <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
+                        <xsl:call-template name="subfieldSelect">
+                            <xsl:with-param name="codes">y3z</xsl:with-param>
+                        </xsl:call-template>
+                    </xsl:when>
+                    <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
+                        <xsl:choose>
+                            <xsl:when test="$URLLinkText!=''">
+                                <xsl:value-of select="$URLLinkText"/>
+                            </xsl:when>
+                            <xsl:otherwise>
+                                <xsl:text>Click here to access online</xsl:text>
+                            </xsl:otherwise>
+                        </xsl:choose>
+                    </xsl:when>
+                </xsl:choose>
+            </a>
+            <xsl:choose>
+                <xsl:when test="position()=last()"><xsl:text>  </xsl:text></xsl:when>
+                <xsl:otherwise> | </xsl:otherwise>
+            </xsl:choose>
 
         </xsl:for-each>
         </span>
-        </xsl:if>
+    </xsl:if>
+
         <xsl:if test="marc:datafield[@tag=505]">
             <div class="results_summary contents">
             <xsl:choose>
             </span>
         </xsl:if>
 
+         <!-- 583 -->
+             <xsl:if test="marc:datafield[@tag=583]">
+                 <xsl:for-each select="marc:datafield[@tag=583]">
+                    <xsl:if test="@ind1=1 or @ind1=' '">
+                      <span class="results_summary actionnote">
+                          <span class="label">Action note: </span>
+                             <xsl:choose>
+                                 <xsl:when test="marc:subfield[@code='z']">
+                                     <xsl:value-of select="marc:subfield[@code='z']"/>
+                                 </xsl:when>
+                                 <xsl:otherwise>
+                                     <xsl:call-template name="subfieldSelect">
+                                         <xsl:with-param name="codes">abcdefgijklnou</xsl:with-param>
+                                     </xsl:call-template>
+                                 </xsl:otherwise>
+                             </xsl:choose>
+                         </span>
+                     </xsl:if>
+                 </xsl:for-each>
+             </xsl:if>
+
         <!-- 508 -->
         <xsl:if test="marc:datafield[@tag=508]">
             <div class="results_summary prod_credits">
                     <xsl:call-template name="subfieldSelectSpan">
                         <xsl:with-param name="codes">a</xsl:with-param>
                     </xsl:call-template>
+                    <xsl:if test="position()!=last()"><span class="separator"><xsl:text> | </xsl:text></span></xsl:if>
                 </xsl:for-each>
             </div>
         </xsl:if>
 
         <!-- 773 -->
         <xsl:if test="marc:datafield[@tag=773]">
-        <xsl:for-each select="marc:datafield[@tag=773]">
-        <xsl:if test="@ind1 !=1">
-        <span class="results_summary in"><span class="label">
-        <xsl:choose>
-        <xsl:when test="@ind2=' '">
-            In:
-        </xsl:when>
-        <xsl:when test="@ind2=8">
-            <xsl:if test="marc:subfield[@code='i']">
-                <xsl:value-of select="marc:subfield[@code='i']"/>
-            </xsl:if>
-        </xsl:when>
-        </xsl:choose>
-        </span>
-                <xsl:variable name="f773">
-                    <xsl:call-template name="chopPunctuation"><xsl:with-param name="chopString"><xsl:call-template name="subfieldSelect">
-                        <xsl:with-param name="codes">a_t</xsl:with-param>
-                    </xsl:call-template></xsl:with-param></xsl:call-template>
-                </xsl:variable>
-            <xsl:choose>
-                <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
-                    <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
-                        <xsl:value-of select="translate($f773, '()', '')"/>
-                    </a>
-                    <xsl:if test="marc:subfield[@code='g']"><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='g']"/></xsl:if>
-                </xsl:when>
-                <xsl:when test="marc:subfield[@code='0']">
-                    <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/detail.pl?biblionumber=<xsl:value-of select="marc:subfield[@code='0']"/></xsl:attribute>
-                        <xsl:value-of select="$f773"/>
-                    </a>
-                </xsl:when>
-                <xsl:otherwise>
-                    <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="translate($f773, '()', '')"/></xsl:attribute>
-                        <xsl:value-of select="$f773"/>
-                    </a>
-                    <xsl:if test="marc:subfield[@code='g']"><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='g']"/></xsl:if>
-                </xsl:otherwise>
-            </xsl:choose>
-        </span>
+            <xsl:for-each select="marc:datafield[@tag=773]">
+                <xsl:if test="@ind1 !=1">
+                    <span class="results_summary in"><span class="label">
+                    <xsl:choose>
+                        <xsl:when test="@ind2=' '">
+                            In:
+                        </xsl:when>
+                        <xsl:when test="@ind2=8">
+                            <xsl:if test="marc:subfield[@code='i']">
+                                <xsl:value-of select="marc:subfield[@code='i']"/>
+                            </xsl:if>
+                        </xsl:when>
+                    </xsl:choose>
+                    </span>
+                    <xsl:variable name="f773">
+                        <xsl:call-template name="chopPunctuation">
+                            <xsl:with-param name="chopString">
+                                <xsl:call-template name="subfieldSelect">
+                                    <xsl:with-param name="codes">a_t</xsl:with-param>
+                                </xsl:call-template>
+                            </xsl:with-param>
+                        </xsl:call-template>
+                    </xsl:variable>
+                    <xsl:choose>
+                        <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
+                            <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
+                            <xsl:value-of select="translate($f773, '()', '')"/>
+                            </a>
+                        </xsl:when>
+                        <xsl:when test="marc:subfield[@code='0']">
+                            <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/detail.pl?biblionumber=<xsl:value-of select="str:encode-uri(marc:subfield[@code='0'], true())"/></xsl:attribute>
+                            <xsl:value-of select="$f773"/>
+                            </a>
+                        </xsl:when>
+                        <xsl:otherwise>
+                            <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="str:encode-uri(translate($f773, '()', ''), true())"/></xsl:attribute>
+                            <xsl:value-of select="$f773"/>
+                            </a>
+                        </xsl:otherwise>
+                    </xsl:choose>
+                    <xsl:if test="marc:subfield[@code='g']">
+                        <xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='g']"/>
+                    </xsl:if>
+                    </span>
 
-        <xsl:if test="marc:subfield[@code='n']">
-            <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
-        </xsl:if>
+                    <xsl:if test="marc:subfield[@code='n']">
+                        <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
+                    </xsl:if>
 
-        </xsl:if>
-        </xsl:for-each>
+                </xsl:if>
+            </xsl:for-each>
         </xsl:if>
 
         <xsl:if test="marc:datafield[@tag=502]">
                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
             </xsl:when>
             <xsl:otherwise>
-                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="translate($f775, '()', '')"/></xsl:attribute>
+                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="str:encode-uri(translate($f775, '()', ''), true())"/></xsl:attribute>
             </xsl:otherwise>
             </xsl:choose>
             <xsl:call-template name="subfieldSelect">
                     </a>
                 </xsl:when>
                 <xsl:otherwise>
-                    <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="translate($f780, '()', '')"/></xsl:attribute>
+                    <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="str:encode-uri(translate($f780, '()', ''), true())"/></xsl:attribute>
                         <xsl:value-of select="translate($f780, '()', '')"/>
                     </a>
                 </xsl:otherwise>
                     </a>
                 </xsl:when>
                 <xsl:otherwise>
-                    <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="translate($f785, '()', '')"/></xsl:attribute>
+                    <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="str:encode-uri(translate($f785, '()', ''), true())"/></xsl:attribute>
                         <xsl:value-of select="translate($f785, '()', '')"/>
                     </a>
                 </xsl:otherwise>
 
         <xsl:if test="$OPACBaseURL!=''">
         <span class="results_summary"><span class="label">OPAC view: </span>
-            <a><xsl:attribute name="href"><xsl:value-of select="$OPACBaseURL"/>/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="marc:datafield[@tag=999]/marc:subfield[@code='c']"/></xsl:attribute><xsl:attribute name="target">_blank</xsl:attribute>Open in new window</a>.
+            <a><xsl:attribute name="href"><xsl:value-of select="$OPACBaseURL"/>/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="str:encode-uri(marc:datafield[@tag=999]/marc:subfield[@code='c'], true())"/></xsl:attribute><xsl:attribute name="target">_blank</xsl:attribute>Open in new window</a>.
         </span>
         </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:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="str:encode-uri(marc:subfield[@code=9], true())"/></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:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=au:"<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>"</xsl:attribute>
             </xsl:otherwise>
         </xsl:choose>
-       <xsl:choose>
-           <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:variable name="str">
-                   <xsl:call-template name="subfieldSelect">
-                       <xsl:with-param name="codes">abcdfghiklmnoprstux</xsl:with-param>
-                   </xsl:call-template>
-               </xsl:variable>
-               <xsl:call-template name="chopPunctuation">
-                   <xsl:with-param name="chopString">
-                       <xsl:value-of select="$str"/>
-                   </xsl:with-param>
-                   <xsl:with-param name="punctuation">
-                       <xsl:text>:,;/. </xsl:text>
-                   </xsl:with-param>
-               </xsl:call-template>
-           </xsl:when>
-       </xsl:choose>
-
-       <!-- add relator code too between brackets-->
+        <xsl:choose>
+            <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, Display only name portion in 1XX -->
+                                    <xsl:when test="@tag=111">aeq</xsl:when>
+                                    <xsl:when test="@tag=110">ab</xsl:when>
+                                    <xsl:otherwise>abcjq</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>
+                    <!-- Display only name and title portion in 110 field -->
+                    <xsl:if test="@tag=110 and boolean(marc:subfield[@code='c' or @code='d' or @code='n' or @code='t'])">
+                    <span class="titleportion">
+                    <xsl:choose>
+                        <xsl:when test="marc:subfield[@code='c' or @code='d' or @code='n'][not(marc:subfield[@code='t'])]"><xsl:text> </xsl:text></xsl:when>
+                        <xsl:otherwise><xsl:text>. </xsl:text></xsl:otherwise>
+                    </xsl:choose>
+                    <xsl:call-template name="chopPunctuation">
+                        <xsl:with-param name="chopString">
+                        <xsl:call-template name="subfieldSelect">
+                            <xsl:with-param name="codes">cdnt</xsl:with-param>
+                        </xsl:call-template>
+                        </xsl:with-param>
+                    </xsl:call-template>
+                    </span>
+                    </xsl:if>
+                    <!-- Display only name and title portion in 111 field -->
+            <xsl:if test="@tag=111 and boolean(marc:subfield[@code='c' or @code='d' or @code='g' or @code='n' or @code='t'])">
+                    <span class="titleportion">
+                    <xsl:choose>
+                        <xsl:when test="marc:subfield[@code='c' or @code='d' or @code='g' or @code='n'][not(marc:subfield[@code='t'])]"><xsl:text> </xsl:text></xsl:when>
+                        <xsl:otherwise><xsl:text>. </xsl:text></xsl:otherwise>
+                    </xsl:choose>
+
+                    <xsl:call-template name="chopPunctuation">
+                        <xsl:with-param name="chopString">
+                        <xsl:call-template name="subfieldSelect">
+                            <xsl:with-param name="codes">cdgnt</xsl:with-param>
+                        </xsl:call-template>
+                        </xsl:with-param>
+                    </xsl:call-template>
+                    </span>
+            </xsl:if>
+            <!-- Display only dates in 100 field -->
+            <xsl:if test="@tag=100 and marc:subfield[@code='d']">
+                <span class="authordates">
+                <xsl:text>, </xsl:text>
+                <xsl:call-template name="chopPunctuation">
+                    <xsl:with-param name="chopString">
+                        <xsl:call-template name="subfieldSelect">
+                           <xsl:with-param name="codes">d</xsl:with-param>
+                        </xsl:call-template>
+                        </xsl:with-param>
+                    </xsl:call-template>
+                    </span>
+            </xsl:if>
+
+            </xsl:when>
+            <!-- #13382 excludes 700$i and ind2=2, displayed as Related Works -->
+            <!--#13382 Added all relevant subfields 4, e, and d are handled separately -->
+            <xsl:when test="@tag=700 or @tag=710 or @tag=711">
+                    <!-- Includes major changes for 7XX fields; display name portion in 710 and 711 fields -->
+                    <xsl:if test="@tag=710 or @tag=711">
+                    <xsl:call-template name="chopPunctuation">
+                        <xsl:with-param name="chopString">
+                            <xsl:call-template name="subfieldSelect">
+                            <xsl:with-param name="codes">
+                            <xsl:choose>
+                                <xsl:when test="@tag=711">aeq</xsl:when>
+                                <xsl:otherwise>ab</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>
+                    <!-- Display only name and title portion in 711 field -->
+                    <xsl:if test="@tag=711 and boolean(marc:subfield[@code='c' or @code='d' or @code='g' or @code='n' or @code='t'])">
+                    <span class="titleportion">
+                    <xsl:choose>
+                        <xsl:when test="marc:subfield[@code='c' or @code='d' or @code='g' or @code='n'][not(marc:subfield[@code='t'])]"><xsl:text> </xsl:text></xsl:when>
+                        <xsl:otherwise><xsl:text>. </xsl:text></xsl:otherwise>
+                    </xsl:choose>
+
+                    <xsl:call-template name="chopPunctuation">
+                        <xsl:with-param name="chopString">
+                        <xsl:call-template name="subfieldSelect">
+                            <xsl:with-param name="codes">cdgnt</xsl:with-param>
+                        </xsl:call-template>
+                        </xsl:with-param>
+                    </xsl:call-template>
+                    </span>
+                    </xsl:if>
+                    <!-- Display only name and title portion in 710 field -->
+                    <xsl:if test="@tag=710 and boolean(marc:subfield[@code='c' or @code='d' or @code='n' or @code='t'])">
+                    <span class="titleportion">
+                    <xsl:choose>
+                        <xsl:when test="marc:subfield[@code='c' or @code='d' or @code='n'][not(marc:subfield[@code='t'])]"><xsl:text> </xsl:text></xsl:when>
+                        <xsl:otherwise><xsl:text>. </xsl:text></xsl:otherwise>
+                    </xsl:choose>
+                    <xsl:call-template name="chopPunctuation">
+                        <xsl:with-param name="chopString">
+                        <xsl:call-template name="subfieldSelect">
+                            <xsl:with-param name="codes">cdnt</xsl:with-param>
+                        </xsl:call-template>
+                        </xsl:with-param>
+                    </xsl:call-template>
+                    </span>
+                    </xsl:if>
+
+                    </xsl:if>
+                        <!-- Display only name portion in 700 field -->
+                        <xsl:if test="@tag=700">
+                           <xsl:call-template name="chopPunctuation">
+                               <xsl:with-param name="chopString">
+                               <xsl:call-template name="subfieldSelect">
+                                  <xsl:with-param name="codes">abcq</xsl:with-param>
+                               </xsl:call-template>
+                               </xsl:with-param>
+                        </xsl:call-template>
+                        </xsl:if>
+                        <!-- Display class "authordates" in 700 field -->
+                        <xsl:if test="@tag=700 and marc:subfield[@code='d']">
+                        <span class="authordates">
+                        <xsl:text>, </xsl:text>
+                        <xsl:call-template name="chopPunctuation">
+                            <xsl:with-param name="chopString">
+                            <xsl:call-template name="subfieldSelect">
+                               <xsl:with-param name="codes">d</xsl:with-param>
+                            </xsl:call-template>
+                            </xsl:with-param>
+                        </xsl:call-template>
+                        </span>
+                        </xsl:if>
+                        <!-- Display class "titleportion" in 700 field -->
+                        <xsl:variable name="titleportionfields" select="boolean(marc:subfield[@code='t' or @code='j' or @code='k' or @code='u'])"/>
+                        <xsl:if test="@tag=700 and $titleportionfields">
+                        <span class="titleportion">
+                        <xsl:text>. </xsl:text>
+                        <xsl:call-template name="chopPunctuation">
+                            <xsl:with-param name="chopString">
+                            <xsl:call-template name="subfieldSelect">
+                                <xsl:with-param name="codes">fghjklmnoprstux</xsl:with-param>
+                            </xsl:call-template>
+                            </xsl:with-param>
+                        </xsl:call-template>
+                        </span>
+                        </xsl:if>
+
+        </xsl:when>
+        </xsl:choose>
+
+    <!-- add relator code too between brackets-->
     <!-- #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'][. != ''])">
+            <xsl:if test="(@tag!=111 and @tag!=711 and marc:subfield[@code='4' or @code='e']) or ((@tag=111 or @tag=711) and marc:subfield[@code='4' or @code='j'])">
                 <span class="relatorcode">
                     <xsl:text> [</xsl:text>
                     <xsl:choose>
-                        <xsl:when test="@tag=111">
+                        <xsl:when test="@tag=111 or @tag=711">
                             <xsl:choose>
-                                <!-- Prefer j over 4 -->
+                                <!-- Prefer j over 4 for fields 111 and 711-->
                                 <xsl:when test="marc:subfield[@code='j']">
                                     <xsl:for-each select="marc:subfield[@code='j']">
                                         <xsl:value-of select="."/>
                                 </xsl:otherwise>
                             </xsl:choose>
                         </xsl:when>
-                        <!-- Prefer e over 4 -->
-                        <xsl:when test="marc:subfield[@code='e']">
+                        <!-- Prefer e over 4 for fields 111 and 711-->
+                        <xsl:when test="marc:subfield[@code='e'][not(@tag=111) or not(@tag=711)]">
                             <xsl:for-each select="marc:subfield[@code='e']">
                                 <xsl:value-of select="."/>
                                 <xsl:if test="position() != last()">, </xsl:if>
                     <xsl:text>]</xsl:text>
                 </span>
             </xsl:if>
-       </a>
+        </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>
         </xsl:choose>
         <xsl:param name="subdivDelimiter"/>
         <xsl:param name="prefix"/>
         <xsl:param name="suffix"/>
+        <xsl:param name="urlencode"/>
         <xsl:variable name="str">
             <xsl:for-each select="marc:subfield">
                 <xsl:if test="contains($codes, @code)">
                 </xsl:if>
             </xsl:for-each>
         </xsl:variable>
-        <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
+        <xsl:choose>
+            <xsl:when test="$urlencode=1">
+                <xsl:value-of select="str:encode-uri(substring($str,1,string-length($str)-string-length($delimeter)), true())"/>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
+            </xsl:otherwise>
+        </xsl:choose>
     </xsl:template>
 
 </xsl:stylesheet>