Skip to content

Instantly share code, notes, and snippets.

@aschweer
Last active September 22, 2015 22:46
Show Gist options
  • Save aschweer/5ee6339b3e1202699220 to your computer and use it in GitHub Desktop.
Save aschweer/5ee6339b3e1202699220 to your computer and use it in GitHub Desktop.
Template for Mirage 2 that links author names to "author" browse index
<xsl:stylesheet
xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
xmlns:dri="http://di.tamu.edu/DRI/1.0/"
xmlns:mets="http://www.loc.gov/METS/"
xmlns:dim="http://www.dspace.org/xmlns/dspace/dim"
xmlns:xlink="http://www.w3.org/TR/xlink/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:ore="http://www.openarchives.org/ore/terms/"
xmlns:oreatom="http://www.openarchives.org/ore/atom/"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:encoder="xalan://java.net.URLEncoder"
xmlns:util="org.dspace.app.xmlui.utils.XSLUtils"
xmlns:jstring="java.lang.String"
xmlns:rights="http://cosimo.stanford.edu/sdr/metsrights/"
xmlns:confman="org.dspace.core.ConfigurationManager"
exclude-result-prefixes="xalan encoder i18n dri mets dim xlink xsl util jstring rights confman">
<xsl:output indent="yes"/>
<xsl:template name="itemSummaryView-DIM-authors">
<xsl:if test="dim:field[@element='contributor'][@qualifier='author' and descendant::text()] or dim:field[@element='creator' and descendant::text()] or dim:field[@element='contributor' and descendant::text()]">
<div class="simple-item-view-authors item-page-field-wrapper table">
<h5><i18n:text>xmlui.dri2xhtml.METS-1.0.item-author</i18n:text></h5>
<xsl:choose>
<xsl:when test="dim:field[@element='contributor'][@qualifier='author']">
<xsl:for-each select="dim:field[@element='contributor'][@qualifier='author']">
<div>
<xsl:if test="@authority">
<xsl:attribute name="class"><xsl:text>ds-dc_contributor_author-authority</xsl:text></xsl:attribute>
</xsl:if>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat($context-path,'/browse?type=author&amp;value=')"/>
<xsl:copy-of select="encoder:encode(node())"/>
</xsl:attribute>
<xsl:copy-of select="node()"/>
</a>
</div>
</xsl:for-each>
</xsl:when>
<xsl:when test="dim:field[@element='creator']">
<xsl:for-each select="dim:field[@element='creator']">
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat($context-path,'/browse?type=author&amp;value=')"/>
<xsl:copy-of select="encoder:encode(node())"/>
</xsl:attribute>
<xsl:copy-of select="node()"/>
</a>
<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="dim:field[@element='contributor']">
<xsl:for-each select="dim:field[@element='contributor']">
<div>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat($context-path,'/browse?type=author&amp;value=')"/>
<xsl:copy-of select="encoder:encode(node())"/>
</xsl:attribute>
<xsl:copy-of select="node()"/>
</a>
</div>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<i18n:text>xmlui.dri2xhtml.METS-1.0.no-author</i18n:text>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:if>
</xsl:templat>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment