<?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:msxsl="urn:schemas-microsoft-com:xslt"
	xmlns:SQ="urn:SQ-namespace"
	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="NativePressureUnits">psi</xsl:variable>
 <xsl:variable name="TheSchema" select="document('AcquityTQ-Method-r100.xsd')"></xsl:variable>
 <xsl:variable name="LanguageSubfolder" select="Locale:LanguageSubfolder()"/>
 <xsl:variable name="ResourceFile" select="concat($LanguageSubfolder,'\\AcquityTQ-Resource-r100.xml')"/>
 <xsl:variable name="TheResources" select="document(string($ResourceFile))"></xsl:variable>

<!-- Don't emit event table if brief or summary report is requested -->
<xsl:template match="EventTable">
	<xsl:if test="$printtype = 'Full' or $printtype = 'Plain Text'">
		<xsl:if test="count(EventRow) > 0">
			<xsl:call-template name="Emit"/>
		</xsl:if>
	</xsl:if>
</xsl:template>

<xsl:template match="RunEvents">
	<xsl:if test="count(//EventTable/EventRow) > 0">
		<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'">
						<xsl:value-of  select="$TheResources//Enum[@id='BooleanYes_1A']/@value"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of  select="$TheResources//Enum[@id='BooleanNo_0A']/@value"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:with-param>
			<xsl:with-param name="InputPrompt">
				<xsl:value-of  select="$TheResources//Type[@name='tRunEvents']/@prompt"/>
			</xsl:with-param>
			<xsl:with-param name="InputUnits">None</xsl:with-param>
		</xsl:call-template>
	</xsl:if>
</xsl:template>

 <!-- Customize text for boolean Yes/No before end of FieldList -->
<xsl:template match="UseTuneVoltage | MRM/UseTuneEnergy | TargetScan/UseTuneEnergy">
	<xsl:variable name="FieldName">
		<xsl:value-of select="name()"/>
	</xsl:variable>
	<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'">
					<xsl:value-of  select="$TheResources//Enum[@id='BooleanYes_1A']/@value"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of  select="$TheResources//Enum[@id='BooleanNo_0A']/@value"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:with-param>
		<xsl:with-param name="InputPrompt">
			<xsl:value-of  select="$TheResources//Type[@name='xsd:boolean']/Prompt[@id=$FieldName]/@value"/>
		</xsl:with-param>
		<xsl:with-param name="InputUnits">None</xsl:with-param>
	</xsl:call-template>
</xsl:template>

<xsl:template match="ConeVoltageRamp/Enable">
	<xsl:variable name="FieldName">
		<xsl:value-of select="name()"/>
	</xsl:variable>
	<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'">
					<xsl:value-of  select="$TheResources//Enum[@id='BooleanYes_1A']/@value"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of  select="$TheResources//Enum[@id='BooleanNo_0A']/@value"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:with-param>
		<xsl:with-param name="InputPrompt">
			<xsl:value-of  select="$TheResources//Type[@name='tEnableConeRamp']/@prompt"/>
		</xsl:with-param>
		<xsl:with-param name="InputUnits">None</xsl:with-param>
	</xsl:call-template>
</xsl:template>

<xsl:template match="CollisionEnergyRamp/Enable">
	<xsl:variable name="FieldName">
		<xsl:value-of select="name()"/>
	</xsl:variable>
	<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'">
					<xsl:value-of  select="$TheResources//Enum[@id='BooleanYes_1A']/@value"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of  select="$TheResources//Enum[@id='BooleanNo_0A']/@value"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:with-param>
		<xsl:with-param name="InputPrompt">
			<xsl:value-of  select="$TheResources//Type[@name='tEnableEnergyRamp']/@prompt"/>
		</xsl:with-param>
		<xsl:with-param name="InputUnits">None</xsl:with-param>
	</xsl:call-template>
</xsl:template>

<xsl:template match="SIR/Channels">

	<xsl:variable name="UseTune">
		<xsl:value-of select="../../UseTuneVoltage"/>
	</xsl:variable>
	
	<xsl:element name="Table">

		<xsl:element name="Title">
			<xsl:value-of  select="$TheResources//Type[@name='tSIRChannels']/@prompt"/>
		</xsl:element>
			
		<xsl:element name="Columns">
			<xsl:for-each select="$TheSchema//xsd:complexType[@name='tChannels']//xsd:element[@name='Channel']//xsd:element">
				<!-- Omit the cone voltage column when using tune -->
				<xsl:if test="@name != 'ConeVoltage' or $UseTune = 'false' ">
					<xsl:call-template name="Insert-Column"/>
				</xsl:if>
			</xsl:for-each>
		</xsl:element>
			
		<xsl:element name="Rows">
			<xsl:for-each select="child::*">
				<xsl:element name="Row">
					<xsl:for-each select="*">
						<xsl:element name="Cell">
							<xsl:variable name="TheValue" select="."/>
              <xsl:variable name="Period" select="string('.')"/>
              <xsl:variable name="DecimalSymbol" select="Locale:DecimalSymbol()"/>


              <xsl:variable name="LocalValue">
                <xsl:choose>
                  <xsl:when test="string-length(substring-before(.,string('.')))=0">
                    <xsl:value-of select="."/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="concat(substring-before(.,$Period),$DecimalSymbol,substring-after(.,$Period))"/>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:variable>
              <xsl:variable name="LocalLookup" select="$TheResources//Enum[@id=$TheValue]/@value"/>
							<!-- Try to find a localized equivalent of the string interpreted as an ID -->
							<xsl:choose>
								<xsl:when test="string-length($LocalLookup)>0">
									<xsl:value-of select="$LocalLookup"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$LocalValue"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:element>
					</xsl:for-each>
				</xsl:element>
			</xsl:for-each>
		</xsl:element>

	</xsl:element>
</xsl:template>

<xsl:template match="MRM/Channels">

	<xsl:variable name="UseTuneV">
		<xsl:value-of select="../../UseTuneVoltage"/>
	</xsl:variable>
	
	<xsl:variable name="UseTuneE">
		<xsl:value-of select="../UseTuneEnergy"/>
	</xsl:variable>
	
	<xsl:element name="Table">

		<xsl:element name="Title">
			<xsl:value-of  select="$TheResources//Type[@name='tMRMChannels']/@prompt"/>
		</xsl:element>
			
		<xsl:element name="Columns">
			<xsl:for-each select="$TheSchema//xsd:complexType[@name='tMRMChannels']//xsd:element[@name='Channel']//xsd:element">
				<!-- Omit the cone voltage column when using tune -->
				<xsl:if test="@name != 'ConeVoltage' or $UseTuneV = 'false' ">
					<xsl:if test="@name != 'CollisionEnergy' or $UseTuneE = 'false' ">
						<xsl:call-template name="Insert-Column"/>
					</xsl:if>
				</xsl:if>
			</xsl:for-each>
		</xsl:element>
			
		<xsl:element name="Rows">
			<xsl:for-each select="child::*">
				<xsl:element name="Row">
					<xsl:for-each select="*">
						<xsl:element name="Cell">
              <xsl:variable name="TheValue" select="."/>
              <xsl:variable name="Period" select="string('.')"/>
              <xsl:variable name="DecimalSymbol" select="Locale:DecimalSymbol()"/>


              <xsl:variable name="LocalValue">
                <xsl:choose>
                  <xsl:when test="string-length(substring-before(.,string('.')))=0">
                    <xsl:value-of select="."/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="concat(substring-before(.,$Period),$DecimalSymbol,substring-after(.,$Period))"/>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:variable>
              <xsl:variable name="LocalLookup" select="$TheResources//Enum[@id=$TheValue]/@value"/>
              <!-- Try to find a localized equivalent of the string interpreted as an ID -->
              <xsl:choose>
                <xsl:when test="string-length($LocalLookup)>0">
                  <xsl:value-of select="$LocalLookup"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="$LocalValue"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:element>
					</xsl:for-each>
				</xsl:element>
			</xsl:for-each>
		</xsl:element>

	</xsl:element>
</xsl:template>

<xsl:template match="Scan/ConeVoltageRamp | TargetScan/ConeVoltageRamp">
	<xsl:element name="Table">
		<xsl:element name="Title">
			<xsl:value-of select="$TheResources//Type[@name='tConeVoltageRamp']/@prompt"/>
		</xsl:element>
		<xsl:element name="Columns">
			<xsl:element name="Column">
				<xsl:attribute name="name">
					<xsl:value-of select="$TheResources//Type[@name='tMass']/@prompt"/>
				</xsl:attribute>
				<xsl:attribute name="units">
					<xsl:value-of select="$TheResources//Type[@name='tMass']/@units"/>
				</xsl:attribute>
				<xsl:attribute name="type">Float</xsl:attribute>
				<xsl:attribute name="precision">
					<xsl:value-of select="$TheSchema//xsd:simpleType[@name='tMass']/xsd:restriction/xsd:fractionDigits/@value"/>
				</xsl:attribute>
			</xsl:element>
			<xsl:element name="Column">
				<xsl:attribute name="name">
					<xsl:value-of select="$TheResources//Type[@name='tConeVoltage']/@prompt"/>
				</xsl:attribute>
				<xsl:attribute name="units">
					<xsl:value-of select="$TheResources//Type[@name='tConeVoltage']/@units"/>
				</xsl:attribute>
				<xsl:attribute name="type">Float</xsl:attribute>
				<xsl:attribute name="precision">
					<xsl:value-of select="$TheSchema//xsd:simpleType[@name='tConeVoltage']/xsd:restriction/xsd:fractionDigits/@value"/>
				</xsl:attribute>
			</xsl:element>
		</xsl:element>
		<xsl:element name="Rows">
			<xsl:element name="Row">
				<xsl:element name="Cell">
					<xsl:value-of select="StartMass"/>
				</xsl:element>
				<xsl:element name="Cell">
					<xsl:value-of select="StartVoltage"/>
				</xsl:element>
			</xsl:element>
			<xsl:element name="Row">
				<xsl:element name="Cell">
					<xsl:value-of select="EndMass"/>
				</xsl:element>
				<xsl:element name="Cell">
					<xsl:value-of select="EndVoltage"/>
				</xsl:element>
			</xsl:element>
		</xsl:element>
	</xsl:element>
</xsl:template>

<xsl:template match="TargetScan/CollisionEnergyRamp">
	<xsl:element name="Table">
		<xsl:element name="Title">
			<xsl:value-of select="$TheResources//Type[@name='tCollisionEnergyRamp']/@prompt"/>
		</xsl:element>
		<xsl:element name="Columns">
			<xsl:element name="Column">
				<xsl:attribute name="name">
					<xsl:value-of select="$TheResources//Type[@name='tMass']/@prompt"/>
				</xsl:attribute>
				<xsl:attribute name="units">
					<xsl:value-of select="$TheResources//Type[@name='tMass']/@units"/>
				</xsl:attribute>
				<xsl:attribute name="type">Float</xsl:attribute>
				<xsl:attribute name="precision">
					<xsl:value-of select="$TheSchema//xsd:simpleType[@name='tMass']/xsd:restriction/xsd:fractionDigits/@value"/>
				</xsl:attribute>
			</xsl:element>
			<xsl:element name="Column">
				<xsl:attribute name="name">
					<xsl:value-of select="$TheResources//Type[@name='tCollisionEnergy']/@prompt"/>
				</xsl:attribute>
				<xsl:attribute name="units">
					<xsl:value-of select="$TheResources//Type[@name='tCollisionEnergy']/@units"/>
				</xsl:attribute>
				<xsl:attribute name="type">Float</xsl:attribute>
				<xsl:attribute name="precision">
					<xsl:value-of select="$TheSchema//xsd:simpleType[@name='tCollisionEnergy']/xsd:restriction/xsd:fractionDigits/@value"/>
				</xsl:attribute>
			</xsl:element>
		</xsl:element>
		<xsl:element name="Rows">
			<xsl:element name="Row">
				<xsl:element name="Cell">
					<xsl:value-of select="StartMass"/>
				</xsl:element>
				<xsl:element name="Cell">
					<xsl:value-of select="StartEnergy"/>
				</xsl:element>
			</xsl:element>
			<xsl:element name="Row">
				<xsl:element name="Cell">
					<xsl:value-of select="EndMass"/>
				</xsl:element>
				<xsl:element name="Cell">
					<xsl:value-of select="EndEnergy"/>
				</xsl:element>
			</xsl:element>
		</xsl:element>
	</xsl:element>
</xsl:template>

<xsl:template name="EmitScanMassRange">
	<xsl:call-template name="Emit-Field-Value-Prompt">
		<xsl:with-param name="InputVar" select="ScanMassRange"/>
		<xsl:with-param name="InputType">String</xsl:with-param>
		<xsl:with-param name="InputPrecision">0</xsl:with-param>
		<xsl:with-param name="InputValue" select="concat(Scan/ScanStartMass,' - ',Scan/ScanEndMass)"/>
		<xsl:with-param name="InputPrompt" select="$TheResources//Type[@name='tMass']/Prompt[@id='ScanMassRange']/@value" />
		<xsl:with-param name="InputUnits" select="$TheResources//Type[@name='tMass']/@units"/>
	</xsl:call-template>
</xsl:template>

<xsl:template name="EmitTargetScanMassRange">
	<xsl:call-template name="Emit-Field-Value-Prompt">
		<xsl:with-param name="InputVar" select="ScanMassRange"/>
		<xsl:with-param name="InputType">String</xsl:with-param>
		<xsl:with-param name="InputPrecision">0</xsl:with-param>
		<xsl:with-param name="InputValue" select="concat(TargetScan/ScanStartMass,' - ',TargetScan/ScanEndMass)"/>
		<xsl:with-param name="InputPrompt" select="$TheResources//Type[@name='tMass']/Prompt[@id='ScanMassRange']/@value" />
		<xsl:with-param name="InputUnits" select="$TheResources//Type[@name='tMass']/@units"/>
	</xsl:call-template>
</xsl:template>

<xsl:template match="TargetScan/TargetMass">

	<xsl:variable name="FuncType">
		<xsl:value-of select="../../FunctionType"/>
	</xsl:variable>
	
	<xsl:call-template name="Emit-Field-Value-Prompt">
		<xsl:with-param name="InputVar" select="name()"/>
		<xsl:with-param name="InputType">Float</xsl:with-param>
		<xsl:with-param name="InputPrecision">2</xsl:with-param>
		<xsl:with-param name="InputValue" select="."/>
		<xsl:with-param name="InputPrompt">
			<xsl:choose>
				<xsl:when test="$FuncType = 'TQFunctionTypeParents_4'">
					<xsl:value-of select="$TheResources//Type[@name='tMass']/Prompt[@id='ParentsOf']/@value"/>
				</xsl:when>
				<xsl:when test="$FuncType = 'TQFunctionTypeDaughters_5'">
					<xsl:value-of select="$TheResources//Type[@name='tMass']/Prompt[@id='DaughtersOf']/@value"/>
				</xsl:when>
				<xsl:when test="$FuncType = 'TQFunctionTypeNeutralLoss_6'">
					<xsl:value-of select="$TheResources//Type[@name='tMass']/Prompt[@id='LossesOf']/@value"/>
				</xsl:when>
				<xsl:when test="$FuncType = 'TQFunctionTypeNeutralGain_7'">
					<xsl:value-of select="$TheResources//Type[@name='tMass']/Prompt[@id='GainsOf']/@value"/>
				</xsl:when>
			</xsl:choose>
		</xsl:with-param>
		<xsl:with-param name="InputUnits">
			<xsl:value-of select="$TheResources//Type[@name='tMass']/@units"/>
		</xsl:with-param>
	</xsl:call-template>

</xsl:template>

<xsl:template match="Smoothing">
	<xsl:apply-templates select="Enable"/>
	<xsl:variable name="SmoothingEnabled">
		<xsl:value-of select="Enable"/>
	</xsl:variable>
	<xsl:if test="$SmoothingEnabled = 'true'">
		<xsl:apply-templates select="Width"/>
		<xsl:apply-templates select="Repeats"/>
	</xsl:if>
</xsl:template>

<xsl:template match="Functions">
	<xsl:if test="count(//Functions/Function) > 0">
		<xsl:for-each select="Function">
			<xsl:element name="FieldList">
				<xsl:element name="Title">
					<xsl:variable name="FunctionTitle" select="$TheResources//Type[@name='tFunction']/@prompt"/>
					<xsl:variable name="TypeID">
						<xsl:value-of select="FunctionType"/>
					</xsl:variable>
					<xsl:variable name="FuncType"  select="$TheResources//Type[@name='tTQFunctionType']/Enum[@id=$TypeID]/@value"/>
					<xsl:element name="Title">
						<xsl:value-of select="SQ:FormatString(string($FunctionTitle),format-number(position(),'#'),string($FuncType))"/>
					</xsl:element>
				</xsl:element>
				
				<xsl:apply-templates select="IonMode"/>
				<xsl:apply-templates select="StartTime"/>
				<xsl:apply-templates select="EndTime"/>
	
				<xsl:choose>

					<xsl:when test="FunctionType = 'TQFunctionTypeSIR_0'">
						<xsl:apply-templates select="SIR/Span"/>
					</xsl:when>

					<xsl:when test="FunctionType = 'TQFunctionTypeMRM_3'">
						<xsl:apply-templates select="MRM/Span"/>
					</xsl:when>

					<xsl:when test="FunctionType = 'TQFunctionTypeMSScan_1' or FunctionType = 'TQFunctionTypeMS2Scan_2'">
						<xsl:apply-templates select="Scan/DataFormat"/>
						<xsl:call-template name="EmitScanMassRange"/>
						<xsl:apply-templates select="Scan/ScanRate"/>
						<xsl:apply-templates select="UseTuneVoltage"/>
						<xsl:if test="UseTuneVoltage = 'false' and Scan/ConeVoltageRamp/Enable = 'false'">
							<xsl:apply-templates select="Scan/ConeVoltage"/>
						</xsl:if>
					</xsl:when>

					<xsl:when test="FunctionType = 'TQFunctionTypeParents_4' or FunctionType = 'TQFunctionTypeDaughters_5' or FunctionType = 'TQFunctionTypeNeutralLoss_6' or FunctionType = 'TQFunctionTypeNeutralGain_7'">
						<xsl:apply-templates select="TargetScan/DataFormat"/>
						<xsl:apply-templates select="TargetScan/TargetMass"/>
						<xsl:call-template name="EmitTargetScanMassRange"/>
						<xsl:apply-templates select="TargetScan/ScanRate"/>
						<xsl:apply-templates select="UseTuneVoltage"/>
						<xsl:if test="UseTuneVoltage = 'false' and TargetScan/ConeVoltageRamp/Enable = 'false'">
							<xsl:apply-templates select="TargetScan/ConeVoltage"/>
						</xsl:if>
						<xsl:apply-templates select="TargetScan/UseTuneEnergy"/>
						<xsl:if test="TargetScan/UseTuneEnergy = 'false' and TargetScan/CollisionEnergyRamp/Enable = 'false'">
							<xsl:apply-templates select="TargetScan/CollisionEnergy"/>
						</xsl:if>
					</xsl:when>

				</xsl:choose>
			</xsl:element>

			<!-- Tabular information must be emitted after completion of field list -->
			<xsl:choose>
				<xsl:when test="FunctionType = 'TQFunctionTypeSIR_0'">
					<xsl:apply-templates select="UseTuneVoltage"/>
					<xsl:apply-templates select="SIR/Channels"/>
				</xsl:when>
				<xsl:when test="FunctionType = 'TQFunctionTypeMRM_3'">
					<xsl:apply-templates select="UseTuneVoltage"/>
					<xsl:apply-templates select="MRM/UseTuneEnergy"/>
					<xsl:apply-templates select="MRM/Channels"/>
				</xsl:when>
				<xsl:when test="FunctionType = 'TQFunctionTypeMSScan_1' or FunctionType = 'TQFunctionTypeMS2Scan_2' ">
					<xsl:apply-templates select="Scan/ConeVoltageRamp/Enable"/>
					<xsl:if test="Scan/ConeVoltageRamp/Enable = 'true'">
						<xsl:apply-templates select="Scan/ConeVoltageRamp"/>
					</xsl:if>
				</xsl:when>
				<xsl:when test="FunctionType = 'TQFunctionTypeParents_4' or FunctionType = 'TQFunctionTypeDaughters_5' or FunctionType = 'TQFunctionTypeNeutralLoss_6' or FunctionType = 'TQFunctionTypeNeutralGain_7'">
					<xsl:apply-templates select="TargetScan/ConeVoltageRamp/Enable"/>
					<xsl:if test="TargetScan/ConeVoltageRamp/Enable = 'true'">
						<xsl:apply-templates select="TargetScan/ConeVoltageRamp"/>
					</xsl:if>
					<xsl:apply-templates select="TargetScan/CollisionEnergyRamp/Enable"/>
					<xsl:if test="TargetScan/CollisionEnergyRamp/Enable = 'true'">
						<xsl:apply-templates select="TargetScan/CollisionEnergyRamp"/>
					</xsl:if>
				</xsl:when>
			</xsl:choose>

		</xsl:for-each>
	</xsl:if>"
</xsl:template>

<xsl:template match="SIR" />

<xsl:template match="Smoothing/Enable">
	<xsl:variable name="FieldName">EnableSmoothing</xsl:variable>
	<xsl:call-template name="Emit-Field-Value-Prompt">
		<xsl:with-param name="InputVar" select="EnableSmoothing"/>
		<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'">
					<xsl:value-of  select="$TheResources//Enum[@id='BooleanEnabled_1D']/@value"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of  select="$TheResources//Enum[@id='BooleanDisabled_0D']/@value"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:with-param>
		<xsl:with-param name="InputPrompt">
			<xsl:value-of  select="$TheResources//Type[@name='tEnableSmoothing']/Prompt[@id='TQSmoothing']/@value"/>
		</xsl:with-param>
		<xsl:with-param name="InputUnits">None</xsl:with-param>
	</xsl:call-template>
</xsl:template>

  <xsl:template match="Operate">
    <xsl:variable name="FieldName">Operate</xsl:variable>
    <xsl:call-template name="Emit-Field-Value-Prompt">
      <xsl:with-param name="InputVar" select="Operate"/>
      <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'">
            <xsl:value-of  select="$TheResources//Enum[@id='BooleanNo_0A']/@value"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of  select="$TheResources//Enum[@id='BooleanYes_1A']/@value"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="InputPrompt">
        <xsl:value-of  select="$TheResources//Type[@name='tOperate']/@prompt"/>
      </xsl:with-param>
      <xsl:with-param name="InputUnits">None</xsl:with-param>
    </xsl:call-template>
  </xsl:template>

  <xsl:template match="APIGas">
    <xsl:variable name="FieldName">APIGas</xsl:variable>
    <xsl:call-template name="Emit-Field-Value-Prompt">
      <xsl:with-param name="InputVar" select="APIGas"/>
      <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'">
            <xsl:value-of  select="$TheResources//Enum[@id='BooleanNo_0A']/@value"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of  select="$TheResources//Enum[@id='BooleanYes_1A']/@value"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="InputPrompt">
        <xsl:value-of  select="$TheResources//Type[@name='tAPIGas']/@prompt"/>
      </xsl:with-param>
      <xsl:with-param name="InputUnits">None</xsl:with-param>
    </xsl:call-template>
  </xsl:template>

  <xsl:template match="CollisionGas">
    <xsl:variable name="FieldName">CollisionGas</xsl:variable>
    <xsl:call-template name="Emit-Field-Value-Prompt">
      <xsl:with-param name="InputVar" select="CollisionGas"/>
      <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'">
            <xsl:value-of  select="$TheResources//Enum[@id='BooleanNo_0A']/@value"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of  select="$TheResources//Enum[@id='BooleanYes_1A']/@value"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="InputPrompt">
        <xsl:value-of  select="$TheResources//Type[@name='tCollisionGas']/@prompt"/>
      </xsl:with-param>
      <xsl:with-param name="InputUnits">None</xsl:with-param>
    </xsl:call-template>
  </xsl:template>

<xsl:template match="Comment|Smoothing/Width|Smoothing/Repeats|Events">
	<xsl:call-template name="Emit"/>
</xsl:template>

<xsl:template match="StopFlow|Switch2|Switch3|Switch4|Reservoir|FlowState|Refill">
	<xsl:call-template name="Emit"/>
</xsl:template>

<xsl:template match="Infusion"  >
  <!-- Don't emit Infusion as an independent element -->    
</xsl:template>
  
<!-- Combine Infusion and FlowRate as a "single" setting -->
<xsl:template match="FlowRate">
<!--
  <xsl:choose>
    <xsl:when test="../Infusion='InfusionNoChange_0'">
      <xsl:call-template name="Emit-Field-Value-Prompt">
        <xsl:with-param name="InputVar" select="Infusion"/>
        <xsl:with-param name="InputType">String</xsl:with-param>
        <xsl:with-param name="InputPrecision">0</xsl:with-param>
        <xsl:with-param name="InputValue">
          <xsl:value-of  select="$TheResources//Type[@name='tInfusion']/Enum[@id='InfusionNoChange_0']/@value"/>
        </xsl:with-param>
        <xsl:with-param name="InputPrompt">
          <xsl:value-of  select="$TheResources//Type[@name='tFlowRate']/@prompt"/>
        </xsl:with-param>
        <xsl:with-param name="InputUnits">None</xsl:with-param>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="Emit"/>
    </xsl:otherwise>
  </xsl:choose>
  -->
  <xsl:call-template name="Emit"/>
</xsl:template>
  
<xsl:template match="ProbeTemp">
  <xsl:choose>
	<xsl:when test="../IonModeType!='IonModeTypeAPI_1' and ../IonModeType!='IonModeTypeDual_4'">
		<!-- Do not emit unless API or Dual API/APPI -->
	</xsl:when>
    <xsl:when test=".='UseTuneProbeTemp_-1'">
      <xsl:call-template name="Emit-Field-Value-Prompt">
        <xsl:with-param name="InputVar" select="Infusion"/>
        <xsl:with-param name="InputType">String</xsl:with-param>
        <xsl:with-param name="InputPrecision">0</xsl:with-param>
        <xsl:with-param name="InputValue">
          <xsl:value-of  select="$TheResources//Type[@name='tUseTuneProbeTemp']/Enum[@id='UseTuneProbeTemp_-1']/@value"/>
        </xsl:with-param>
        <xsl:with-param name="InputPrompt">
          <xsl:value-of  select="$TheResources//Type[@name='tAPIProbeTemp']/@prompt"/>
        </xsl:with-param>
        <xsl:with-param name="InputUnits">None</xsl:with-param>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="Emit"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="AcquityTQMethod">
	<xsl:element name="AcquityTQMethod">
		<xsl:element name="FieldList">
			<xsl:element name="Title"/>
			<xsl:apply-templates select="Comment"/>
			<xsl:apply-templates select="Smoothing"/>
			<xsl:apply-templates select="ProbeTemp"/>
		</xsl:element>
		<xsl:apply-templates select="Functions"/>
		<xsl:element name="FieldList">
			<xsl:element name="Title">
				<xsl:value-of select="$TheResources//Type[@name='tEvents']/@prompt"/>
			</xsl:element>
			<xsl:apply-templates select="StopFlow"/>
			<xsl:apply-templates select="Switch2"/>
			<xsl:apply-templates select="Switch3"/>
			<xsl:apply-templates select="Switch4"/>
			<xsl:apply-templates select="Infusion"/>
			<xsl:apply-templates select="Reservoir"/>
			<xsl:apply-templates select="FlowState"/>
			<xsl:apply-templates select="FlowRate"/>
			<xsl:apply-templates select="Refill"/>
		</xsl:element>
		<xsl:apply-templates select="RunEvents"/>
		<xsl:if test="RunEvents = 'true'">
			<xsl:apply-templates select="EventTable"/>
		</xsl:if>
    <xsl:element name="FieldList">
      <xsl:element name="Title">
        <xsl:value-of select="$TheResources//Type[@name='tShutdown']/@prompt"/>
      </xsl:element>
      <xsl:apply-templates select="Operate"/>
      <xsl:apply-templates select="APIGas"/>
      <xsl:apply-templates select="CollisionGas"/>
    </xsl:element>
	</xsl:element>
</xsl:template>

<msxsl:script language="VBScript" implements-prefix="SQ">

<!-- A C#-like formatter, which replaces {0} with Sub0 and {1} with Sub1 -->
Function FormatString(s,Sub0,Sub1)

	On Error Resume Next
	
	FormatString = s
	index0 = InStr( s,"{0}" )

	If index0 >= 1 Then
	
		FormatString = Mid(s, 1, index0-1)  + Sub0 + Mid( s, index0 + 3)
		index1 = InStr( FormatString, "{1}")
		
		If index1 >= 1 Then
			FormatString = Mid(FormatString, 1, index1-1) + Sub1 + Mid(FormatString, index1+3)
		End If
	
	End If
	
	On Error Goto 0 ' (Re-enable error trapping)
		
End Function

</msxsl:script>

</xsl:stylesheet>

