Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

&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

Code Block
<sitemap:xmap>

element:

Code Block
<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:

Code Block
<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

Code Block
<xsl:template>

blocks into your theme's XSLT:

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

STEP 3: Alter authors to add links

The existing code looks like this in both locations:

Code Block
<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

Code Block
<xsl:for-each>

blocks, add this link in version 1.4:

Code Block
<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:

Code Block
<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>