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

<!--
   Name: 11_gmd:identificationInfo.xsl 
   Author:  Matthew J. McCready
   Date:  20111012
   Description:  XSLT stylesheet that transforms the following MIF elements with a 'citation' attribute into their respective ISO elements. This style sheet calls
   on  eight templates located in other stylesheets: CI_PresentationFormCode, MD_ProgressCode, MD_MaintenanceFrequencyCode, NonISOKeywords, 
   MD_SpatialRepresentationTypeCode, ISO_TopicCategories, BegDateTemp  and EndDateTemp. The CI_PresentationFormCode template, located in the 
   CI_PresentationFormCode.xsl stylesheet, transforms the value in the  citation/citeinfo/geoform (Geospatial Data Presentation Form) element into the correct 
   CI_PresentationFormCode codeList value. The MD_ProgressCode template, located in the MD_ProgressCode.xsl styleshet, transforms the value in the  timeperd/current
   (Currentness Reference) element into the correct MD_ProgressCode codeList value. The MD_MaintenanceFrequencyCode template, located in the
   MD_MaintenanceFrequencyCode.xsl stylesheet, transforms the element in the /MIF/Maintenance_and_Update_Frequency element into a value in the
   MD_MaintenanceFrequencyCode code list. The NonISOKeywords template, located in the NonISOKeywords.xsl stylesheet, transforms the values stored in the 
   Theme_Keyword and Theme_Keyword MIF elements to the gmd:descriptiveKeywords element. The MD_SpatialRepresentationTypeCode template, stored in the 
   MD_SpatialRepresentationTypeCode.xsl stylesheet, transforms the value in the MIF/Direct_Spatial_Reference element into the correct 
   MD_SpatialRepresentationTypeCode.xsl codeList value. The ISO_TopicCategories template, located in the stylesheet, transforms the value in the keywords/theme that
   are related to the ISO Topic Categories  to the ISO_TopicCategories element. The BegDateTemp template, located in the DateFormat.xsl stylesheet, formats the date
   stored in the /MIF/Beginning_Date[time period of content] MIF element and inserts in the gml:beginPosition ISO element. Finally, the EndDateTemp template, also
   stored in the  DateFormat.xsl stylesheet, formats the value stored  in the /MIF/Ending_Date[time period of content]  element and inserts in the gml:endPosition 
   ISO element. 
   Modification History:
      Initial   Date      Change Request ID   Description
      MMC       12/04/2013                    Inserted a call to the NGDA template to handle National Geospatial Data Asset OMB themes.
      MMC       12/04/2013                    Ensured that all calls to the ISO codelists have the correct URL 
      MMC       12/12/2013                    Inserted a call to the spatialRepresentationType template, which is in the  MD_SpatialRepresentationType.xsl stylesheet.
                                               Spatial reference information is now handled in the metadata file.
                           
-->


<!-- 
List of Related Templates and associated stylesheets
Template                                     Stylesheet/File
CI_PresentationFormCode                      CI_PresentationFormCode.xsl
MD_ProgressCode                              MD_ProgressCode.xsl
MD_MaintenanceFrequencyCode                  MD_MaintenanceFrequencyCode.xsl
NonISOKeywords                               NonISOKeywords.xsl
MD_SpatialRepresentationTypeCode             MD_SpatialRepresentationTypeCode.xsl
ISO_TopicCategories                          ISO_TopicCategories.xsl
BegDateTemp                                 ExtraDataQualityTemplate.xsl
EndDateTemp                                 ExtraDataQualityTemplate.xsl
NGDA_Themes                                  NGDA_Themes.xsl
-->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gfc="http://www.isotc211.org/2005/gfc"
   xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gmx="http://www.isotc211.org/2005/gmx"
   xmlns:gsr="http://www.isotc211.org/2005/gsr" xmlns:gss="http://www.isotc211.org/2005/gss"
   xmlns:gts="http://www.isotc211.org/2005/gts" xmlns:gml="http://www.opengis.net/gml/3.2"
   xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema">

   <xsl:import href="../MIF2ISO/NGDA_Themes.xsl"/>
   <xsl:import href="../MIF2ISO/IdPointOfContact.xsl"/>
   <xsl:import href="../MIF2ISO/MD_SpatialRepresentationType.xsl"/>
   <xsl:import href="../MIF2ISO/03_gmd_characterSet.xsl"/>

   
   <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"/>


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

      <xsl:comment> This part represents Section 1 of the FGDC Metadata Standard </xsl:comment>
      <xsl:text>
</xsl:text>


      <xsl:element name="gmd:identificationInfo">
         <xsl:element name="gmd:MD_DataIdentification">
            <xsl:element name="gmd:citation">
               <xsl:element name="gmd:CI_Citation">

                  <xsl:element name="gmd:title">
                     <xsl:element name="gco:CharacterString">
                        <xsl:apply-templates select="//MIF/Title[@section='citation']"/>
                     </xsl:element>
                  </xsl:element>
                  <!-- gmd:title -->


                  <xsl:element name="gmd:date">
                     <xsl:element name="gmd:CI_Date">
                        <xsl:text>
</xsl:text>
                        <xsl:comment> This is the publication date </xsl:comment>
                        <xsl:text>
</xsl:text>
                        <xsl:element name="gmd:date">

                           <xsl:element name="gco:Date">
                              <xsl:value-of select="//MIF/Publication_Date[@section='citation']"/>
                           </xsl:element>
                           <!--gco:date -->
                        </xsl:element>
                        <!-- gmd:date -->

                        <xsl:element name="gmd:dateType">
                           <xsl:element name="gmd:CI_DateTypeCode">
                              <xsl:attribute name="codeList"
                                 >http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode</xsl:attribute>
                              <xsl:attribute name="codeListValue">publication</xsl:attribute>
                              <xsl:attribute name="codeSpace">002</xsl:attribute> publication </xsl:element>
                           <!-- gmd:CI_DateTypeCode -->
                        </xsl:element>
                        <!-- gmd:dateType -->

                     </xsl:element>
                     <!-- gmd:CI_Date -->
                  </xsl:element>
                  <!-- gmd:date -->

                  <!-- <xsl:comment>Edition Check  </xsl:comment> -->
                  <xsl:text>
</xsl:text>
                  <xsl:if test="//MIF/Edition[@section='citation']">
                     <xsl:element name="gmd:edition">
                        <xsl:element name="gco:CharacterString">
                           <xsl:value-of select="//MIF/Edition[@section='citation']"/>
                        </xsl:element>
                        <!-- gco:CharacterString -->
                     </xsl:element>
                     <!-- gmd:edition -->
                  </xsl:if>

                  <!-- <xsl:comment> calling CitedResponsibleParty</xsl:comment> -->
                  <xsl:call-template name="CitedResponsibleParty"/>
                  <!--  <xsl:comment> done with CitedResponsibleParty</xsl:comment> -->


               </xsl:element>
               <!-- gmd:CI_Citation -->
            </xsl:element>
            <!-- gmd:citation-->

            <xsl:element name="gmd:abstract">
               <xsl:element name="gco:CharacterString">
                  <xsl:value-of select="//MIF/Abstract"/>
               </xsl:element>
               <!-- gco:CharacterString -->
            </xsl:element>
            <!-- gmd:abstract -->

            <xsl:element name="gmd:purpose">
               <xsl:element name="gco:CharacterString">
                  <xsl:value-of select="//MIF/Purpose"/>
               </xsl:element>
               <!-- gco:CharacterString -->
            </xsl:element>
            <!-- gmd:purpose -->

            <xsl:call-template name="pointOfContact"/>




            <xsl:if test="//MIF/Maintenance_and_Update_Frequency">
               <xsl:text>
</xsl:text>
               <xsl:text>
</xsl:text>
               <xsl:element name="gmd:resourceMaintenance">
                  <xsl:element name="gmd:MD_MaintenanceInformation">

                     <xsl:call-template name="MD_MaintenanceFrequencyCode"/>
                  </xsl:element>
                  <!-- gmd:MD_MaintenanceInformation -->
               </xsl:element>
               <!-- gmd:resourceMaintenance -->
            </xsl:if>



            <xsl:if test="//MIF/Theme_Keyword_Thesaurus">
               <xsl:call-template name="NonISOKeywords"/>
            </xsl:if>

            <xsl:call-template name="NonISOKeywordsGID1"/>


            <xsl:if test="/MIF/Place_Keyword_Thesaurus[@gid='2']">
               <xsl:call-template name="NonISOKeywordsGID2"/>
            </xsl:if>

            <xsl:if test="/MIF/Place_Keyword_Thesaurus[@gid='3']">
               <xsl:call-template name="NonISOKeywordsGID3"/>
            </xsl:if>

            <xsl:call-template name="NGDAThemes"/>

            <xsl:element name="gmd:resourceConstraints">
               <xsl:element name="gmd:MD_LegalConstraints">

                  <xsl:element name="gmd:accessConstraints">

                     <xsl:element name="gmd:MD_RestrictionCode">
                        <xsl:attribute name="codeList"
                           >http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_RestrictionCode</xsl:attribute>
                        <xsl:attribute name="codeListValue">otherRestrictions</xsl:attribute>
                        <xsl:attribute name="codeSpace">008 </xsl:attribute> otherRestrictions </xsl:element>
                     <!-- gmd:MD_RestrictionCode -->
                  </xsl:element>
                  <!-- gmd:accessConstraints -->


                  <xsl:element name="gmd:useConstraints">
                     <xsl:element name="gmd:MD_RestrictionCode">
                        <xsl:attribute name="codeList"
                           >http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_RestrictionCode</xsl:attribute>
                        <xsl:attribute name="codeListValue">otherRestrictions</xsl:attribute>
                        <xsl:attribute name="codeSpace">008 </xsl:attribute>
                     </xsl:element>
                     <!-- gmd:MD_RestrictionCode -->
                  </xsl:element>
                  <!-- gmd:useConstraints -->



                  <xsl:if test="/MIF/Access_Constraints">
                     <xsl:element name="gmd:otherConstraints">
                        <xsl:element name="gco:CharacterString"> Access Constraints: <xsl:value-of
                              select="/MIF/Access_Constraints"/>
                        </xsl:element>
                        <!-- gco:CharacterString -->
                     </xsl:element>
                     <!-- gmd:otherConstraints -->
                  </xsl:if>

                  <xsl:if test="/MIF/Use_Constraints">
                     <xsl:element name="gmd:otherConstraints">
                        <xsl:element name="gco:CharacterString"> Use Constraints:<xsl:value-of
                              select="/MIF/Use_Constraints"/>
                        </xsl:element>
                        <!-- gco:CharacterString -->
                     </xsl:element>
                     <!-- gmd:otherConstraints -->
                  </xsl:if>


               </xsl:element>
               <!-- gmd:MD_LegalConstraints -->
            </xsl:element>
            <!-- gmd:resourceConstraints -->

            <xsl:text>
            </xsl:text>
            <xsl:comment> This is from the Direct Spatial Reference from Chapter 3 </xsl:comment>
            <xsl:text>
            </xsl:text>

            <xsl:call-template name="spatialRepresentationType"/>

            <xsl:element name="gmd:language">
               <xsl:choose>
                  <xsl:when test="//metadata/idinfo/Metadata_Language">
                     <xsl:element name="gco:CharacterString">
                        <xsl:value-of select="//metadata/idinfo/Metadata_Language"/>
                     </xsl:element>
                  </xsl:when>
                  <xsl:otherwise>
                     <xsl:element name="gco:CharacterString">eng</xsl:element>
                  </xsl:otherwise>
               </xsl:choose>
            </xsl:element>
            <!-- language -->

            <xsl:call-template name="Metadata_Character_Set"/>
            <!-- <xsl:comment> calling the ISO template </xsl:comment> -->
            <xsl:call-template name="ISO_TopicCategories"/>

            <xsl:if test="/MIF/Technical_Prerequisites">
               <xsl:element name="gmd:environmentDescription">
                  <xsl:element name="gco:CharacterString">
                     <xsl:value-of select="/MIF/Technical_Prerequisites"/>
                  </xsl:element>
               </xsl:element>
            </xsl:if>

            <xsl:element name="gmd:extent">
               <xsl:element name="gmd:EX_Extent">
                  <xsl:attribute name="id">boundingExtent</xsl:attribute>

                  <xsl:element name="gmd:geographicElement">
                     <xsl:element name="gmd:EX_GeographicBoundingBox">
                        <xsl:attribute name="id">boundingGeographicBoundingBox</xsl:attribute>

                        <xsl:element name="gmd:westBoundLongitude">
                           <xsl:element name="gco:Decimal">
                              <xsl:value-of select="/MIF/West_Bounding_Coordinate"/>
                           </xsl:element>
                           <!-- gco:Decimal -->
                        </xsl:element>
                        <!-- gmd:westBoundLongitude -->


                        <xsl:element name="gmd:eastBoundLongitude">
                           <xsl:element name="gco:Decimal">
                              <xsl:value-of select="/MIF/East_Bounding_Coordinate"/>
                           </xsl:element>
                           <!-- gco:Decimal -->
                        </xsl:element>
                        <!-- gmd:eastBoundLongitude -->


                        <xsl:element name="gmd:southBoundLatitude">
                           <xsl:element name="gco:Decimal">
                              <xsl:value-of select="/MIF/North_Bounding_Coordinate"/>
                           </xsl:element>
                           <!-- gco:Decimal -->
                        </xsl:element>
                        <!-- gmd:southBoundLongitude -->


                        <xsl:element name="gmd:northBoundLatitude">
                           <xsl:element name="gco:Decimal">
                              <xsl:value-of select="/MIF/South_Bounding_Coordinate"/>
                           </xsl:element>
                           <!-- gco:Decimal -->
                        </xsl:element>
                        <!-- gmd:southBoundLongitude -->


                     </xsl:element>
                     <!-- gmd:EX_GeographicBoundingBox -->
                  </xsl:element>
                  <!-- gmd:geographicElement -->


                  <xsl:element name="gmd:temporalElement">
                     <xsl:element name="gmd:EX_TemporalExtent">
                        <xsl:attribute name="id">boundingTemporalExtent</xsl:attribute>
                        <!-- <xsl:attribute name="gml:id">boundingTimePeriodExtent</xsl:attribute> -->
                        <xsl:element name="gmd:extent">
                           <xsl:element name="gml:TimePeriod">
                              <xsl:attribute name="gml:id">boundingTemporalExtentA</xsl:attribute>

                              <xsl:element name="gml:description">
                                 <xsl:value-of select="/MIF/Source_Currentness_Reference"/>
                              </xsl:element>

                              <xsl:call-template name="begDateFormatTimePeriod"/>
                              <xsl:call-template name="endDateFormatTimePeriod"/>

                           </xsl:element>
                           <!-- gml:TimePeriod -->
                        </xsl:element>
                        <!-- gmd:extent -->
                     </xsl:element>
                     <!-- gmd:EX_TemporalExtent -->
                  </xsl:element>
                  <!-- gmd:temporalElement -->
               </xsl:element>
               <!-- gmd:EX_Extent -->
            </xsl:element>
            <!-- gmd:extent -->


            <xsl:if test="/MIF/Supplemental_Information">
               <xsl:element name="gmd:supplementalInformation">
                  <xsl:element name="gco:CharacterString">
                     <xsl:value-of select="/MIF/Supplemental_Information"/>
                  </xsl:element>
               </xsl:element>
            </xsl:if>
         </xsl:element>
         <!-- gmd:MD_DataIdentification -->
      </xsl:element>
      <!-- gmd:identificationInfo -->

      <!-- </xsl:if> -->




   </xsl:template>
</xsl:stylesheet>
