<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:import href="keyval-common.xsl" />

  <xsl:output method="text" indent="no"/>

  <xsl:preserve-space elements="*"/>


<!-- Process contents -->

<xsl:template match="keyval">
  <xsl:text>#
# </xsl:text>
  <xsl:value-of select="(@namespace)"/>
  <xsl:text>::</xsl:text>
  <xsl:value-of select="(@class)"/>
  <xsl:text> configuration file
#
</xsl:text>

  <xsl:apply-templates select="*"/>

</xsl:template>

<xsl:template match="keyval/*">

  <xsl:text>
# </xsl:text>
  <xsl:value-of select="key"/>
  <xsl:text>&#09;</xsl:text>
  <xsl:value-of select="(@type)"/>
  <xsl:text>
#   </xsl:text>
  <xsl:value-of select="summary"/>
  <xsl:text>
#
</xsl:text>

  <xsl:if test="(@min)">
    <xsl:text>#   Minimum: </xsl:text>
    <xsl:value-of select="(@min)"/>
    <xsl:text>
</xsl:text>
  </xsl:if>

  <xsl:if test="(@max)">
    <xsl:text>#   Maximum: </xsl:text>
    <xsl:value-of select="(@max)"/>
    <xsl:text>
</xsl:text>
  </xsl:if>

  <xsl:if test="@default != 'REQUIRED'">
    <xsl:text>#   Default: </xsl:text>
    <xsl:value-of select="key"/>
    <xsl:text>&#09;</xsl:text>
    <xsl:call-template name="format-cctype-value">
      <xsl:with-param name="cctype" select="(@cctype)" />
      <xsl:with-param name="value" select="(@default)" />
    </xsl:call-template>
    <xsl:text>
</xsl:text>
  </xsl:if>

  <xsl:if test="@type = 'DATE'">
    <xsl:text>#
# Dates need to appear in the form specified by the nlib::Date class.
# They need to be entered in UTC to the nanosecond resolution within
# this file and have the form of:
#
#   "YYYY-MM-DD HH:MM:SS.nnnnnnnnn"
</xsl:text>
  </xsl:if>

  <xsl:choose>
    <xsl:when test="@default = 'REQUIRED'">
      <xsl:text>#
# Choose an appropriate value and uncomment the following line
# </xsl:text>
      <xsl:value-of select="key"/>
      <xsl:text>&#09;</xsl:text>
      <xsl:choose>
        <xsl:when test="@type = 'TEXT'">
          <xsl:text>"YOUR VALUE"</xsl:text>
        </xsl:when>
        <xsl:when test="@type = 'DATE'">
          <xsl:text>"YYYY-MM-DD HH:MM:SS.sssssssss"</xsl:text>
        </xsl:when>
        <xsl:when test="@type = 'HOST'">
          <xsl:text>"host.domain"</xsl:text>
        </xsl:when>
        <xsl:when test="@type = 'FILE'">
          <xsl:text>"/path/file.ext"</xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="(@type)"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>

    <xsl:otherwise>
      <xsl:text>#
</xsl:text>
      <xsl:value-of select="key"/>
      <xsl:text>&#09;</xsl:text>
      <xsl:call-template name="format-cctype-value" >
        <xsl:with-param name="cctype" select="(@cctype)" />
        <xsl:with-param name="value" select="(@default)" />
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>

  <xsl:text>
</xsl:text>

</xsl:template>

</xsl:stylesheet>
