Guest User

item-view.xsl

a guest
Jun 5th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 32.62 KB | None | 0 0
  1. <!--
  2.  
  3.    The contents of this file are subject to the license and copyright
  4.    detailed in the LICENSE and NOTICE files at the root of the source
  5.    tree and available online at
  6.  
  7.    http://www.dspace.org/license/
  8.  
  9. -->
  10. <!--
  11.    Rendering specific to the item display page.
  12.  
  13.    Author: art.lowel at atmire.com
  14.    Author: lieven.droogmans at atmire.com
  15.    Author: ben at atmire.com
  16.    Author: Alexey Maslov
  17.  
  18. -->
  19.  
  20. <xsl:stylesheet
  21.    xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
  22.    xmlns:dri="http://di.tamu.edu/DRI/1.0/"
  23.    xmlns:mets="http://www.loc.gov/METS/"
  24.    xmlns:dim="http://www.dspace.org/xmlns/dspace/dim"
  25.    xmlns:xlink="http://www.w3.org/TR/xlink/"
  26.    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  27.    xmlns:atom="http://www.w3.org/2005/Atom"
  28.    xmlns:ore="http://www.openarchives.org/ore/terms/"
  29.    xmlns:oreatom="http://www.openarchives.org/ore/atom/"
  30.    xmlns="http://www.w3.org/1999/xhtml"
  31.    xmlns:xalan="http://xml.apache.org/xalan"
  32.    xmlns:encoder="xalan://java.net.URLEncoder"
  33.    xmlns:util="org.dspace.app.xmlui.utils.XSLUtils"
  34.    xmlns:jstring="java.lang.String"
  35.    xmlns:rights="http://cosimo.stanford.edu/sdr/metsrights/"
  36.    exclude-result-prefixes="xalan encoder i18n dri mets dim xlink xsl util jstring rights">
  37.  
  38.     <xsl:output indent="yes"/>
  39.  
  40.     <xsl:template name="itemSummaryView-DIM">
  41.         <!-- Generate the info about the item from the metadata section -->
  42.         <xsl:apply-templates select="./mets:dmdSec/mets:mdWrap[@OTHERMDTYPE='DIM']/mets:xmlData/dim:dim"
  43.        mode="itemSummaryView-DIM"/>
  44.  
  45.         <xsl:copy-of select="$SFXLink" />
  46.         <!-- Generate the bitstream information from the file section -->
  47.         <xsl:choose>
  48.             <xsl:when test="./mets:fileSec/mets:fileGrp[@USE='CONTENT' or @USE='ORIGINAL' or @USE='PRESERVATION']/mets:file">
  49.                 <xsl:apply-templates select="./mets:fileSec/mets:fileGrp[@USE='CONTENT' or @USE='ORIGINAL' or @USE='PRESERVATION']">
  50.                     <xsl:with-param name="context" select="."/>
  51.                     <xsl:with-param name="primaryBitstream" select="./mets:structMap[@TYPE='LOGICAL']/mets:div[@TYPE='DSpace Item']/mets:fptr/@FILEID"/>
  52.                 </xsl:apply-templates>
  53.             </xsl:when>
  54.             <!-- Special case for handling ORE resource maps stored as DSpace bitstreams -->
  55.             <xsl:when test="./mets:fileSec/mets:fileGrp[@USE='ORE']">
  56.                 <xsl:apply-templates select="./mets:fileSec/mets:fileGrp[@USE='ORE']"/>
  57.             </xsl:when>
  58.             <xsl:otherwise>
  59.                 <h2><i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-head</i18n:text></h2>
  60.         <table class="ds-table file-list">
  61.                     <tr class="ds-table-header-row">
  62.                         <th><i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-file</i18n:text></th>
  63.                         <th><i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-size</i18n:text></th>
  64.                         <th><i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-format</i18n:text></th>
  65.                         <th><i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-view</i18n:text></th>
  66.                     </tr>
  67.                     <tr>
  68.                         <td colspan="4">
  69.                             <p><i18n:text>xmlui.dri2xhtml.METS-1.0.item-no-files</i18n:text></p>
  70.                         </td>
  71.                     </tr>
  72.                 </table>
  73.             </xsl:otherwise>
  74.     </xsl:choose>
  75.         <!-- Generate the Creative Commons license information from the file section (DSpace deposit license hidden by default)-->
  76.         <xsl:apply-templates select="./mets:fileSec/mets:fileGrp[@USE='CC-LICENSE']"/>
  77.     </xsl:template>
  78.  
  79.     <xsl:template match="dim:dim" mode="itemSummaryView-DIM">
  80.         <div class="item-summary-view-metadata">
  81.             <xsl:call-template name="itemSummaryView-DIM-fields"/>
  82.         </div>
  83.     </xsl:template>
  84.  
  85.     <xsl:template name="itemSummaryView-DIM-fields">
  86.       <xsl:param name="clause" select="'1'"/>
  87.       <xsl:param name="phase" select="'even'"/>
  88.       <xsl:variable name="otherPhase">
  89.             <xsl:choose>
  90.               <xsl:when test="$phase = 'even'">
  91.                 <xsl:text>odd</xsl:text>
  92.               </xsl:when>
  93.               <xsl:otherwise>
  94.                 <xsl:text>even</xsl:text>
  95.               </xsl:otherwise>
  96.             </xsl:choose>
  97.       </xsl:variable>
  98.  
  99.       <xsl:choose>
  100.           <!-- Title row -->
  101.           <xsl:when test="$clause = 1">
  102.  
  103.               <xsl:choose>
  104.                   <xsl:when test="count(dim:field[@element='title'][not(@qualifier)]) &gt; 1">
  105.                       <!-- display first title as h1 -->
  106.                       <h1>
  107.                           <xsl:value-of select="dim:field[@element='title'][not(@qualifier)][1]/node()"/>
  108.                       </h1>
  109.                       <div class="simple-item-view-other">
  110.                           <span class="bold"><i18n:text>xmlui.dri2xhtml.METS-1.0.item-title</i18n:text>:</span>
  111.                           <span>
  112.                               <xsl:for-each select="dim:field[@element='title'][not(@qualifier)]">
  113.                                   <xsl:value-of select="./node()"/>
  114.                                   <xsl:if test="count(following-sibling::dim:field[@element='title'][not(@qualifier)]) != 0">
  115.                                       <xsl:text>; </xsl:text>
  116.                                       <br/>
  117.                                   </xsl:if>
  118.                               </xsl:for-each>
  119.                           </span>
  120.                       </div>
  121.                   </xsl:when>
  122.                   <xsl:when test="count(dim:field[@element='title'][not(@qualifier)]) = 1">
  123.                       <h1>
  124.                           <xsl:value-of select="dim:field[@element='title'][not(@qualifier)][1]/node()"/>
  125.                       </h1>
  126.                   </xsl:when>
  127.                   <xsl:otherwise>
  128.                       <h1>
  129.                           <i18n:text>xmlui.dri2xhtml.METS-1.0.no-title</i18n:text>
  130.                       </h1>
  131.                   </xsl:otherwise>
  132.               </xsl:choose>
  133.             <xsl:call-template name="itemSummaryView-DIM-fields">
  134.               <xsl:with-param name="clause" select="($clause + 1)"/>
  135.               <xsl:with-param name="phase" select="$otherPhase"/>
  136.             </xsl:call-template>
  137.           </xsl:when>
  138.  
  139.           <!-- Author(s) row -->
  140.           <xsl:when test="$clause = 2 and (dim:field[@element='contributor'][@qualifier='author'] or dim:field[@element='creator'] or dim:field[@element='contributor'])">
  141.                     <div class="simple-item-view-authors">
  142.                         <xsl:choose>
  143.                             <xsl:when test="dim:field[@element='contributor'][@qualifier='author']">
  144.                                 <xsl:for-each select="dim:field[@element='contributor'][@qualifier='author']">
  145.                                         <span>
  146.                                           <xsl:if test="@authority">
  147.                                             <xsl:attribute name="class"><xsl:text>ds-dc_contributor_author-authority</xsl:text></xsl:attribute>
  148.                                           </xsl:if>
  149.                                     <xsl:copy-of select="node()"/>
  150.                                         </span>
  151.                                     <xsl:if test="count(following-sibling::dim:field[@element='contributor'][@qualifier='author']) != 0">
  152.                                         <xsl:text>; </xsl:text>
  153.                                     </xsl:if>
  154.                                 </xsl:for-each>
  155.                             </xsl:when>
  156.                             <xsl:when test="dim:field[@element='creator']">
  157.                                 <xsl:for-each select="dim:field[@element='creator']">
  158.                                     <xsl:copy-of select="node()"/>
  159.                                     <xsl:if test="count(following-sibling::dim:field[@element='creator']) != 0">
  160.                                         <xsl:text>; </xsl:text>
  161.                                     </xsl:if>
  162.                                 </xsl:for-each>
  163.                             </xsl:when>
  164.                             <xsl:when test="dim:field[@element='contributor']">
  165.                                 <xsl:for-each select="dim:field[@element='contributor']">
  166.                                     <xsl:copy-of select="node()"/>
  167.                                     <xsl:if test="count(following-sibling::dim:field[@element='contributor']) != 0">
  168.                                         <xsl:text>; </xsl:text>
  169.                                     </xsl:if>
  170.                                 </xsl:for-each>
  171.                             </xsl:when>
  172.                             <xsl:otherwise>
  173.                                 <i18n:text>xmlui.dri2xhtml.METS-1.0.no-author</i18n:text>
  174.                             </xsl:otherwise>
  175.                         </xsl:choose>
  176.                 </div>
  177.               <xsl:call-template name="itemSummaryView-DIM-fields">
  178.                 <xsl:with-param name="clause" select="($clause + 1)"/>
  179.                 <xsl:with-param name="phase" select="$otherPhase"/>
  180.               </xsl:call-template>
  181.           </xsl:when>
  182.  
  183.           <!-- identifier.uri row -->
  184.           <xsl:when test="$clause = 3 and (dim:field[@element='identifier' and @qualifier='uri'])">
  185.                     <div class="simple-item-view-other">
  186.                     <span class="bold"><i18n:text>xmlui.dri2xhtml.METS-1.0.item-uri</i18n:text>:</span>
  187.                     <span>
  188.                         <xsl:for-each select="dim:field[@element='identifier' and @qualifier='uri']">
  189.                             <a>
  190.                                 <xsl:attribute name="href">
  191.                                     <xsl:copy-of select="./node()"/>
  192.                                 </xsl:attribute>
  193.                                 <xsl:copy-of select="./node()"/>
  194.                             </a>
  195.                             <xsl:if test="count(following-sibling::dim:field[@element='identifier' and @qualifier='uri']) != 0">
  196.                                 <br/>
  197.                             </xsl:if>
  198.                         </xsl:for-each>
  199.                     </span>
  200.                 </div>
  201.               <xsl:call-template name="itemSummaryView-DIM-fields">
  202.                 <xsl:with-param name="clause" select="($clause + 1)"/>
  203.                 <xsl:with-param name="phase" select="$otherPhase"/>
  204.               </xsl:call-template>
  205.           </xsl:when>
  206.  
  207.           <!-- identifier.catalog row -->
  208.           <xsl:when test="$clause = 4 and (dim:field[@element='identifier' and @qualifier='catalog'])">
  209.                     <div class="simple-item-view-other">
  210.                     <span class="bold"><i18n:text>xmlui.dri2xhtml.METS-1.0.item-catalog</i18n:text>:</span>
  211.                     <span>
  212.                         <xsl:for-each select="dim:field[@element='identifier' and @qualifier='catalog']">
  213.                             <a>
  214.                                 <xsl:attribute name="href">
  215.                                     <xsl:copy-of select="./node()"/>
  216.                                 </xsl:attribute>
  217.                                 <xsl:copy-of select="./node()"/>
  218.                             </a>
  219.                             <xsl:if test="count(following-sibling::dim:field[@element='identifier' and @qualifier='catalog']) != 0">
  220.                                 <br/>
  221.                             </xsl:if>
  222.                         </xsl:for-each>
  223.                     </span>
  224.                 </div>
  225.               <xsl:call-template name="itemSummaryView-DIM-fields">
  226.                 <xsl:with-param name="clause" select="($clause + 1)"/>
  227.                 <xsl:with-param name="phase" select="$otherPhase"/>
  228.               </xsl:call-template>
  229.           </xsl:when>
  230.      
  231.           <!-- identifier.call row -->
  232.           <xsl:when test="$clause = 5 and (dim:field[@element='identifier' and @qualifier='call'])">
  233.                     <div class="simple-item-view-other">
  234.                     <span class="bold"><i18n:text>xmlui.dri2xhtml.METS-1.0.item-call</i18n:text>:</span>
  235.                     <span>
  236.                         <xsl:for-each select="dim:field[@element='identifier' and @qualifier='call']">
  237.                             <xsl:copy-of select="substring(./node(),1,10)"/>
  238.                              <xsl:if test="count(following-sibling::dim:field[@element='identifier' and @qualifier='call']) != 0">
  239.                             <br/>
  240.                         </xsl:if>
  241.                         </xsl:for-each>
  242.                    </span>
  243.                    <!-- line break in display -->
  244.                <br/><br/>
  245.                 </div>
  246.               <xsl:call-template name="itemSummaryView-DIM-fields">
  247.                 <xsl:with-param name="clause" select="($clause + 1)"/>
  248.                 <xsl:with-param name="phase" select="$otherPhase"/>
  249.               </xsl:call-template>
  250.           </xsl:when>
  251.          
  252.           <!-- date.created row -->
  253.           <xsl:when test="$clause = 6 and (dim:field[@element='date' and @qualifier='created'])">
  254.                     <div class="simple-item-view-other">
  255.                     <span class="bold"><i18n:text>xmlui.dri2xhtml.METS-1.0.item-dateCreated</i18n:text>:</span>
  256.                     <span>
  257.                         <xsl:for-each select="dim:field[@element='date' and @qualifier='created']">
  258.                             <xsl:copy-of select="substring(./node(),1,10)"/>
  259.                              <xsl:if test="count(following-sibling::dim:field[@element='date' and @qualifier='created']) != 0">
  260.                             <br/>
  261.                         </xsl:if>
  262.                         </xsl:for-each>
  263.                     </span>
  264.                 </div>
  265.               <xsl:call-template name="itemSummaryView-DIM-fields">
  266.                 <xsl:with-param name="clause" select="($clause + 1)"/>
  267.                 <xsl:with-param name="phase" select="$otherPhase"/>
  268.               </xsl:call-template>
  269.           </xsl:when>
  270.  
  271.           <!-- date.issued row -->
  272.           <xsl:when test="$clause = 7 and (dim:field[@element='date' and @qualifier='issued'])">
  273.                     <div class="simple-item-view-other">
  274.                     <span class="bold"><i18n:text>xmlui.dri2xhtml.METS-1.0.item-date</i18n:text> Issued:</span>
  275.                     <span>
  276.                         <xsl:for-each select="dim:field[@element='date' and @qualifier='issued']">
  277.                             <xsl:copy-of select="substring(./node(),1,10)"/>
  278.                              <xsl:if test="count(following-sibling::dim:field[@element='date' and @qualifier='issued']) != 0">
  279.                             <br/>
  280.                         </xsl:if>
  281.                         </xsl:for-each>
  282.                     </span>
  283.                 </div>
  284.               <xsl:call-template name="itemSummaryView-DIM-fields">
  285.                 <xsl:with-param name="clause" select="($clause + 1)"/>
  286.                 <xsl:with-param name="phase" select="$otherPhase"/>
  287.               </xsl:call-template>
  288.           </xsl:when>
  289.  
  290.           <!-- Abstract row -->
  291.           <xsl:when test="$clause = 8 and (dim:field[@element='description' and @qualifier='abstract' and descendant::text()])">
  292.                     <div class="simple-item-view-description">
  293.                     <h3><i18n:text>xmlui.dri2xhtml.METS-1.0.item-abstract</i18n:text>:</h3>
  294.                     <div>
  295.                     <xsl:if test="count(dim:field[@element='description' and @qualifier='abstract']) &gt; 1">
  296.                         <div class="spacer">&#160;</div>
  297.                     </xsl:if>
  298.                     <xsl:for-each select="dim:field[@element='description' and @qualifier='abstract']">
  299.                         <xsl:choose>
  300.                             <xsl:when test="node()">
  301.                                 <xsl:copy-of select="node()"/>
  302.                             </xsl:when>
  303.                             <xsl:otherwise>
  304.                                 <xsl:text>&#160;</xsl:text>
  305.                             </xsl:otherwise>
  306.                         </xsl:choose>
  307.                         <xsl:if test="count(following-sibling::dim:field[@element='description' and @qualifier='abstract']) != 0">
  308.                             <div class="spacer">&#160;</div>
  309.                         </xsl:if>
  310.                     </xsl:for-each>
  311.                     <xsl:if test="count(dim:field[@element='description' and @qualifier='abstract']) &gt; 1">
  312.                           <div class="spacer">&#160;</div>
  313.                     </xsl:if>
  314.                     </div>
  315.                 </div>
  316.               <xsl:call-template name="itemSummaryView-DIM-fields">
  317.                 <xsl:with-param name="clause" select="($clause + 1)"/>
  318.                 <xsl:with-param name="phase" select="$otherPhase"/>
  319.               </xsl:call-template>
  320.           </xsl:when>
  321.  
  322.           <!-- Description row -->
  323.           <xsl:when test="$clause = 9 and (dim:field[@element='description' and not(@qualifier)])">
  324.                 <div class="simple-item-view-description">
  325.                     <h3 class="bold"><i18n:text>xmlui.dri2xhtml.METS-1.0.item-description</i18n:text>:</h3>
  326.                     <div>
  327.                     <xsl:if test="count(dim:field[@element='description' and not(@qualifier)]) &gt; 1 and not(count(dim:field[@element='description' and @qualifier='abstract']) &gt; 1)">
  328.                         <div class="spacer">&#160;</div>
  329.                     </xsl:if>
  330.                     <xsl:for-each select="dim:field[@element='description' and not(@qualifier)]">
  331.                         <xsl:copy-of select="./node()"/>
  332.                         <xsl:if test="count(following-sibling::dim:field[@element='description' and not(@qualifier)]) != 0">
  333.                             <div class="spacer">&#160;</div>
  334.                         </xsl:if>
  335.                     </xsl:for-each>
  336.                     <xsl:if test="count(dim:field[@element='description' and not(@qualifier)]) &gt; 1">
  337.                            <div class="spacer">&#160;</div>
  338.                     </xsl:if>
  339.                     </div>
  340.                 </div>
  341.               <xsl:call-template name="itemSummaryView-DIM-fields">
  342.                 <xsl:with-param name="clause" select="($clause + 1)"/>
  343.                 <xsl:with-param name="phase" select="$otherPhase"/>
  344.               </xsl:call-template>
  345.           </xsl:when>
  346.  
  347.           <xsl:when test="$clause = 10 and $ds_item_view_toggle_url != ''">
  348.               <p class="ds-paragraph item-view-toggle item-view-toggle-bottom">
  349.                   <a>
  350.                       <xsl:attribute name="href"><xsl:value-of select="$ds_item_view_toggle_url"/></xsl:attribute>
  351.                       <i18n:text>xmlui.ArtifactBrowser.ItemViewer.show_full</i18n:text>
  352.                   </a>
  353.               </p>
  354.           </xsl:when>
  355.  
  356.           <!-- recurse without changing phase if we didn't output anything -->
  357.           <xsl:otherwise>
  358.             <!-- IMPORTANT: This test should be updated if clauses are added! -->
  359.             <xsl:if test="$clause &lt; 11">
  360.               <xsl:call-template name="itemSummaryView-DIM-fields">
  361.                 <xsl:with-param name="clause" select="($clause + 1)"/>
  362.                 <xsl:with-param name="phase" select="$phase"/>
  363.               </xsl:call-template>
  364.             </xsl:if>
  365.           </xsl:otherwise>
  366.         </xsl:choose>
  367.  
  368.          <!-- Generate the Creative Commons license information from the file section (DSpace deposit license hidden by default) -->
  369.         <xsl:apply-templates select="mets:fileSec/mets:fileGrp[@USE='CC-LICENSE']"/>
  370.     </xsl:template>
  371.  
  372.  
  373.     <xsl:template match="dim:dim" mode="itemDetailView-DIM">
  374.         <table class="ds-includeSet-table detailtable">
  375.             <xsl:apply-templates mode="itemDetailView-DIM"/>
  376.         </table>
  377.         <span class="Z3988">
  378.             <xsl:attribute name="title">
  379.                  <xsl:call-template name="renderCOinS"/>
  380.             </xsl:attribute>
  381.             &#xFEFF; <!-- non-breaking space to force separating the end tag -->
  382.         </span>
  383.         <xsl:copy-of select="$SFXLink" />
  384.     </xsl:template>
  385.  
  386.     <xsl:template match="dim:field" mode="itemDetailView-DIM">
  387.             <tr>
  388.                 <xsl:attribute name="class">
  389.                     <xsl:text>ds-table-row </xsl:text>
  390.                     <xsl:if test="(position() div 2 mod 2 = 0)">even </xsl:if>
  391.                     <xsl:if test="(position() div 2 mod 2 = 1)">odd </xsl:if>
  392.                 </xsl:attribute>
  393.                 <td class="label-cell">
  394.                     <xsl:value-of select="./@mdschema"/>
  395.                     <xsl:text>.</xsl:text>
  396.                     <xsl:value-of select="./@element"/>
  397.                     <xsl:if test="./@qualifier">
  398.                         <xsl:text>.</xsl:text>
  399.                         <xsl:value-of select="./@qualifier"/>
  400.                     </xsl:if>
  401.                 </td>
  402.             <td>
  403.               <xsl:copy-of select="./node()"/>
  404.               <xsl:if test="./@authority and ./@confidence">
  405.                 <xsl:call-template name="authorityConfidenceIcon">
  406.                   <xsl:with-param name="confidence" select="./@confidence"/>
  407.                 </xsl:call-template>
  408.               </xsl:if>
  409.             </td>
  410.                 <td><xsl:value-of select="./@language"/></td>
  411.             </tr>
  412.     </xsl:template>
  413.  
  414.     <!-- don't render the item-view-toggle automatically in the summary view, only when it gets called -->
  415.     <xsl:template match="dri:p[contains(@rend , 'item-view-toggle') and
  416.        (preceding-sibling::dri:referenceSet[@type = 'summaryView'] or following-sibling::dri:referenceSet[@type = 'summaryView'])]">
  417.     </xsl:template>
  418.  
  419.     <!-- don't render the head on the item view page -->
  420.     <xsl:template match="dri:div[@n='item-view']/dri:head" priority="5">
  421.     </xsl:template>
  422.  
  423.     <xsl:template match="mets:fileGrp[@USE='PRESERVATION']">
  424.       <xsl:param name="context"/>
  425.       <xsl:param name="primaryBitstream" select="-1"/>
  426.  
  427.       <h2><i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-head-preservation</i18n:text></h2>
  428.       <div class="file-list">
  429.         <xsl:choose>
  430.           <!-- If one exists and it's of text/html MIME type, only display the primary bitstream -->
  431.           <xsl:when test="mets:file[@ID=$primaryBitstream]/@MIMETYPE='text/html'">
  432.             <xsl:apply-templates select="mets:file[@ID=$primaryBitstream]">
  433.               <xsl:with-param name="context" select="$context"/>
  434.              </xsl:apply-templates>
  435.            </xsl:when>
  436.                        
  437.     <!-- Otherwise, iterate over and display all of them -->
  438.         <xsl:otherwise>
  439.       <xsl:apply-templates select="mets:file">
  440.             <!--Do not sort any more bitstream order can be changed-->
  441.             <!--<xsl:sort data-type="number" select="boolean(./@ID=$primaryBitstream)" order="descending" />-->
  442.             <!--<xsl:sort select="mets:FLocat[@LOCTYPE='URL']/@xlink:title"/>-->
  443.             <xsl:with-param name="context" select="$context"/>
  444.           </xsl:apply-templates>
  445.         </xsl:otherwise>
  446.       </xsl:choose>
  447.     </div>
  448.   </xsl:template>
  449.    
  450.     <xsl:template match="mets:file">
  451.         <xsl:param name="context" select="."/>
  452.         <div class="file-wrapper clearfix">
  453.             <div class="thumbnail-wrapper">
  454.                 <a class="image-link">
  455.                     <xsl:attribute name="href">
  456.                         <xsl:value-of select="mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
  457.                     </xsl:attribute>
  458.                     <xsl:choose>
  459.                         <xsl:when test="$context/mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']/
  460.                        mets:file[@GROUPID=current()/@GROUPID]">
  461.                             <img alt="Thumbnail">
  462.                                 <xsl:attribute name="src">
  463.                                     <xsl:value-of select="$context/mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']/
  464.                                    mets:file[@GROUPID=current()/@GROUPID]/mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
  465.                                 </xsl:attribute>
  466.                             </img>
  467.                         </xsl:when>
  468.                         <xsl:otherwise>
  469.                         <!-- <img alt="Icon" src="{concat($theme-path, '/images/mime.png')}" style="height: {$thumbnail.maxheight}px;"/> -->
  470.                 <xsl:choose>
  471.                     <xsl:when test="current()/@MIMETYPE = 'text/xml'">
  472.                             <img alt="Icon" src="{concat($theme-path,'/images/text-xml.png')}" style="height:{$thumbnail.maxheight}px;"/>
  473.                         </xsl:when>
  474.                     <xsl:when test="current()/@MIMETYPE = 'application/msword' or @MIMETYPE = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'">
  475.                             <img alt="Icon" src="{concat($theme-path,'/images/x-office-document-2.png')}" style="height:{$thumbnail.maxheight}px;"/>
  476.                     </xsl:when>
  477.                     <xsl:when test="current()/@MIMETYPE = 'application/vnd.ms-excel' or @MIMETYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' or @MIMETYPE = 'text/csv'">
  478.                             <img alt="Icon" src="{concat($theme-path,'/images/x-office-spreadsheet.png')}" style="height:{$thumbnail.maxheight}px;"/>
  479.                     </xsl:when>
  480.                         <xsl:when test="current()/@MIMETYPE = 'video/quicktime' or @MIMETYPE = 'video/mpeg'">
  481.                             <img alt="Icon" src="{concat($theme-path,'/images/video-x-generic.png')}" style="height:{$thumbnail.maxheight}px;"/>
  482.                                         </xsl:when>
  483.                     <xsl:when test="current()/@MIMETYPE = 'application/pdf'">
  484.                             <img alt="Icon" src="{concat($theme-path,'/images/pdf.png')}" style="height:{$thumbnail.maxheight}px;"/>
  485.                         </xsl:when>
  486.                         <xsl:when test="current()/@MIMETYPE = 'image/jpeg' or @MIMETYPE = 'image/png' or @MIMETYPE = 'image/tiff'">
  487.                                 <img alt="Icon" src="{concat($theme-path,'/images/image-x-generic.png')}" style="height:{$thumbnail.maxheight}px;"/>
  488.                             </xsl:when>
  489.                             <xsl:otherwise>
  490.                                     <img alt="Icon" src="{concat($theme-path, '/images/mime.png')}" style="height: {$thumbnail.maxheight}px;"/>
  491.                                 </xsl:otherwise>
  492.                             </xsl:choose>
  493.            
  494.                         </xsl:otherwise>
  495.                     </xsl:choose>
  496.                 </a>
  497.             </div>
  498.             <div class="file-metadata" style="height: {$thumbnail.maxheight}px;">
  499.                 <div>
  500.                     <span class="bold">
  501.                         <i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-name</i18n:text>
  502.                         <xsl:text>:</xsl:text>
  503.                     </span>
  504.                     <span>
  505.                         <xsl:attribute name="title"><xsl:value-of select="mets:FLocat[@LOCTYPE='URL']/@xlink:title"/></xsl:attribute>
  506.                         <xsl:value-of select="util:shortenString(mets:FLocat[@LOCTYPE='URL']/@xlink:title, 17, 5)"/>
  507.                     </span>
  508.                 </div>
  509.                 <!-- File size always comes in bytes and thus needs conversion -->
  510.                 <div>
  511.                     <span class="bold">
  512.                         <i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-size</i18n:text>
  513.                         <xsl:text>:</xsl:text>
  514.                     </span>
  515.                     <span>
  516.                         <xsl:choose>
  517.                             <xsl:when test="@SIZE &lt; 1024">
  518.                                 <xsl:value-of select="@SIZE"/>
  519.                                 <i18n:text>xmlui.dri2xhtml.METS-1.0.size-bytes</i18n:text>
  520.                             </xsl:when>
  521.                             <xsl:when test="@SIZE &lt; 1024 * 1024">
  522.                                 <xsl:value-of select="substring(string(@SIZE div 1024),1,5)"/>
  523.                                 <i18n:text>xmlui.dri2xhtml.METS-1.0.size-kilobytes</i18n:text>
  524.                             </xsl:when>
  525.                             <xsl:when test="@SIZE &lt; 1024 * 1024 * 1024">
  526.                                 <xsl:value-of select="substring(string(@SIZE div (1024 * 1024)),1,5)"/>
  527.                                 <i18n:text>xmlui.dri2xhtml.METS-1.0.size-megabytes</i18n:text>
  528.                             </xsl:when>
  529.                             <xsl:otherwise>
  530.                                 <xsl:value-of select="substring(string(@SIZE div (1024 * 1024 * 1024)),1,5)"/>
  531.                                 <i18n:text>xmlui.dri2xhtml.METS-1.0.size-gigabytes</i18n:text>
  532.                             </xsl:otherwise>
  533.                         </xsl:choose>
  534.                     </span>
  535.                 </div>
  536.                 <!-- Lookup File Type description in local messages.xml based on MIME Type.
  537.         In the original DSpace, this would get resolved to an application via
  538.         the Bitstream Registry, but we are constrained by the capabilities of METS
  539.         and can't really pass that info through. -->
  540.                 <div>
  541.                     <span class="bold">
  542.                         <i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-format</i18n:text>
  543.                         <xsl:text>:</xsl:text>
  544.                     </span>
  545.                     <span>
  546.                         <xsl:call-template name="getFileTypeDesc">
  547.                             <xsl:with-param name="mimetype">
  548.                                 <xsl:value-of select="substring-before(@MIMETYPE,'/')"/>
  549.                                 <xsl:text>/</xsl:text>
  550.                                 <xsl:value-of select="substring-after(@MIMETYPE,'/')"/>
  551.                             </xsl:with-param>
  552.                         </xsl:call-template>
  553.                     </span>
  554.                 </div>
  555.                 <!---->
  556.                 <!-- Display the contents of 'Description' only if bitstream contains a description -->
  557.                 <xsl:if test="mets:FLocat[@LOCTYPE='URL']/@xlink:label != ''">
  558.                     <div>
  559.                         <span class="bold">
  560.                             <i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-description</i18n:text>
  561.                             <xsl:text>:</xsl:text>
  562.                         </span>
  563.                         <span>
  564.                             <xsl:attribute name="title"><xsl:value-of select="mets:FLocat[@LOCTYPE='URL']/@xlink:label"/></xsl:attribute>
  565.                             <!--<xsl:value-of select="mets:FLocat[@LOCTYPE='URL']/@xlink:label"/>-->
  566.                             <xsl:value-of select="util:shortenString(mets:FLocat[@LOCTYPE='URL']/@xlink:label, 17, 5)"/>
  567.                         </span>
  568.                     </div>
  569.                 </xsl:if>
  570.             </div>
  571.             <div class="file-link" style="height: {$thumbnail.maxheight}px;">
  572.                 <xsl:choose>
  573.                     <xsl:when test="@ADMID">
  574.                         <xsl:call-template name="display-rights"/>
  575.                     </xsl:when>
  576.                     <xsl:otherwise>
  577.                         <xsl:call-template name="view-open"/>
  578.                     </xsl:otherwise>
  579.                 </xsl:choose>
  580.             </div>
  581.         </div>
  582.     </xsl:template>
  583.  
  584.     <xsl:template name="view-open">
  585.         <a>
  586.             <xsl:attribute name="href">
  587.                 <xsl:value-of select="mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
  588.             </xsl:attribute>
  589.             <i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-viewOpen</i18n:text>
  590.         </a>
  591.     </xsl:template>
  592.  
  593.     <xsl:template name="display-rights">
  594.         <xsl:variable name="file_id" select="jstring:replaceAll(jstring:replaceAll(string(@ADMID), '_METSRIGHTS', ''), 'rightsMD_', '')"/>
  595.         <xsl:variable name="rights_declaration" select="../../../mets:amdSec/mets:rightsMD[@ID = concat('rightsMD_', $file_id, '_METSRIGHTS')]/mets:mdWrap/mets:xmlData/rights:RightsDeclarationMD"/>
  596.         <xsl:variable name="rights_context" select="$rights_declaration/rights:Context"/>
  597.         <xsl:variable name="users">
  598.             <xsl:for-each select="$rights_declaration/*">
  599.                 <xsl:value-of select="rights:UserName"/>
  600.                 <xsl:choose>
  601.                     <xsl:when test="rights:UserName/@USERTYPE = 'GROUP'">
  602.                        <xsl:text> (group)</xsl:text>
  603.                     </xsl:when>
  604.                     <xsl:when test="rights:UserName/@USERTYPE = 'INDIVIDUAL'">
  605.                        <xsl:text> (individual)</xsl:text>
  606.                     </xsl:when>
  607.                 </xsl:choose>
  608.                 <xsl:if test="position() != last()">, </xsl:if>
  609.             </xsl:for-each>
  610.         </xsl:variable>
  611.  
  612.         <xsl:choose>
  613.             <xsl:when test="not ($rights_context/@CONTEXTCLASS = 'GENERAL PUBLIC') and ($rights_context/rights:Permissions/@DISPLAY = 'true')">
  614.                 <a href="{mets:FLocat[@LOCTYPE='URL']/@xlink:href}">
  615.                     <img width="64" height="64" src="{concat($theme-path,'/images/Crystal_Clear_action_lock3_64px.png')}" title="Read access available for {$users}"/>
  616.                     <!-- icon source: http://commons.wikimedia.org/wiki/File:Crystal_Clear_action_lock3.png -->
  617.                 </a>
  618.             </xsl:when>
  619.             <xsl:otherwise>
  620.                 <xsl:call-template name="view-open"/>
  621.             </xsl:otherwise>
  622.         </xsl:choose>
  623.     </xsl:template>
  624.  
  625. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment