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

<!--
   Name:  10_gmd:referenceSystemInfo.xsl
   Author:  Matthew J. McCready
   Date:  20111012
   Description:  XSLT stylesheet that transforms the //MIF/Indirect_Spatial_Reference MIF standard into the  
                 gmd:referenceSystemIdentifier element
   Modification History:
      Initial   Date      Change Request ID   Description
      MMc       4/16/2012                      Elimanated the ISO gmd:code element. This element is now handled by the ReferenceSystemCodes template.  
      MMC       12/04/2013                     Inserted the gmd:code element
      MMC       12/11/2013                     Inserted a choice structure so that the gmd:referenceSystemInfo does not appear if the Indirect_Spatial_Reference
                                                element is not in the MIF file.
      MMC       12/11/2013                     Changed the path of the ISO gmd:RS_Identifier so that it transforms the MIF Indirect_Spatial_Reference element                                         
-->


<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:template name="referenceSystemInfo" match="/">


      <!-- <xsl:if test="//MIF/Indirect_Spatial_Reference" or test="/MIF/Map_Projection_Name" > -->

      <xsl:choose>
         <xsl:when test="/MIF/Indirect_Spatial_Reference">

            <xsl:comment>This is the indirect spatial reference of section 3 and the Projection
               Information from Section 4 of the FGDC Standard</xsl:comment>
            <xsl:text>
         
      </xsl:text>

            <xsl:element name="gmd:referenceSystemInfo">
               <xsl:element name="gmd:MD_ReferenceSystem">
                  <xsl:element name="gmd:referenceSystemIdentifier">
                     <xsl:element name="gmd:RS_Identifier">

                        <xsl:element name="gmd:code">
                           <xsl:attribute name="gco:nilReason">unknown</xsl:attribute>
                           <!-- <xsl:call-template name="ReferenceSystemCodes"/> -->
                        </xsl:element>
                        <!-- gmd:code -->

                        <xsl:if test="//MIF/Indirect_Spatial_Reference">
                           <xsl:element name="gmd:codeSpace">
                              <xsl:element name="gco:CharacterString">
                                 <xsl:value-of select="/MIF/Indirect_Spatial_Reference"/>
                              </xsl:element>
                              <!-- gco:CharacterString -->
                           </xsl:element>
                           <!-- gmd:codeSpace -->
                        </xsl:if>

                     </xsl:element>
                     <!-- gmd:RS_Identifier -->
                  </xsl:element>
                  <!-- gmd:referenceSystemIdentifier -->
               </xsl:element>
               <!-- gmd:MD_ReferenceSystem -->
            </xsl:element>
            <!-- gmd:referenceSystemInfo -->
            <!-- </xsl:if> -->
         </xsl:when>
      </xsl:choose>
   </xsl:template>
</xsl:stylesheet>
