<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:Locale="urn:Locale-namespace">

  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

  <xsl:include href="DefaultPrint-r102.xsl"/>
  <xsl:param name="printtype">Full</xsl:param>

  <xsl:variable name="TheSchema" select="document('AltusA30FL-Report-r100.xsd')"/>
  <xsl:variable name="LanguageSubfolder" select="Locale:LanguageSubfolder()"/>
  <xsl:variable name="ResourceFile" select="concat($LanguageSubfolder,'\\AltusA30FL-Resource-r100.xml')"/>
  <xsl:variable name="TheResources" select="document(string($ResourceFile))"/>
  <xsl:variable name="NativePressureUnits">psi</xsl:variable>


  <xsl:template match="/*">
		<xsl:element name="AltusA30FLReport">

			<xsl:apply-templates/>

		</xsl:element>

	</xsl:template>
	<xsl:template match="Messages">
		<xsl:if test="count(child::*) > 0">
			<xsl:element name="FieldList">
				<xsl:element name="Title">Messages</xsl:element>
				<xsl:apply-templates/>
			</xsl:element>

		</xsl:if>
	</xsl:template>
	<xsl:template match="Message">
		<xsl:element name="Field">
			<xsl:attribute name="name">
				<xsl:value-of select="position()"/>
				<xsl:text>. </xsl:text>
			</xsl:attribute>
			<xsl:attribute name="type">String</xsl:attribute>
			<xsl:value-of select="."/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="GainChanged|LampChanged">
		<xsl:call-template name="Emit-Field-Value-Prompt">
			<xsl:with-param name="InputVar" select="name()"/>
			<xsl:with-param name="InputType">String</xsl:with-param>
			<xsl:with-param name="InputPrecision">0</xsl:with-param>
			<xsl:with-param name="InputValue">
				<xsl:choose>
			   		<xsl:when test=".='true'" >Yes</xsl:when>
			   		<xsl:otherwise>No</xsl:otherwise>
				</xsl:choose>
			</xsl:with-param>
			<xsl:with-param name="InputPrompt">None</xsl:with-param>
			<xsl:with-param name="InputUnits">None</xsl:with-param>
		</xsl:call-template>
	</xsl:template>

  <xsl:template match="TemperatureCompensation">
    <xsl:if test="//TemperatureCompensation = 'true'" >
      <xsl:call-template name="Emit"/>
    </xsl:if>
  </xsl:template>
  
  <xsl:template match="TemperatureCompensationEnabled">
    <xsl:if test="//TemperatureCompensationEnabled = 'true'" >
      <xsl:call-template name="Emit"/>
    </xsl:if>
  </xsl:template>

  <xsl:template match="TemperatureCompensationFactor">
    <xsl:if test="//TemperatureCompensationEnabled = 'true'" >
      <xsl:call-template name="Emit"/>      
    </xsl:if>
    <xsl:text disable-output-escaping="yes">&lt;/FieldList&gt;</xsl:text>
  </xsl:template>

  <!--
		*************************************************************************************************************************
		Emit-Field-Value
		Generate the output for a single parameter in the method, substituting the supplied value string
		*************************************************************************************************************************
-->
  <!--<xsl:template name="Emit-Field-Value-Prompt">
		<xsl:param name="InputVar"/>
		<xsl:param name="InputType"/>
		<xsl:param name="InputPrecision"/>
		<xsl:param name="InputValue" />
		<xsl:param name="InputPrompt" />
		<xsl:param name="InputUnits" />

		 Get the variable name (prompt) for output; default to the element name if no Prompt property is defined 
		<xsl:variable name="PromptProperty">
			<xsl:choose>
				<xsl:when test="$InputPrompt='None'">
					<xsl:value-of  select="$TheSchema//xsd:element[@name=$InputVar]//xsd:has-property[@name='Prompt']/@value"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$InputPrompt"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
	
		<xsl:variable name="Prompt">
			<xsl:choose>
				<xsl:when test="string-length($PromptProperty) > 0">
					<xsl:value-of select="$PromptProperty"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="name()"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:element name="Field">

			<xsl:attribute name="name">
				<xsl:value-of select="$Prompt"/>
			</xsl:attribute>
				
			<xsl:attribute name="type">
				<xsl:value-of select="$InputType"/>
			</xsl:attribute>

			<xsl:if test="$InputType='Float'">
				<xsl:attribute name="precision">
					<xsl:value-of select="$InputPrecision" />
				</xsl:attribute>
			</xsl:if>

			 Get the units descriptor and output it only if found 
			<xsl:variable name="Units">
				<xsl:choose>
					<xsl:when test="$InputUnits='None'">
						<xsl:value-of select="$TheSchema//xsd:element[@name=$InputVar]//xsd:has-property[@name='Units']/@value"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$InputUnits"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<xsl:if test="string-length($Units) > 0">
				<xsl:attribute name="units">
					<xsl:choose>
						<xsl:when test="$Units=$NativePressureUnits">
							<xsl:value-of select="$CustomPressureUnits"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="$Units"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:attribute>
			</xsl:if>
				
			<xsl:value-of select="$InputValue"/>
			
		</xsl:element>

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