Last active
November 6, 2015 19:01
-
-
Save CJHArch/2531cda69461189aea69 to your computer and use it in GitHub Desktop.
This XSLT adds 856 fields based on the 094 field, in preparation for ingest via the Digitool MARCXML ingest process.
This file contains 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:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim | |
http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" version="2.0"> | |
<xsl:output method="xml"/> | |
<!-- This stylesheet was written in July 2015 to automatically add 856 fields for the LBI art project. Filenames are derived from the 094 field. KS 20150713 --> | |
<xsl:variable name="filename"> | |
<xsl:value-of select="translate(marc:collection/marc:record/marc:datafield[@tag='094']/marc:subfield[@code='a']/text(), '.', '-')"/> | |
</xsl:variable> | |
<xsl:template match="@*|node()"> | |
<xsl:copy> | |
<xsl:apply-templates select="@*|node()"/> | |
</xsl:copy> | |
</xsl:template> | |
<xsl:template match="marc:collection/marc:record/marc:datafield[@tag='852']"> | |
<xsl:copy-of select="."/> | |
<!-- add tiff, jp2, and web derivatives --> | |
<xsl:element name="datafield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="tag">856</xsl:attribute> | |
<xsl:attribute name="ind1">4</xsl:attribute> | |
<xsl:attribute name="ind2">6</xsl:attribute> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">u</xsl:attribute> | |
<xsl:text>lo-</xsl:text> | |
<xsl:value-of select="$filename"/> | |
<xsl:text>.tif</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">q</xsl:attribute> | |
<xsl:text>image/tiff</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">z</xsl:attribute> | |
<xsl:text>Artwork</xsl:text> | |
</xsl:element> | |
</xsl:element> | |
<xsl:element name="datafield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="tag">856</xsl:attribute> | |
<xsl:attribute name="ind1">4</xsl:attribute> | |
<xsl:attribute name="ind2">6</xsl:attribute> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">u</xsl:attribute> | |
<xsl:text>lo-</xsl:text> | |
<xsl:value-of select="$filename"/> | |
<xsl:text>.jpf</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">q</xsl:attribute> | |
<xsl:text>image/jpf</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">z</xsl:attribute> | |
<xsl:text>Artwork</xsl:text> | |
</xsl:element> | |
</xsl:element> | |
<xsl:element name="datafield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="tag">856</xsl:attribute> | |
<xsl:attribute name="ind1">4</xsl:attribute> | |
<xsl:attribute name="ind2">6</xsl:attribute> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">u</xsl:attribute> | |
<xsl:text>lo-</xsl:text> | |
<xsl:value-of select="$filename"/> | |
<xsl:text>.jpg</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">q</xsl:attribute> | |
<xsl:text>image/jpeg</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">z</xsl:attribute> | |
<xsl:text>Artwork</xsl:text> | |
</xsl:element> | |
</xsl:element> | |
<xsl:element name="datafield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="tag">856</xsl:attribute> | |
<xsl:attribute name="ind1">4</xsl:attribute> | |
<xsl:attribute name="ind2">6</xsl:attribute> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">u</xsl:attribute> | |
<xsl:text>lo-</xsl:text> | |
<xsl:value-of select="$filename"/> | |
<xsl:text>-200.jpg</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">q</xsl:attribute> | |
<xsl:text>image/jpeg</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">z</xsl:attribute> | |
<xsl:text>Web derivative: 200px</xsl:text> | |
</xsl:element> | |
</xsl:element> | |
<xsl:element name="datafield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="tag">856</xsl:attribute> | |
<xsl:attribute name="ind1">4</xsl:attribute> | |
<xsl:attribute name="ind2">6</xsl:attribute> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">u</xsl:attribute> | |
<xsl:text>lo-</xsl:text> | |
<xsl:value-of select="$filename"/> | |
<xsl:text>-800.jpg</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">q</xsl:attribute> | |
<xsl:text>image/jpeg</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">z</xsl:attribute> | |
<xsl:text>Web derivative: 800px</xsl:text> | |
</xsl:element> | |
</xsl:element> | |
</xsl:template> | |
</xsl:stylesheet> |
This file contains 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:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim | |
http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" version="2.0"> | |
<xsl:output method="xml"/> | |
<!-- This stylesheet was written in July 2015 to automatically add 856 fields for the LBI art project. Filenames are derived from the 094 field. KS 20150713 --> | |
<!-- Put variable into 852 template, so that it grabs the correct 094 value for EACH record KS 20150814 --> | |
<!-- Copy the 094 to 852$h KS 20150814 --> | |
<xsl:template match="@*|node()"> | |
<xsl:copy> | |
<xsl:apply-templates select="@*|node()"/> | |
</xsl:copy> | |
</xsl:template> | |
<xsl:template match="marc:collection/marc:record/marc:datafield[@tag='852']"> | |
<xsl:variable name="filename"> | |
<xsl:value-of select="translate(../marc:datafield[@tag='094']/marc:subfield[@code='a']/text(), '.', '-')"/> | |
</xsl:variable> | |
<xsl:variable name="eightfivetwo"> | |
<xsl:value-of select="../marc:datafield[@tag='094']/marc:subfield[@code='a']"/> | |
</xsl:variable> | |
<xsl:element name="datafield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="tag">852</xsl:attribute> | |
<xsl:attribute name="ind1"> </xsl:attribute> | |
<xsl:attribute name="ind2"> </xsl:attribute> | |
<!-- copy subfields --> | |
<xsl:for-each select="marc:subfield"> | |
<xsl:copy-of select="."/> | |
</xsl:for-each> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">h</xsl:attribute> | |
<xsl:value-of select="$eightfivetwo"/> | |
</xsl:element> | |
</xsl:element> | |
<!-- add tiff, jp2, and web derivatives --> | |
<xsl:element name="datafield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="tag">856</xsl:attribute> | |
<xsl:attribute name="ind1">4</xsl:attribute> | |
<xsl:attribute name="ind2">6</xsl:attribute> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">u</xsl:attribute> | |
<xsl:text>lo-</xsl:text> | |
<xsl:value-of select="$filename"/> | |
<xsl:text>.tif</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">q</xsl:attribute> | |
<xsl:text>image/tiff</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">z</xsl:attribute> | |
<xsl:text>Artwork</xsl:text> | |
</xsl:element> | |
</xsl:element> | |
<xsl:element name="datafield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="tag">856</xsl:attribute> | |
<xsl:attribute name="ind1">4</xsl:attribute> | |
<xsl:attribute name="ind2">6</xsl:attribute> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">u</xsl:attribute> | |
<xsl:text>lo-</xsl:text> | |
<xsl:value-of select="$filename"/> | |
<xsl:text>.jpf</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">q</xsl:attribute> | |
<xsl:text>image/jpf</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">z</xsl:attribute> | |
<xsl:text>Artwork</xsl:text> | |
</xsl:element> | |
</xsl:element> | |
<xsl:element name="datafield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="tag">856</xsl:attribute> | |
<xsl:attribute name="ind1">4</xsl:attribute> | |
<xsl:attribute name="ind2">6</xsl:attribute> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">u</xsl:attribute> | |
<xsl:text>lo-</xsl:text> | |
<xsl:value-of select="$filename"/> | |
<xsl:text>.jpg</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">q</xsl:attribute> | |
<xsl:text>image/jpeg</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">z</xsl:attribute> | |
<xsl:text>Artwork</xsl:text> | |
</xsl:element> | |
</xsl:element> | |
<xsl:element name="datafield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="tag">856</xsl:attribute> | |
<xsl:attribute name="ind1">4</xsl:attribute> | |
<xsl:attribute name="ind2">6</xsl:attribute> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">u</xsl:attribute> | |
<xsl:text>lo-</xsl:text> | |
<xsl:value-of select="$filename"/> | |
<xsl:text>-200px.jpg</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">q</xsl:attribute> | |
<xsl:text>image/jpeg</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">z</xsl:attribute> | |
<xsl:text>Web_derivative_200px</xsl:text> | |
</xsl:element> | |
</xsl:element> | |
<xsl:element name="datafield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="tag">856</xsl:attribute> | |
<xsl:attribute name="ind1">4</xsl:attribute> | |
<xsl:attribute name="ind2">6</xsl:attribute> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">u</xsl:attribute> | |
<xsl:text>lo-</xsl:text> | |
<xsl:value-of select="$filename"/> | |
<xsl:text>-800px.jpg</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">q</xsl:attribute> | |
<xsl:text>image/jpeg</xsl:text> | |
</xsl:element> | |
<xsl:element name="subfield" namespace="http://www.loc.gov/MARC21/slim"> | |
<xsl:attribute name="code">z</xsl:attribute> | |
<xsl:text>Web_derivative_800px</xsl:text> | |
</xsl:element> | |
</xsl:element> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment