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


<!--
   Name:  06_distinfo.xsl
   Author:  Matthew J. McCready
   Date:  20070115
   Description:  XSLT stylesheet that transforms Section 6 of an
                 FGDC format file into a mif file
   Modification History:
      Initial   Date      Change Request ID   Description
      MMC       20070115   N/A                Initial Version
      MMC       20070500   N/A                Made Ordering_Instructions, Resource_Description, Network_Resource_Name, 
                                               Offline_Media and Technical_Prerequisites optional
      MMC       20070500   N/A                Modified so that the Digital_Form, Standard_Order_Process and Network_Resource_Name elements loop.
-->






<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"/>

	<xsl:template name="distinfo" match="/">

		<xsl:if test="//distinfo">

			<xsl:element name="Contact_Organization">
				<!-- mif name -->
				<xsl:attribute name="section">distributor</xsl:attribute>
				<xsl:apply-templates select="//distinfo/distrib/cntinfo/cntorgp/cntorg"/>
				<!-- FGDC path -->
			</xsl:element>

			<xsl:element name="Address_Type">
				<!-- mif name -->
				<xsl:attribute name="section">distributor</xsl:attribute>mailing</xsl:element>

			<xsl:element name="Address">
				<!-- mif name -->
				<xsl:attribute name="section">distributor</xsl:attribute>
				<xsl:attribute name="gid1">1</xsl:attribute>
				<xsl:apply-templates select="//distinfo/distrib/cntinfo/cntaddr/address"/>
				<!-- FGDC path -->
			</xsl:element>

			<xsl:element name="City">
				<!-- mif name -->
				<xsl:attribute name="section">distributor</xsl:attribute>
				<xsl:apply-templates select="//distinfo/distrib/cntinfo/cntaddr/city"/>
				<!-- FGDC path -->
			</xsl:element>

			<xsl:element name="State_or_Province">
				<!-- mif name -->
				<xsl:attribute name="section">distributor</xsl:attribute>
				<xsl:apply-templates select="//distinfo/distrib/cntinfo/cntaddr/state"/>
				<!-- FGDC path -->
			</xsl:element>

			<xsl:element name="Postal_Code">
				<!-- mif name -->
				<xsl:attribute name="section">distributor</xsl:attribute>
				<xsl:apply-templates select="//distinfo/distrib/cntinfo/cntaddr/postal"/>
				<!-- FGDC path -->
			</xsl:element>

			<xsl:element name="Country">
				<!-- mif name -->
				<xsl:attribute name="section">distributor</xsl:attribute>
				<xsl:apply-templates select="//distinfo/distrib/cntinfo/cntaddr/country"/>
				<!-- FGDC path -->
			</xsl:element>

			<xsl:element name="Contact_Voice_Telephone">
				<!-- mif name -->
				<xsl:attribute name="section">distributor</xsl:attribute>
				<xsl:attribute name="gid1">1</xsl:attribute>
				<xsl:apply-templates select="//distinfo/distrib/cntinfo/cntvoice"/>
				<!-- FGDC path -->
			</xsl:element>

			<xsl:element name="Contact_Facsimile_Telephone">
				<!-- mif name -->
				<xsl:attribute name="section">distributor</xsl:attribute>
				<xsl:apply-templates select="//distinfo/distrib/cntinfo/cntfax"/>
				<!-- FGDC path -->
			</xsl:element>

			<xsl:element name="Contact_Electronic_Mail_Address">
				<!-- mif name -->
				<xsl:attribute name="section">distributor</xsl:attribute>
				<xsl:apply-templates select="//distinfo/distrib/cntinfo/cntemail"/>
				<!-- FGDC path -->
			</xsl:element>

			<xsl:if test="//distinfo/resdesc">
				<xsl:element name="Resource_Description">
					<!-- mif name -->
					<xsl:apply-templates select="//distinfo/resdesc"/>
					<!-- FGDC path -->
				</xsl:element>
			</xsl:if>

			<xsl:element name="Distribution_Liability">
				<!-- mif name -->
				<xsl:apply-templates select="//distinfo/distliab"/>
				<!-- FGDC path -->
			</xsl:element>

			<xsl:for-each select="//distinfo/stdorder">
				<xsl:if test="//distinfo/stdorder/nondig">
					<xsl:element name="Non-Digital_Form">
						<!-- mif name -->
						<xsl:attribute name="section">distributor</xsl:attribute>
						<xsl:attribute name="gid1">1</xsl:attribute>
						<xsl:attribute name="gid2">1</xsl:attribute>
						<xsl:apply-templates select="//distinfo/stdorder/nondig"/>
						<!-- FGDC path -->
					</xsl:element>
				</xsl:if>


				 <xsl:if test="//distinfo/stdorder/digform"> 
				<xsl:for-each select="digform">
					<xsl:element name="Format_Name">
						<!-- mif name -->
						<xsl:attribute name="gid1">1</xsl:attribute>
						<xsl:attribute name="gid2">1</xsl:attribute>
						<xsl:apply-templates select="digtinfo/formname"/>
						<!-- FGDC path -->
					</xsl:element>

					<xsl:element name="File_Decompression_Technique">
						<!-- mif name -->
						<xsl:attribute name="gid1">1</xsl:attribute>
						<xsl:attribute name="gid2">1</xsl:attribute>
						<xsl:apply-templates select="digtinfo/filedec"/>
						<!-- FGDC path -->
					</xsl:element>

					<xsl:if test="digtinfo/transize">
                                         <xsl:element name="Transfer_Size">
						<!-- mif name -->
						<xsl:attribute name="gid1">1</xsl:attribute>
						<xsl:attribute name="gid2">1</xsl:attribute>
						<xsl:apply-templates select="digtinfo/transize"/>
						<!-- FGDC path -->
					</xsl:element>
                                        </xsl:if>

					<!-- <xsl:if test="digtopt/onlinopt"> -->

			<xsl:if test="digtopt/onlinopt/computer/networka/networkr">
			<xsl:for-each select="digtopt/onlinopt/computer/networka/networkr">
						<xsl:element name="Network_Resource_Name">
								<!-- mif name -->
						<xsl:attribute name="gid1">1</xsl:attribute>
						<xsl:attribute name="gid2">1</xsl:attribute>
						<xsl:attribute name="gid3">1</xsl:attribute>
						<xsl:apply-templates select="."/>
								<!-- FGDC path -->
						</xsl:element>
						</xsl:for-each>
					</xsl:if>
					<!--	</xsl:if> -->

					<xsl:if test="digtopt/offoptn">

						<xsl:if test="digtopt/offoptn/offmedia">
							<xsl:element name="Offline_Media">
								<!-- mif name -->
						<xsl:attribute name="gid1">1</xsl:attribute>
						<xsl:attribute name="gid2">1</xsl:attribute>
					<xsl:apply-templates select="digtopt/offoptn/offmedia"/>
								<!-- FGDC path -->
							</xsl:element>


						<xsl:for-each select="digtopt/offoptn/recfmt">
						<xsl:element name="Recording_Format">
									<!-- mif name -->
						<xsl:attribute name="gid1">1</xsl:attribute>
						<xsl:attribute name="gid2">1</xsl:attribute>
						<xsl:apply-templates select="."/>
									<!-- FGDC path -->
								</xsl:element>
							</xsl:for-each>
						</xsl:if>
					</xsl:if>
				</xsl:for-each>
				</xsl:if>

				<xsl:element name="Fees">
					<!-- mif name -->
					<xsl:attribute name="gid1">1</xsl:attribute>
					<xsl:apply-templates select="fees"/>
					<!-- FGDC path -->
				</xsl:element>

				<xsl:if test="//distinfo/stdorder/ordering">
					<xsl:element name="Ordering_Instructions">
						<!-- mif name -->
						<!-- <xsl:attribute name ="section">distributor</xsl:attribute> -->
						<xsl:attribute name="gid1">1</xsl:attribute>
						<xsl:apply-templates select="ordering"/>
						<!-- FGDC path -->
					</xsl:element>
				</xsl:if>
			</xsl:for-each>

			<xsl:if test="//distinfo/techpreq">
				<xsl:element name="Technical_Prerequisites">
					<!-- mif name -->
					<xsl:apply-templates select="//distinfo/techpreq"/>
					<!-- FGDC path -->
				</xsl:element>
			</xsl:if>
			<!-- //distinfo/techpreq -->
		</xsl:if>
		<!-- distinfo -->
	</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2005. Progress Software Corporation. All rights reserved.
<metaInformation>
<scenarios/><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/><MapperBlockPosition></MapperBlockPosition></MapperMetaTag>
</metaInformation>
-->
