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

<xsl:stylesheet version="2.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"
    xmlns:fn="http://www.w3.org/2005/xpath-functions"
    xmlns:grp="http://www.altova.com/Mapforce/grouping"
    exclude-result-prefixes="fn grp xs xsi xsl xd" xmlns="http://www.isotc211.org/2005/gfc"
    xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">

    <xd:doc scope="stylesheet">
        <xd:desc>
            <xd:p><xd:b>Created on:</xd:b> Nov 22, 2013</xd:p>
            <xd:p><xd:b>Author:</xd:b> mccre004</xd:p>
            <xd:p>This stylesheet handles the gml:BaseUnit attribute for the Feature Catalog
                file</xd:p>
        </xd:desc>
    </xd:doc>

    <!-- <gml:BaseUnit>
        <xsl:attribute name="gml:id">
        <xsl:sequence
        select="xs:string(xs:ID('baseUnit'))"/>
        </xsl:attribute>
        <gml:identifier>
        <xsl:attribute name="codeSpace">
        <xsl:sequence
        select="xs:string(xs:anyURI(xs:string(.)))"/>
        </xsl:attribute>
        </gml:identifier>
        <gml:unitsSystem>
        <xsl:attribute name="nilReason">
        <xsl:sequence
        select="xs:string(xs:string('unknown'))"/>
        </xsl:attribute>
        </gml:unitsSystem> 
        <xsl:variable name="FinalTitle"
        select="concat('Feature Catalog for ', $Part1 )"/>
    -->

    <xsl:template name="baseUnit">
        <xsl:variable name="baseunit" select="/metadata/eainfo/detailed/attr/attrlabl"/>
        <xsl:variable name="newBaseUnit" select="concat('baseUnit',$baseunit)"/>
        <xsl:element name="gml:BaseUnit">
            <xsl:attribute name="gml:id">
                <xsl:sequence select="xs:string(xs:ID($newBaseUnit))"/>
            </xsl:attribute>
            <xsl:element name="gml:identifier">
                <xsl:attribute name="codeSpace">
                    <xsl:sequence select="xs:string(xs:anyURI(xs:string(.)))"/>
                </xsl:attribute>
            </xsl:element>
            <xsl:element name="gml:unitsSystem">
                <xsl:attribute name="nilReason">
                    <xsl:sequence
                        select="xs:string(xs:string('unknown'))"/>
                </xsl:attribute>
            </xsl:element>
        </xsl:element>

    </xsl:template>



</xsl:stylesheet>
