<?xml version="1.0" encoding="UTF-8" ?>

<!--
   Name:  MD_MediumFormatCode.xsl 
   Author:  Matthew J. McCready
   Date:  20110623
   Description:  XSLT stylesheet that transforms the value in the  /metadata/distinfo/stdorder/digform/digtopt/offoptn[1]/recfmt (recording format) FGDC element
into the correct MD_MediumFormatCode codeList value ,which can be found of page 99 of the ISO standard, for the gmd:MD_MediumFormatCode ISO element and the 
 codeListValue and codeSpace attributes. This stylesheet is called by the 13_gmd:distributionInfo.xsl style sheet.
  Modification History:
Initial   Date      Change Request ID   Description

-->




<xsl:stylesheet version = "1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:gmd="http://www.isotc211.org/2005/gmd"
   xmlns:gco="http://www.isotc211.org/2005/gco" 
>
<xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"/>
<!-- <xsl:variable name ="MetDate"   select= "//metadata/metainfo/metd"/> -->
<!-- <xsl:variable name="SDTSPntVot" select="//metadata/spdoinfo/ptvctinf/sdtsterm/sdtstype"/> -->



<xsl:template name="MD_MediumFormatCode">
<xsl:variable name="CodeListLoc">http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_MediumFormatCode</xsl:variable>
<xsl:variable name="MediumFormatCode" select="//MIF/Recording_Format"/>
<xsl:choose>

<xsl:when test="$MediumFormatCode='cpio'">
	<xsl:element name="gmd:mediumFormat">
		<xsl:element name="gmd:MD_MediumFormatCode">
			<xsl:attribute name="codeList"><xsl:value-of select="$CodeListLoc"/></xsl:attribute>
			<xsl:attribute name="codeListValue">cpio</xsl:attribute>
			<xsl:attribute name="codeSpace">001 </xsl:attribute>
                         cpio
		</xsl:element><!-- gmd:MD_MediumFormatCode -->
	</xsl:element><!-- gmd:mediumFormat -->
</xsl:when>


<xsl:when test="$MediumFormatCode='tar'">
        <xsl:element name="gmd:mediumFormat">
                <xsl:element name="gmd:MD_MediumFormatCode">
                        <xsl:attribute name="codeList"><xsl:value-of select="$CodeListLoc"/></xsl:attribute>
                        <xsl:attribute name="codeListValue">tar</xsl:attribute>
                        <xsl:attribute name="codeSpace">002</xsl:attribute>
                         tar
                </xsl:element><!-- gmd:MD_MediumFormatCode -->
        </xsl:element><!-- gmd:mediumFormat -->
</xsl:when>

<xsl:when test="$MediumFormatCode='High Sierra'">
        <xsl:element name="gmd:mediumFormat">
                <xsl:element name="gmd:MD_MediumFormatCode">
                        <xsl:attribute name="codeList"><xsl:value-of select="$CodeListLoc"/></xsl:attribute>
                        <xsl:attribute name="codeListValue">highSierra</xsl:attribute>
                        <xsl:attribute name="codeSpace">003</xsl:attribute>
                         highSierra
                </xsl:element><!-- gmd:MD_MediumFormatCode -->
        </xsl:element><!-- gmd:mediumFormat -->
</xsl:when>

<xsl:when test="$MediumFormatCode='ISO 9660'">
        <xsl:element name="gmd:mediumFormat">
                <xsl:element name="gmd:MD_MediumFormatCode">
                        <xsl:attribute name="codeList"><xsl:value-of select="$CodeListLoc"/></xsl:attribute>
                        <xsl:attribute name="codeListValue">iso9660</xsl:attribute>
                        <xsl:attribute name="codeSpace">004</xsl:attribute>
                         iso9660
                </xsl:element><!-- gmd:MD_MediumFormatCode -->
        </xsl:element><!-- gmd:mediumFormat -->
</xsl:when>

<xsl:when test="$MediumFormatCode='ISO 9660 with Rock Ridge extensions'">
        <xsl:element name="gmd:mediumFormat">
                <xsl:element name="gmd:MD_MediumFormatCode">
                        <xsl:attribute name="codeList"><xsl:value-of select="$CodeListLoc"/></xsl:attribute>
                        <xsl:attribute name="codeListValue">iso9660RockRidge</xsl:attribute>
                        <xsl:attribute name="codeSpace">005</xsl:attribute>
                         iso9660RockRidge
                </xsl:element><!-- gmd:MD_MediumFormatCode -->
        </xsl:element><!-- gmd:mediumFormat -->
</xsl:when>

<xsl:when test="$MediumFormatCode='ISO 9660 with Apple HFS extensions'">
        <xsl:element name="gmd:mediumFormat">
                <xsl:element name="gmd:MD_MediumFormatCode">
                        <xsl:attribute name="codeList"><xsl:value-of select="$CodeListLoc"/></xsl:attribute>
                        <xsl:attribute name="codeListValue">iso9660AppleHFS</xsl:attribute>
                        <xsl:attribute name="codeSpace">006</xsl:attribute>
                         iso9660AppleHFS
                </xsl:element><!-- gmd:MD_MediumFormatCode -->
        </xsl:element><!-- gmd:mediumFormat -->
</xsl:when>

<xsl:when test="$MediumFormatCode='ISO 9660 MAC'">
        <xsl:element name="gmd:mediumFormat">
                <xsl:element name="gmd:MD_MediumFormatCode">
                        <xsl:attribute name="codeList"><xsl:value-of select="$CodeListLoc"/></xsl:attribute>
                        <xsl:attribute name="codeListValue">iso9660AppleHFS</xsl:attribute>
                        <xsl:attribute name="codeSpace">006</xsl:attribute>
                         iso9660AppleHFS
                </xsl:element><!-- gmd:MD_MediumFormatCode -->
        </xsl:element><!-- gmd:mediumFormat -->
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
