Changeset 26023

Show
Ignore:
Timestamp:
25.07.2012 21:37:04 (7 years ago)
Author:
ak19
Message:

1. Fixing the java code to handle gsf:equivlinkgs3 again. The code had recently been changed to remove the gsf:meta attribute of multiple=true to use attribute pos=index|first|last instead. But when multiple=true in the past, _all_ would be prefixed to the metadata_sep and metadata, and this still needed to be processed. 2. Added the XSLT to deal with gsf:equivlinkgs3 into the default skin (previously this was only added into gs3-library which has now become the basic skin). With changes 1 and 2, the parts of the DSpace tutorial which deal with equivlink now work for GS3 (again).

Location:
main/trunk/greenstone3
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java

    r25967 r26023  
    411411        // check for pos on the front, indicating which piece of meta the user wants 
    412412        // pos can be "first", "last" or the position value of the requested piece of metadata  
    413         if (temp.startsWith(GSConstants.META_POS)) 
    414         { 
     413        if (temp.startsWith(GSConstants.META_POS) || temp.equals("all")) 
     414        { 
     415            if (temp.startsWith(GSConstants.META_POS)) { 
    415416            temp = temp.substring(GSConstants.META_POS.length()); 
    416417            pos = temp; 
     418            } 
    417419             
    418420            index = metadata.indexOf(GSConstants.META_RELATION_SEP); 
  • main/trunk/greenstone3/web/interfaces/default/transform/config_format.xsl

    r26022 r26023  
    125125    </xsl:template> 
    126126     
     127  <!-- calls a template in gslib.xsl in order to avoid xsl vs xslt issue --> 
     128  <xsl:template match="gsf:equivlinkgs3"> 
     129    <xslt:call-template name="equivDocLinks"> 
     130      <xslt:with-param name="count" select="0"/> 
     131    </xslt:call-template> 
     132  </xsl:template> 
     133 
     134  <!-- Another way (also works with DSpace tutorial): build all the equivalent document links for the current document in one go. No looping necessary: handled in function call. --> 
     135  <!--<xsl:template match="gsf:equivlinkgs3"> 
     136    <xslt:variable name="docicon" select="metadataList/metadata[contains(@name, 'equivDocIcon')]"/>  
     137    <xslt:variable name="docStartlink" select="metadataList/metadata[contains(@name, 'all_*,*_equivDocLink')]"/>     
     138    <xslt:variable name="docEndlink" select="metadataList/metadata[contains(@name, '/equivDocLink')]"/> 
     139 
     140    <xslt:variable name="equivDocLinks" select="java:org.greenstone.gsdl3.util.XSLTUtil.getEquivDocLinks(',',$docicon, $docStartlink, $docEndlink, ' ')" /> 
     141    <xslt:value-of disable-output-escaping="yes" select="$equivDocLinks"/> 
     142  </xsl:template>--> 
     143 
     144<!-- 
     145In the collection's format statement, could have the following javascript+XSLT in place of 
     146the gsf:equivlinkgs3 element (which resolves to the XSLT in config_format.xsl and gslib.xsl). 
     147<xsl:text disable-output-escaping="yes">&lt;script&gt;var equivDocIcon= [ &quot; 
     148</xsl:text> 
     149<gsf:metadata name="equivDocIcon" separator="&quot;, &quot;" multiple="true"/> 
     150<xsl:text disable-output-escaping="yes">&quot;];var equivDocStartLink= [ &quot; 
     151</xsl:text> 
     152<gsf:metadata name="equivDocLink" separator="&quot;,&quot;" multiple="true"/> 
     153<xsl:text disable-output-escaping="yes">&quot;];var equivDocEndLink= [ &quot; 
     154</xsl:text> 
     155<gsf:metadata name="/equivDocLink" separator="&quot;,&quot;" multiple="true"/> 
     156<xsl:text disable-output-escaping="yes">&quot;];for (var i=0; i&lt;equivDocIcon.length; i++) { document.write(equivDocStartLink[i]+ equivDocIcon[i] + equivDocEndLink[i]); }&lt;/script&gt; 
     157</xsl:text> 
     158--> 
     159 
    127160    <!-- gsf:cgiparam example, as used by the Enhanced PDF tutorial:  
    128161        <a><xsl:attribute name="href"><gsf:metadata name="httpPath" type="collection"/>/index/assoc/<gsf:metadata name="archivedir"/>/<gsf:metadata name="srclinkFile"/>#search=&amp;quot;<gsf:cgi-param name="query"/>&amp;quot;</xsl:attribute>src doc link with query highlighting</a> --> 
  • main/trunk/greenstone3/web/interfaces/default/transform/gslib.xsl

    r25934 r26023  
    705705  </xsl:template> 
    706706 
     707 
     708  <!-- builds up links to available document types equivalent to the default source 
     709       document with as anchor the equivalent documents' doctype icons. --> 
     710  <xsl:template name="equivDocLinks"> 
     711    <xsl:param name="count"/> 
     712 
     713      <xsl:variable name="docicon" select="metadataList/metadata[contains(@name, 'equivDocIcon')]"/> 
     714      <xsl:variable name="docEndlink" select="metadataList/metadata[contains(@name, '/equivDocLink')]"/> 
     715 
     716      <!--<xsl:variable name="docStartlink" select="metadataList/metadata[contains(@name, 'all_*,*_equivDocLink')]"/>-->     
     717      <!-- In the following variable statement, we're trying to set the docStartlink to any metadata whose value  
     718    ends on equivDocLink but NOT /equivDocLink. Unfortunately, the xslt function fn:ends-with only exists from 
     719    xslt 2.0 onwards. So need to use substring() and string-lenth() functions now to check whether the 13th char 
     720    from the end is a slash or not, in order to distinguish between the start of a doclink and end of one.  
     721    If this 13th char from the end is not a slash, then we found (the string we want to store in) docStartlink. --> 
     722      <xsl:variable name="docStartlink"> 
     723    <xsl:for-each select="metadataList/metadata"> 
     724      <xsl:if test="contains(@name, 'equivDocLink')">    
     725        <xsl:variable name="tmpvar" select="substring(@name, string-length(@name)-12, 1)"/>  
     726          <xsl:if test="not($tmpvar='/')"> 
     727            <xsl:value-of select="self::node()[@name]"/>             
     728          </xsl:if>      
     729      </xsl:if> 
     730    </xsl:for-each>  
     731      </xsl:variable> 
     732 
     733      <xsl:variable name="equivDocIcon" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($docicon, $count)" /> 
     734      <xsl:variable name="equivStartlink" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($docStartlink, $count)" /> 
     735      <xsl:variable name="equivEndlink" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($docEndlink, $count)" /> 
     736 
     737      <xsl:if test="$equivDocIcon != ''"> 
     738        <xsl:value-of disable-output-escaping="yes" select="$equivStartlink"/> 
     739        <xsl:value-of disable-output-escaping="yes" select="$equivDocIcon"/> 
     740        <xsl:value-of disable-output-escaping="yes" select="$equivEndlink"/> 
     741 
     742        <!-- recursively call this template to get multiple entries --> 
     743        <xsl:call-template name="equivDocLinks"> 
     744          <xsl:with-param name="count"><xsl:value-of select="$count + 1"/></xsl:with-param> 
     745        </xsl:call-template> 
     746      </xsl:if> 
     747 
     748  </xsl:template> 
     749 
    707750</xsl:stylesheet>