Skip to content

Instantly share code, notes, and snippets.

@bibliotechy
Last active August 29, 2015 13:57
Show Gist options
  • Save bibliotechy/9629633 to your computer and use it in GitHub Desktop.
Save bibliotechy/9629633 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:foxml="info:fedora/fedora-system:def/foxml#"
xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
exclude-result-prefixes="foxml mods"
version="1.0">
<xsl:template match="foxml:datastream[@ID='MODS']/foxml:datastreamVersion[last()]" name="SORTS">
<xsl:param name="content"/>
<xsl:apply-templates mode="mods_sorts" select="$content/mods:mods" />
</xsl:template>
<xsl:template match="mods:mods/mods:name[1]" mode="mods_sorts">
<field>
<xsl:attribute name="name">creator_sort</xsl:attribute>
<xsl:value-of select="mods:namePart" />
</field>
</xsl:template>
<xsl:template match="mods:originInfo" mode="mods_sorts">
<xsl:choose>
<xsl:when test="mods:dateIssued" >
<field>
<xsl:attribute name="name">date_sort</xsl:attribute>
<xsl:value-of select="mods:dateIssued" />
</field>
</xsl:when>
<xsl:when test="mods:dateCreated">
<field>
<xsl:attribute name="name">date_sort</xsl:attribute>
<xsl:value-of select="mods:dateCreated" />
</field>
</xsl:when>
<xsl:when test="mods:dateOther">
<field>
<xsl:attribute name="name">date_sort</xsl:attribute>
<xsl:value-of select="mods:dateOther" />
</field>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="mods:mods/mods:titleInfo[not(@type)]" mode="mods_sorts">
<field>
<xsl:attribute name="name">title_sort</xsl:attribute>
<xsl:value-of select="mods:title" />
</field>
</xsl:template>
<xsl:template match="text()" mode="mods_sorts"/>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment