Contribute to the DSpace Development Fund

The newly established DSpace Development Fund supports the development of new features prioritized by DSpace Governance. For a list of planned features see the fund wiki page.

&This page assumes that you are working from DIM rather than MODS. The technique should be transferable, however, as it relies on browse-by-author and browse-by-subject pages having predictable URLs.

This page walks you through creating author links. Subject links employ the same technique.

STEP 1: Encode all URLs in Manakin

This is done so that special characters in author names don't break browsers when used in URLs. In the sitemap.xmap file inside your theme folder, add the following just under the root

<sitemap:xmap>

element:

<map:components>
  <map:transformers default="xslt">
       <map:transformer name="encodeURL" src="org.apache.cocoon.transformation.EncodeURLTransformer"/>
  </map:transformers>
</map:components>

Then, between Steps 2 and 3 lower in the file, add the following:

<map:transform type="encodeURL"/>

STEP 2: Copy templates into your theme

The XSLT that creates author listings is in themes/dri2xhtml/DS-METS-1.0-DIM.xsl. Copy two

<xsl:template>

blocks into your theme's XSLT:

  • Version 1.4, the one with
    name="itemSummaryList_DS-METS-1.0-DIM"
    (this governs authors on browse lists)
  • Version 1.4, the one with
    name="itemSummaryView_DS-METS-1.0-DIM"
    (this governs authors on item pages)
  • Version 1.5, the one with
    name="DIM-Handler.xsl"
    . Look for the template
    <xsl:template match="dim:dim" mode="itemSummaryView-DIM">

STEP 3: Alter authors to add links

The existing code looks like this in both locations:

<span class="author">
    <xsl:choose>
        <xsl:when test="$data/dim:field[@element='contributor'][@qualifier='author']">
            <xsl:for-each select="$data/dim:field[@element='contributor'][@qualifier='author']">
                <xsl:copy-of select="."/>
                <xsl:if test="count(following-sibling::dim:field[@element='contributor'][@qualifier='author']) != 0">
                    <xsl:text>; </xsl:text>
                </xsl:if>
            </xsl:for-each>
        </xsl:when>
        <xsl:when test="$data/dim:field[@element='creator']">
            <xsl:for-each select="$data/dim:field[@element='creator']">
                <xsl:copy-of select="."/>
                <xsl:if test="count(following-sibling::dim:field[@element='creator']) != 0">
                    <xsl:text>; </xsl:text>
                </xsl:if>
            </xsl:for-each>
        </xsl:when>
        <xsl:when test="$data/dim:field[@element='contributor']">
            <xsl:for-each select="$data/dim:field[@element='contributor']">
                <xsl:copy-of select="."/>
                <xsl:if test="count(following-sibling::dim:field[@element='contributor']) != 0">
                    <xsl:text>; </xsl:text>
                </xsl:if>
            </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
            <i18n:text>xmlui.dri2xhtml.METS-1.0.no-author</i18n:text>
        </xsl:otherwise>
    </xsl:choose>
</span>

Inside EACH of the

<xsl:for-each>

blocks, add this link in version 1.4:

<xsl:for-each select="$data/dim:field[@element='contributor'][@qualifier='author']">
    <a>
        <xsl:attribute name="href">
            <xsl:value-of
                select="concat($context-path,'/browse-author-items?author=')"/>
            <xsl:copy-of select="."/>
        </xsl:attribute>
        <xsl:value-of select="text()"/>
    </a>
    <xsl:if test="count(following-sibling::dim:field[@element='contributor'][@qualifier='author']) != 0">
        <xsl:text>; </xsl:text>
    </xsl:if>
</xsl:for-each>

Add this link in version 1.5:

<a>
        <xsl:attribute name="href">
            <xsl:value-of
                select="concat($context-path,'/browse?value=')"/>
            <xsl:copy-of select="."/>&amp;type=author
        </xsl:attribute>
        <xsl:value-of select="text()"/>
 </a>