"Fossies" - the Fresh Open Source Software Archive

Member "koha-19.11.15/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslimUtils.xsl" (23 Feb 2021, 15644 Bytes) of package /linux/misc/koha-19.11.15.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) XML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "UNIMARCslimUtils.xsl": 20.11.02_vs_20.11.03.

    1 <?xml version='1.0'?>
    2 
    3 <!DOCTYPE stylesheet [<!ENTITY nbsp "&#160;" >]>
    4 
    5 <xsl:stylesheet version="1.0"
    6   xmlns:marc="http://www.loc.gov/MARC21/slim"
    7   xmlns:items="http://www.koha-community.org/items"
    8   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    9   xmlns:str="http://exslt.org/strings"
   10   exclude-result-prefixes="marc items str">
   11 
   12   <xsl:template name="datafield">
   13     <xsl:param name="tag"/>
   14     <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
   15     <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
   16     <xsl:param name="subfields"/>
   17     <xsl:element name="datafield">
   18       <xsl:attribute name="tag">
   19         <xsl:value-of select="$tag"/>
   20       </xsl:attribute>
   21       <xsl:attribute name="ind1">
   22         <xsl:value-of select="$ind1"/>
   23       </xsl:attribute>
   24       <xsl:attribute name="ind2">
   25        <xsl:value-of select="$ind2"/>
   26          </xsl:attribute>
   27        <xsl:copy-of select="$subfields"/>
   28     </xsl:element>
   29   </xsl:template>
   30 
   31   <xsl:template name="subfieldSelect">
   32     <xsl:param name="codes"/>
   33     <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
   34     <xsl:param name="subdivCodes"/>
   35     <xsl:param name="subdivDelimiter"/>
   36     <xsl:param name="urlencode"/>
   37     <xsl:variable name="str">
   38       <xsl:for-each select="marc:subfield">
   39         <xsl:if test="contains($codes, @code)">
   40           <xsl:if test="contains($subdivCodes, @code)">
   41             <xsl:value-of select="$subdivDelimiter"/>
   42           </xsl:if>
   43           <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>
   44         </xsl:if>
   45       </xsl:for-each>
   46     </xsl:variable>
   47     <xsl:choose>
   48       <xsl:when test="$urlencode=1">
   49         <xsl:value-of select="str:encode-uri(substring($str,1,string-length($str)-string-length($delimeter)), true())"/>
   50       </xsl:when>
   51       <xsl:otherwise>
   52         <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
   53       </xsl:otherwise>
   54     </xsl:choose>
   55   </xsl:template>
   56 
   57   <xsl:template name="buildSpaces">
   58     <xsl:param name="spaces"/>
   59     <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
   60     <xsl:if test="$spaces>0">
   61       <xsl:value-of select="$char"/>
   62       <xsl:call-template name="buildSpaces">
   63         <xsl:with-param name="spaces" select="$spaces - 1"/>
   64         <xsl:with-param name="char" select="$char"/>
   65       </xsl:call-template>
   66     </xsl:if>
   67   </xsl:template>
   68 
   69   <xsl:template name="buildBiblioDefaultViewURL">
   70     <xsl:param name="BiblioDefaultView"/>
   71     <xsl:choose>
   72         <xsl:when test="$BiblioDefaultView='normal'">
   73             <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
   74         </xsl:when>
   75         <xsl:when test="$BiblioDefaultView='isbd'">
   76             <xsl:text>/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=</xsl:text>
   77         </xsl:when>
   78         <xsl:when test="$BiblioDefaultView='marc'">
   79             <xsl:text>/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=</xsl:text>
   80         </xsl:when>
   81         <xsl:otherwise>
   82             <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
   83         </xsl:otherwise>
   84     </xsl:choose>
   85   </xsl:template>
   86 
   87 
   88   <xsl:template name="chopPunctuation">
   89     <xsl:param name="chopString"/>
   90     <xsl:variable name="length" select="string-length($chopString)"/>
   91     <xsl:choose>
   92       <xsl:when test="$length=0"/>
   93       <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
   94         <xsl:call-template name="chopPunctuation">
   95           <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
   96         </xsl:call-template>
   97       </xsl:when>
   98       <xsl:when test="not($chopString)"/>
   99       <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
  100     </xsl:choose>
  101     <xsl:text> </xsl:text>
  102   </xsl:template>
  103 
  104   <xsl:template name="addClassRtl">
  105     <xsl:variable name="lang" select="marc:subfield[@code='7']" />
  106     <xsl:if test="$lang = 'ha' or $lang = 'Hebrew' or $lang = 'fa' or $lang = 'Arabe'">
  107       <xsl:attribute name="class">rtl</xsl:attribute>
  108     </xsl:if>
  109   </xsl:template>
  110 
  111   <xsl:template name="tag_title">
  112     <xsl:param name="tag" />
  113     <xsl:param name="label" />
  114     <xsl:param name="spanclass" />
  115     <xsl:if test="marc:datafield[@tag=$tag]">
  116       <span class="results_summary {$spanclass}">
  117         <span class="label">
  118           <xsl:value-of select="$label"/>
  119           <xsl:text>: </xsl:text>
  120         </span>
  121         <xsl:for-each select="marc:datafield[@tag=$tag]">
  122           <xsl:call-template name="addClassRtl" />
  123           <xsl:for-each select="marc:subfield">
  124             <xsl:choose>
  125               <xsl:when test="@code='a'">
  126                 <xsl:variable name="title" select="."/>
  127                 <xsl:variable name="ntitle"
  128                  select="translate($title, '&#x0088;&#x0089;&#x0098;&#x009C;','')"/>
  129                 <xsl:value-of select="$ntitle" />
  130               </xsl:when>
  131               <xsl:when test="@code='b'">
  132                 <xsl:text>[</xsl:text>
  133                 <xsl:value-of select="."/>
  134                 <xsl:text>]</xsl:text>
  135               </xsl:when>
  136               <xsl:when test="@code='d'">
  137                 <xsl:text> = </xsl:text>
  138                 <xsl:value-of select="."/>
  139               </xsl:when>
  140               <xsl:when test="@code='e'">
  141                 <xsl:text> : </xsl:text>
  142                 <xsl:value-of select="."/>
  143               </xsl:when>
  144               <xsl:when test="@code='f'">
  145                 <xsl:text> / </xsl:text>
  146                 <xsl:value-of select="."/>
  147               </xsl:when>
  148               <xsl:when test="@code='g'">
  149                 <xsl:text> ; </xsl:text>
  150                 <xsl:value-of select="."/>
  151               </xsl:when>
  152               <xsl:otherwise>
  153                 <xsl:if test="position()>1">
  154                   <xsl:text>, </xsl:text>
  155                 </xsl:if>
  156                 <xsl:value-of select="."/>
  157               </xsl:otherwise>
  158             </xsl:choose>
  159           </xsl:for-each>
  160           <xsl:if test="not (position() = last())">
  161             <xsl:text></xsl:text>
  162           </xsl:if>
  163         </xsl:for-each>
  164       </span>
  165     </xsl:if>
  166   </xsl:template>
  167 
  168   <xsl:template name="tag_comma">
  169     <xsl:param name="tag" />
  170     <xsl:param name="label" />
  171     <xsl:param name="spanclass" />
  172     <xsl:if test="marc:datafield[@tag=$tag]">
  173       <span class="results_summary {$spanclass}">
  174         <span class="label">
  175         <xsl:value-of select="$label"/>: </span>
  176         <xsl:for-each select="marc:datafield[@tag=$tag]">
  177           <xsl:call-template name="addClassRtl" />
  178           <xsl:for-each select="marc:subfield">
  179             <xsl:if test="position()>1">
  180               <xsl:text>, </xsl:text>
  181             </xsl:if>
  182             <xsl:value-of select="."/>
  183           </xsl:for-each>
  184           <xsl:if test="not (position() = last())">
  185             <xsl:text></xsl:text>
  186           </xsl:if>
  187         </xsl:for-each>
  188       </span>
  189     </xsl:if>
  190   </xsl:template>
  191 
  192   <xsl:template name="tag_210">
  193     <span class="results_summary publication">
  194       <span class="label">Publication: </span>
  195       <xsl:for-each select="marc:datafield[@tag=210]">
  196         <span>
  197           <xsl:call-template name="addClassRtl" />
  198           <xsl:for-each select="marc:subfield">
  199             <xsl:choose>
  200               <xsl:when test="@code='c' or @code='g'">
  201                 <xsl:if test="position()>1">
  202                   <xsl:text> : </xsl:text>
  203                 </xsl:if>
  204                 <xsl:value-of select="."/>
  205               </xsl:when>
  206               <xsl:otherwise>
  207                 <xsl:if test="position()>1">
  208                   <xsl:text>, </xsl:text>
  209                 </xsl:if>
  210                 <xsl:value-of select="."/>
  211               </xsl:otherwise>
  212             </xsl:choose>
  213           </xsl:for-each>
  214           <xsl:if test="not (position() = last())">
  215             <xsl:text></xsl:text>
  216           </xsl:if>
  217         </span>
  218       </xsl:for-each>
  219     </span>
  220   </xsl:template>
  221 
  222   <xsl:template name="tag_215">
  223     <xsl:for-each select="marc:datafield[@tag=215]">
  224       <span class="results_summary description">
  225         <span class="label">Description: </span>
  226         <xsl:if test="marc:subfield[@code='a']">
  227           <xsl:value-of select="marc:subfield[@code='a']"/>
  228         </xsl:if>
  229         <xsl:if test="marc:subfield[@code='c']"> :
  230           <xsl:value-of select="marc:subfield[@code='c']"/>
  231         </xsl:if>
  232         <xsl:if test="marc:subfield[@code='d']"> ;
  233           <xsl:value-of select="marc:subfield[@code='d']"/>
  234         </xsl:if>
  235         <xsl:if test="marc:subfield[@code='e']"> +
  236           <xsl:value-of select="marc:subfield[@code='e']"/>
  237         </xsl:if>
  238       </span>
  239     </xsl:for-each>
  240   </xsl:template>
  241 
  242   <xsl:template name="tag_onesubject">
  243     <xsl:choose>
  244       <xsl:when test="marc:subfield[@code=9]">
  245         <xsl:for-each select="marc:subfield">
  246           <xsl:if test="@code='9'">
  247             <xsl:variable name="start" select="position()"/>
  248             <xsl:variable name="ends">
  249               <xsl:for-each select="../marc:subfield[position() &gt; $start]">
  250                 <xsl:if test="@code=9">
  251                   <xsl:variable name="end" select="position() + $start"/>
  252                   <xsl:value-of select="$end"/>
  253                   <xsl:text>,</xsl:text>
  254                 </xsl:if>
  255               </xsl:for-each>
  256             </xsl:variable>
  257             <xsl:variable name="end">
  258               <xsl:choose>
  259                 <xsl:when test="string-length($ends) > 0">
  260                   <xsl:value-of select="substring-before($ends,',')"/>
  261                 </xsl:when>
  262                 <xsl:otherwise>
  263                   <xsl:text>1000</xsl:text>
  264                 </xsl:otherwise>
  265               </xsl:choose>
  266             </xsl:variable>
  267             <xsl:variable name="display">
  268               <xsl:for-each select="../marc:subfield[position() &gt; $start and position() &lt; $end and @code!=2 and @code!=3]">
  269                 <xsl:value-of select="."/>
  270                 <xsl:if test="not(position()=last())">
  271                   <xsl:text>, </xsl:text>
  272                 </xsl:if>
  273               </xsl:for-each>
  274             </xsl:variable>
  275             <a>
  276               <xsl:attribute name="href">
  277                 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
  278                 <xsl:value-of select="str:encode-uri(., true())"/>
  279               </xsl:attribute>
  280               <xsl:choose>
  281                 <xsl:when test="string-length($display) &gt; 0">
  282                   <xsl:call-template name="chopPunctuation">
  283                     <xsl:with-param name="chopString">
  284                       <xsl:value-of select="$display"/>
  285                     </xsl:with-param>
  286                   </xsl:call-template>
  287                 </xsl:when>
  288                 <xsl:otherwise>
  289                   <xsl:value-of select="."/>
  290                 </xsl:otherwise>
  291               </xsl:choose>
  292             </a>
  293             <xsl:variable name="ncommas"
  294                  select="string-length($ends) - string-length(translate($ends, ',', ''))" />
  295             <xsl:if test="$ncommas &gt; 1">
  296               <xsl:text> -- </xsl:text>
  297             </xsl:if>
  298           </xsl:if>
  299         </xsl:for-each>
  300       </xsl:when>
  301       <xsl:when test="marc:subfield[@code='a']">
  302         <a>
  303           <xsl:attribute name="href">
  304             <xsl:text>/cgi-bin/koha/opac-search.pl?q=su:</xsl:text>
  305             <xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>
  306           </xsl:attribute>
  307           <xsl:call-template name="chopPunctuation">
  308             <xsl:with-param name="chopString">
  309               <xsl:call-template name="subfieldSelect">
  310                 <xsl:with-param name="codes">abcdfijkmnptvxyz</xsl:with-param>
  311                 <xsl:with-param name="subdivCodes">ijknpxyz</xsl:with-param>
  312                 <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
  313               </xsl:call-template>
  314             </xsl:with-param>
  315           </xsl:call-template>
  316         </a>
  317       </xsl:when>
  318       <xsl:otherwise/>
  319     </xsl:choose>
  320     <xsl:if test="not(position()=last())">
  321       <xsl:text> | </xsl:text>
  322     </xsl:if>
  323   </xsl:template>
  324 
  325   <xsl:template name="tag_subject">
  326     <xsl:param name="tag" />
  327     <xsl:param name="label" />
  328     <xsl:param name="spanclass" />
  329     <xsl:if test="marc:datafield[@tag=$tag]">
  330       <span class="results_summary subjects {$spanclass}">
  331         <span class="label">
  332           <xsl:value-of select="$label"/>
  333           <xsl:text>: </xsl:text>
  334         </span>
  335         <span class="value">
  336           <xsl:for-each select="marc:datafield[@tag=$tag]">
  337             <xsl:call-template name="tag_onesubject">
  338             </xsl:call-template>
  339           </xsl:for-each>
  340         </span>
  341       </span>
  342     </xsl:if>
  343   </xsl:template>
  344 
  345   <xsl:template name="tag_7xx">
  346     <xsl:param name="tag" />
  347     <xsl:param name="label" />
  348     <xsl:param name="spanclass" />
  349     <xsl:variable name="IdRef" select="marc:sysprefs/marc:syspref[@name='IdRef']"/>
  350     <xsl:if test="marc:datafield[@tag=$tag]">
  351       <span class="results_summary author {$spanclass}">
  352         <span class="label">
  353           <xsl:value-of select="$label" />
  354           <xsl:text>: </xsl:text>
  355         </span>
  356         <span class="value">
  357           <xsl:for-each select="marc:datafield[@tag=$tag]">
  358             <a>
  359               <xsl:choose>
  360                 <xsl:when test="marc:subfield[@code=9]">
  361                   <xsl:attribute name="href">
  362                     <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
  363                     <xsl:value-of select="str:encode-uri(marc:subfield[@code=9], true())"/>
  364                   </xsl:attribute>
  365                 </xsl:when>
  366                 <xsl:otherwise>
  367                   <xsl:attribute name="href">
  368                     <xsl:text>/cgi-bin/koha/opac-search.pl?q=au:</xsl:text>
  369                     <xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>
  370                     <xsl:text>%20</xsl:text>
  371                     <xsl:value-of select="str:encode-uri(marc:subfield[@code='b'], true())"/>
  372                   </xsl:attribute>
  373                 </xsl:otherwise>
  374               </xsl:choose>
  375               <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='4' or @code='c' or @code='d' or @code='f' or @code='g' or @code='p']">
  376                 <xsl:choose>
  377                   <xsl:when test="@code='9'">
  378                   </xsl:when>
  379                   <xsl:otherwise>
  380                     <xsl:value-of select="."/>
  381                   </xsl:otherwise>
  382                 </xsl:choose>
  383                 <xsl:if test="not(position() = last())">
  384                   <xsl:text>, </xsl:text>
  385                 </xsl:if>
  386               </xsl:for-each>
  387             </a>
  388             <xsl:if test="$IdRef = '1'">
  389               <xsl:if test="marc:subfield[@code=3]">
  390                 <xsl:text> </xsl:text>
  391                 <a>
  392                   <xsl:attribute name="href">
  393                     <xsl:text>/cgi-bin/koha/opac-idref.pl?unimarc3=</xsl:text>
  394                     <xsl:value-of select="str:encode-uri(marc:subfield[@code=3], true())"/>
  395                   </xsl:attribute>
  396                   <xsl:attribute name="title">IdRef</xsl:attribute>
  397                   <xsl:attribute name="rel">gb_page_center[600,500]</xsl:attribute>
  398                   <xsl:text>Idref</xsl:text>
  399                 </a>
  400               </xsl:if>
  401             </xsl:if>
  402             <xsl:if test="not(position() = last())">
  403               <span style="padding: 3px;">
  404                 <xsl:text>;</xsl:text>
  405               </span>
  406             </xsl:if>
  407           </xsl:for-each>
  408         </span>
  409       </span>
  410     </xsl:if>
  411   </xsl:template>
  412 
  413 </xsl:stylesheet>