Created
December 31, 2015 20:03
-
-
Save cmharlow/b84f3299b1f4e7f1a846 to your computer and use it in GitHub Desktop.
UTK OpenRefine Simple XML Export to MODS/XML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet xmlns="http://www.loc.gov/mods/v3" | |
xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-5.xsd" | |
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
version="2.0"> | |
<xsl:output encoding="UTF-8" indent="yes" method="xml"/> | |
<xsl:strip-space elements="*"/> | |
<!-- Create Item Record for each Row, Name Record Filename after Identifier --> | |
<xsl:template match="root/row"> | |
<xsl:variable name="filename" select="identifier_file[1]"/> | |
<xsl:result-document method="xml" href="modsxml/{$filename}.xml" encoding="UTF-8" indent="yes"> | |
<mods xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-5.xsd" version="3.5"> | |
<xsl:call-template name="record"/> | |
</mods> | |
</xsl:result-document> | |
</xsl:template> | |
<!-- ITEM RECORD --> | |
<xsl:template name="record"> | |
<!-- Item/Record Identifiers --> | |
<xsl:apply-templates select="identifier"/> | |
<xsl:apply-templates select="identifier_opac"/> | |
<xsl:apply-templates select="identifier_isbn"/> | |
<xsl:apply-templates select="identifier_file"/> | |
<!-- Names --> | |
<xsl:apply-templates select="name"/> | |
<!-- titleInfo --> | |
<titleInfo> | |
<xsl:if test="title_initial_article"> | |
<nonSort><xsl:value-of select="title_initial_article"/></nonSort> | |
</xsl:if> | |
<title><xsl:value-of select="title"/></title> | |
<xsl:if test="title_of_part"> | |
<partName><xsl:value-of select="title_of_part"/></partName> | |
</xsl:if> | |
</titleInfo> | |
<xsl:if test="title_2"> | |
<titleInfo type="alternative"> | |
<title><xsl:value-of select="title_2"/></title> | |
</titleInfo> | |
</xsl:if> | |
<!-- Item Type (taken from MODS Type vocabulary) --> | |
<xsl:apply-templates select="item_type"/> | |
<!-- originInfo --> | |
<originInfo> | |
<!-- Place of Origin --> | |
<!-- See notes in subtemplates for explanation of repeated element --> | |
<xsl:apply-templates select="place_of_origin"/> | |
<!-- Publisher --> | |
<xsl:for-each select="publisher"> | |
<publisher><xsl:value-of select='.'/></publisher> | |
</xsl:for-each> | |
<!-- Date --> | |
<dateCreated><xsl:value-of select="date_text"/></dateCreated> | |
<dateCreated encoding="edtf" keyDate="yes"> | |
<xsl:if test="date_qualifier != 'exact' and date_qualifier != ''"> | |
<xsl:attribute name="qualifier"><xsl:value-of select="date_qualifier"/></xsl:attribute> | |
</xsl:if> | |
<xsl:value-of select="date_key"/> | |
</dateCreated> | |
<xsl:if test="date_publication"> | |
<dateIssued><xsl:value-of select="date_publication"/></dateIssued> | |
</xsl:if> | |
</originInfo> | |
<!-- physicalDescription --> | |
<xsl:if test="extent | form | digital_origin"> | |
<physicalDescription> | |
<xsl:apply-templates select="extent"/> | |
<xsl:apply-templates select="form"/> | |
<xsl:apply-templates select="digital_origin" /> | |
</physicalDescription> | |
</xsl:if> | |
<!-- Genre --> | |
<xsl:apply-templates select="genre"/> | |
<!-- Abstract --> | |
<xsl:apply-templates select="abstract"/> | |
<!-- Language --> | |
<xsl:apply-templates select="language"/> | |
<!-- Notes --> | |
<xsl:apply-templates select="public_note"/> | |
<xsl:apply-templates select="note_provenance"/> | |
<!-- Location --> | |
<location> | |
<physicalLocation><xsl:value-of select="repository"/></physicalLocation> | |
<xsl:if test="shelf_locator"> | |
<holdingSimple> | |
<copyInformation> | |
<xsl:apply-templates select="shelf_locator"/> | |
</copyInformation> | |
</holdingSimple> | |
</xsl:if> | |
</location> | |
<!-- Subject --> | |
<xsl:apply-templates select="subject_topical"/> | |
<xsl:apply-templates select="subject_local"/> | |
<xsl:apply-templates select="subject_name"/> | |
<xsl:apply-templates select="subject_geographic"/> | |
<xsl:if test="subject_temporal"> | |
<subject> | |
<temporal><xsl:value-of select="subject_temporal"/></temporal> | |
</subject> | |
</xsl:if> | |
<!-- relatedItems --> | |
<relatedItem type="host" displayLabel="Project"> | |
<titleInfo> | |
<title><xsl:value-of select="project_title"/></title> | |
</titleInfo> | |
</relatedItem> | |
<!-- THIS IS THE PHYSICAL, ARCHIVAL Collection that holds the physical item digitized. For Digital Collections, use Project (above) --> | |
<xsl:for-each select="collection"> | |
<relatedItem type="host" displayLabel="Collection"> | |
<titleInfo> | |
<title><xsl:value-of select="."/></title> | |
</titleInfo> | |
<xsl:if test="../collection_identifier"> | |
<identifier type="local"><xsl:value-of select="../collection_identifier"/></identifier> | |
</xsl:if> | |
</relatedItem> | |
</xsl:for-each> | |
<!-- This refers to items that may have contained the physical item in some way - such as books for digitized chapters --> | |
<xsl:for-each select="host_title"> | |
<relatedItem type="host"> | |
<titleInfo> | |
<title><xsl:value-of select="."/></title> | |
</titleInfo> | |
</relatedItem> | |
</xsl:for-each> | |
<!-- accessCondition --> | |
<accessCondition type="use and reproduction"> | |
<xsl:value-of select="rights"/> | |
</accessCondition> | |
<!-- recordInfo --> | |
<recordInfo> | |
<recordIdentifier><xsl:value-of select="concat('record_', identifier_file[1])"/></recordIdentifier> | |
<recordContentSource>University of Tennessee, Knoxville. Libraries</recordContentSource> | |
<languageOfCataloging> | |
<languageTerm type="code" authority="iso639-2b">eng</languageTerm> | |
</languageOfCataloging> | |
<recordOrigin>Created and edited in general conformance to MODS Guidelines (Version 3.5).</recordOrigin> | |
</recordInfo> | |
</xsl:template> | |
<!-- End Item Record Template --> | |
<!-- SUBTEMPLATES --> | |
<xsl:template match="identifier"> | |
<identifier type="local"><xsl:value-of select="." /></identifier> | |
</xsl:template> | |
<xsl:template match="identifier_opac"> | |
<identifier type="opac"><xsl:value-of select="."/></identifier> | |
</xsl:template> | |
<xsl:template match="identifier_isbn"> | |
<identifier type="isbn"><xsl:value-of select="."/></identifier> | |
</xsl:template> | |
<xsl:template match="identifier_file"> | |
<identifier type="filename"><xsl:value-of select="."/></identifier> | |
</xsl:template> | |
<xsl:template match="name"> | |
<name> | |
<namePart><xsl:value-of select="."/></namePart> | |
<role> | |
<roleTerm type="text" authority="marcrelator"> | |
<xsl:value-of select="../name_role"/> | |
</roleTerm> | |
</role> | |
</name> | |
</xsl:template> | |
<xsl:template match="name_1"> | |
<name> | |
<namePart><xsl:value-of select="."/></namePart> | |
<role> | |
<roleTerm type="text" authority="marcrelator"> | |
<xsl:value-of select="../name_role_1"/> | |
</roleTerm> | |
</role> | |
</name> | |
</xsl:template> | |
<xsl:template match="name_2"> | |
<name> | |
<namePart><xsl:value-of select="."/></namePart> | |
<role> | |
<roleTerm type="text" authority="marcrelator"> | |
<xsl:value-of select="../name_role_2"/> | |
</roleTerm> | |
</role> | |
</name> | |
</xsl:template> | |
<xsl:template match="name_3"> | |
<name> | |
<namePart><xsl:value-of select="."/></namePart> | |
<role> | |
<roleTerm type="text" authority="marcrelator"> | |
<xsl:value-of select="../name_role_3"/> | |
</roleTerm> | |
</role> | |
</name> | |
</xsl:template> | |
<xsl:template match="name_4"> | |
<name> | |
<namePart><xsl:value-of select="."/></namePart> | |
<role> | |
<roleTerm type="text" authority="marcrelator"> | |
<xsl:value-of select="../name_role_4"/> | |
</roleTerm> | |
</role> | |
</name> | |
</xsl:template> | |
<xsl:template match="name_5"> | |
<name> | |
<namePart><xsl:value-of select="."/></namePart> | |
<role> | |
<roleTerm type="text" authority="marcrelator"> | |
<xsl:value-of select="../name_role_5"/> | |
</roleTerm> | |
</role> | |
</name> | |
</xsl:template> | |
<xsl:template match="place_of_origin"> | |
<place supplied="yes"> | |
<placeTerm type="text"> | |
<xsl:value-of select="."/> | |
</placeTerm> | |
</place> | |
</xsl:template> | |
<xsl:template match="item_type"> | |
<typeOfResource><xsl:value-of select="lower-case(.)"/></typeOfResource> | |
</xsl:template> | |
<xsl:template match="form"> | |
<form> | |
<xsl:value-of select="."/> | |
</form> | |
</xsl:template> | |
<xsl:template match="genre"> | |
<genre> | |
<xsl:value-of select="."/> | |
</genre> | |
</xsl:template> | |
<xsl:template match="digital_origin"> | |
<digitalOrigin><xsl:value-of select="."/></digitalOrigin> | |
</xsl:template> | |
<xsl:template match="extent"> | |
<extent><xsl:value-of select="."/></extent> | |
</xsl:template> | |
<xsl:template match="abstract"> | |
<abstract><xsl:value-of select="."/></abstract> | |
</xsl:template> | |
<xsl:template match="language"> | |
<language> | |
<languageTerm type="code" authority="iso639-2b"><xsl:value-of select="."/></languageTerm> | |
</language> | |
</xsl:template> | |
<xsl:template match="public_note"> | |
<note><xsl:value-of select="."/></note> | |
</xsl:template> | |
<xsl:template match="note_provenance"> | |
<note type="ownership"><xsl:value-of select="."/></note> | |
</xsl:template> | |
<xsl:template match="subrepository"> | |
<subLocation><xsl:value-of select="."/></subLocation> | |
</xsl:template> | |
<xsl:template match="shelf_locator"> | |
<shelfLocator><xsl:value-of select='.'/></shelfLocator> | |
</xsl:template> | |
<xsl:template match="subject_topical"> | |
<subject> | |
<topic><xsl:value-of select="."/></topic> | |
</subject> | |
</xsl:template> | |
<xsl:template match="subject_name"> | |
<subject> | |
<name> | |
<namePart><xsl:value-of select="."/></namePart> | |
</name> | |
</subject> | |
</xsl:template> | |
<xsl:template match="subject_geographic"> | |
<subject> | |
<geographic><xsl:value-of select="."/></geographic> | |
</subject> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment