<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet version="1.0"    
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt">

<!-- (c) 2013, Trimble Navigation Limited. All rights reserved.                                -->
<!-- Permission is hereby granted to use, copy, modify, or distribute this style sheet for any -->
<!-- purpose and without fee, provided that the above copyright notice appears in all copies   -->
<!-- and that both the copyright notice and the limited warranty and restricted rights notice  -->
<!-- below appear in all supporting documentation.                                             -->

<!-- TRIMBLE NAVIGATION LIMITED PROVIDES THIS STYLE SHEET "AS IS" AND WITH ALL FAULTS.         -->
<!-- TRIMBLE NAVIGATION LIMITED SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY -->
<!-- OR FITNESS FOR A PARTICULAR USE. TRIMBLE NAVIGATION LIMITED DOES NOT WARRANT THAT THE     -->
<!-- OPERATION OF THIS STYLE SHEET WILL BE UNINTERRUPTED OR ERROR FREE.                        -->

<xsl:output method="html" omit-xml-declaration="no" encoding="utf-8"/>

<!-- Set the numeric display details i.e. decimal point, thousands separator etc -->
<xsl:variable name="DecPt" select="string('.')"/>    <!-- Change as appropriate for US/European -->
<xsl:variable name="GroupSep" select="string(',')"/> <!-- Change as appropriate for US/European -->
<!-- Also change decimal-separator & grouping-separator in decimal-format below 
     as appropriate for US/European output -->
<xsl:decimal-format name="Standard" 
                    decimal-separator="."
                    grouping-separator=","
                    infinity="Infinity"
                    minus-sign="-"
                    NaN="?"
                    percent="%"
                    per-mille="&#2030;"
                    zero-digit="0" 
                    digit="#" 
                    pattern-separator=";" />

<xsl:variable name="DecPl0" select="string('#0')"/>
<xsl:variable name="DecPl1" select="string(concat('#0', $DecPt, '0'))"/>
<xsl:variable name="DecPl2" select="string(concat('#0', $DecPt, '00'))"/>
<xsl:variable name="DecPl3" select="string(concat('#0', $DecPt, '000'))"/>
<xsl:variable name="DecPl4" select="string(concat('#0', $DecPt, '0000'))"/>
<xsl:variable name="DecPl5" select="string(concat('#0', $DecPt, '00000'))"/>
<xsl:variable name="DecPl6" select="string(concat('#0', $DecPt, '000000'))"/>
<xsl:variable name="DecPl8" select="string(concat('#0', $DecPt, '00000000'))"/>

<xsl:variable name="fileExt" select="'doc'"/>

<xsl:variable name="useChainageTerminology">false</xsl:variable>
<xsl:variable name="useRailTerminology">false</xsl:variable>

<!-- Define keys to speed up record searchs -->
<xsl:key name="tgtID-search" match="/JOBFile/FieldBook/TargetRecord" use="@ID"/>
<xsl:key name="antID-search" match="/JOBFile/FieldBook/AntennaRecord" use="@ID"/>
<xsl:key name="travID-search" match="/JOBFile/FieldBook/TraverseDefinitionRecord" use="@ID"/>
<xsl:key name="refID-search" match="/JOBFile/FieldBook/ReferenceRecord" use="@ID"/>
<xsl:key name="equipID-search" match="/JOBFile/FieldBook/GPSEquipmentRecord" use="@ID"/>

<!-- User variable definitions - Appropriate fields are displayed on the       -->
<!-- Survey Controller screen to allow the user to enter specific values       -->
<!-- which can then be used within the style sheet definition to control the   -->
<!-- output data.                                                              -->
<!--                                                                           -->
<!-- All user variables must be identified by a variable element definition    -->
<!-- named starting with 'userField' (case sensitive) followed by one or more  -->
<!-- characters uniquely identifying the user variable definition.             -->
<!--                                                                           -->
<!-- The text within the 'select' field for the user variable description      -->
<!-- references the actual user variable and uses the '|' character to         -->
<!-- separate the definition details into separate fields as follows:          -->
<!-- For all user variables the first field must be the name of the user       -->
<!-- variable itself (this is case sensitive) and the second field is the      -->
<!-- prompt that will appear on the Survey Controller screen.                  -->
<!-- The third field defines the variable type - there are four possible       -->
<!-- variable types: Double, Integer, String and StringMenu.  These variable   -->
<!-- type references are not case sensitive.                                   -->
<!-- The fields that follow the variable type change according to the type of  -->
<!-- variable as follow:                                                       -->
<!-- Double and Integer: Fourth field = optional minimum value                 -->
<!--                     Fifth field = optional maximum value                  -->
<!--   These minimum and maximum values are used by the Survey Controller for  -->
<!--   entry validation.                                                       -->
<!-- String: No further fields are needed or used.                             -->
<!-- StringMenu: Fourth field = number of menu items                           -->
<!--             Remaining fields are the actual menu items - the number of    -->
<!--             items provided must equal the specified number of menu items. -->
<!--                                                                           -->
<!-- The style sheet must also define the variable itself, named according to  -->
<!-- the definition.  The value within the 'select' field will be displayed in -->
<!-- the Survey Controller as the default value for the item.                  -->

<!-- Need to use the select attribute for userField definitions and also include the -->
<!-- contents in single quotes so that the user information can be picked up by the  -->
<!-- Survey Controller and ASCII File Generator.  This means it is not possible to   -->
<!-- have text that includes any apostrophes (single quotes) in it.                  -->
<xsl:variable name="userField1" select="'DetailedRpt|Detaylı rapor çıktısı|stringMenu|2|Evet|Hayır'"/>
<xsl:variable name="DetailedRpt" select="'Evet'"/>

<xsl:variable name="userField2" select="'RptContents|İçerik raporu|stringMenu|3|Sadece arazi verisi|Sadece düzeltilmiş koordinatlar|Tüm'"/>
<xsl:variable name="RptContents" select="'Tüm'"/>

<xsl:variable name="userField3" select="'vectorDeltasType|GNSS farklarının raporlanacağı|stringMenu|2|İşaretten işarete|APC - APC'"/>
<xsl:variable name="vectorDeltasType" select="'APC - APC'"/>

<xsl:variable name="IncludeBorders" select="'Evet'"/>

<!-- Save the possible selected values in variables for comparison purposes -->
<!-- so that there is no need to include the translated strings in quotes.  -->
<xsl:variable name="YesStr">Evet</xsl:variable>
<xsl:variable name="NoStr">Hayır</xsl:variable>
<xsl:variable name="FieldBookDataOnlyStr">Sadece arazi verisi</xsl:variable>
<xsl:variable name="ReducedCoordinatesOnlyStr">Sadece düzeltilmiş koordinatlar</xsl:variable>
<xsl:variable name="AllStr">Tüm</xsl:variable>

<!-- **************************************************************** -->
<!-- Set global variables from the Environment section of JobXML file -->
<!-- **************************************************************** -->
<xsl:variable name="DistUnit"   select="/JOBFile/Environment/DisplaySettings/DistanceUnits" />
<xsl:variable name="ElevUnit"   select="/JOBFile/Environment/DisplaySettings/HeightUnits" />
<xsl:variable name="AngleUnit"  select="/JOBFile/Environment/DisplaySettings/AngleUnits" />
<xsl:variable name="CoordOrder" select="/JOBFile/Environment/DisplaySettings/CoordinateOrder" />
<xsl:variable name="TempUnit"   select="/JOBFile/Environment/DisplaySettings/TemperatureUnits" />
<xsl:variable name="PressUnit"  select="/JOBFile/Environment/DisplaySettings/PressureUnits" />
<xsl:variable name="AreaUnit"   select="/JOBFile/Environment/DisplaySettings/AreaUnits" />
<xsl:variable name="VolumeUnit" select="/JOBFile/Environment/DisplaySettings/VolumeUnits" />

<!-- Setup conversion factor for coordinate and distance values -->
<xsl:variable name="DistConvFactor">
  <xsl:choose>
    <xsl:when test="$DistUnit='Metres'">1.0</xsl:when>
    <xsl:when test="$DistUnit='InternationalFeet'">3.280839895</xsl:when>
    <xsl:when test="$DistUnit='USSurveyFeet'">3.2808333333357</xsl:when>
    <xsl:otherwise>1.0</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<!-- Setup conversion factor for coordinate and distance values -->
<xsl:variable name="ElevConvFactor">
  <xsl:choose>
    <xsl:when test="$ElevUnit='Metres'">1.0</xsl:when>
    <xsl:when test="$ElevUnit='InternationalFeet'">3.280839895</xsl:when>
    <xsl:when test="$ElevUnit='USSurveyFeet'">3.2808333333357</xsl:when>
    <xsl:otherwise>1.0</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<!-- Setup conversion factor for angular values -->
<xsl:variable name="AngleConvFactor">
  <xsl:choose>
    <xsl:when test="$AngleUnit='DMSDegrees'">1.0</xsl:when>
    <xsl:when test="$AngleUnit='Gons'">1.111111111111</xsl:when>
    <xsl:when test="$AngleUnit='Mils'">17.77777777777</xsl:when>
    <xsl:otherwise>1.0</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<!-- Setup conversion factor for area values -->
<xsl:variable name="AreaConvFactor">
  <xsl:choose>
    <xsl:when test="$AreaUnit = 'SquareMetres'">1.0</xsl:when>
    <xsl:when test="$AreaUnit = 'SquareMiles'">
      <xsl:value-of select="1.0 div 2589988.110336"/>
    </xsl:when>
    <xsl:when test="$AreaUnit = 'SquareFeet'">
      <xsl:value-of select="3.280839895 * 3.280839895"/>
    </xsl:when>
    <xsl:when test="$AreaUnit = 'SquareUSSurveyFeet'">
      <xsl:value-of select="3.2808333333357 * 3.2808333333357"/>
    </xsl:when>
    <xsl:when test="$AreaUnit = 'Acres'">
      <xsl:value-of select="1.0 div 4046.8564224"/>
    </xsl:when>
    <xsl:when test="$AreaUnit = 'Hectares'">0.0001</xsl:when>
    <xsl:otherwise>1.0</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<!-- Setup conversion factor for volume values -->
<xsl:variable name="VolConvFactor">
  <xsl:choose>
    <xsl:when test="$VolumeUnit = 'CubicMetres'">1.0</xsl:when>
    <xsl:when test="$VolumeUnit = 'CubicFeet'">
      <xsl:value-of select="3.280839895 * 3.280839895 * 3.280839895"/>
    </xsl:when>
    <xsl:when test="$VolumeUnit = 'CubicUSSurveyFeet'">
      <xsl:value-of select="3.2808333333357 * 3.2808333333357 * 3.2808333333357"/>
    </xsl:when>
    <xsl:when test="$VolumeUnit = 'CubicYards'">
      <xsl:value-of select="3.280839895 * 3.280839895 * 3.280839895 div 27.0"/>
    </xsl:when>
    <xsl:when test="$VolumeUnit = 'CubicUSSurveyYards'">
      <xsl:value-of select="3.2808333333357 * 3.2808333333357 * 3.2808333333357 div 27.0"/>
    </xsl:when>
    <xsl:when test="$VolumeUnit = 'AcreFeet'">
      <xsl:value-of select="1.0 div 1233.48183754752"/>
    </xsl:when>
    <xsl:when test="$VolumeUnit = 'USAcreFeet'">
      <xsl:value-of select="1.0 div 1233.4892384681"/>
    </xsl:when>
    <xsl:otherwise>1.0</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<!-- Setup boolean variable for coordinate order -->
<xsl:variable name="NECoords">
  <xsl:choose>
    <xsl:when test="$CoordOrder='North-East-Elevation'">true</xsl:when>
    <xsl:when test="$CoordOrder='X-Y-Z'">true</xsl:when>
    <xsl:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<!-- Set up global variables for the north, east, elevation, delta north, delta east and -->
<!-- delta elevation prompts according to the type of coordinate labeling.               -->
<xsl:variable name="northPrompt">
  <xsl:choose>
    <xsl:when test="($CoordOrder='North-East-Elevation') or ($CoordOrder='East-North-Elevation')">Yukarı</xsl:when>
    <xsl:otherwise>X</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<xsl:variable name="eastPrompt">
  <xsl:choose>
    <xsl:when test="($CoordOrder='North-East-Elevation') or ($CoordOrder='East-North-Elevation')">Sağa</xsl:when>
    <xsl:otherwise>Y</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<xsl:variable name="elevPrompt">
  <xsl:choose>
    <xsl:when test="($CoordOrder='North-East-Elevation') or ($CoordOrder='East-North-Elevation')">Kot</xsl:when>
    <xsl:otherwise>Z</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<xsl:variable name="dNorthPrompt">
  <xsl:choose>
    <xsl:when test="($CoordOrder='North-East-Elevation') or ($CoordOrder='East-North-Elevation')">Δ Yukarı</xsl:when>
    <xsl:otherwise>ΔX</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<xsl:variable name="dEastPrompt">
  <xsl:choose>
    <xsl:when test="($CoordOrder='North-East-Elevation') or ($CoordOrder='East-North-Elevation')">Δ Sağa</xsl:when>
    <xsl:otherwise>ΔY</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<xsl:variable name="dElevPrompt">
  <xsl:choose>
    <xsl:when test="($CoordOrder='North-East-Elevation') or ($CoordOrder='East-North-Elevation')">ΔKot</xsl:when>
    <xsl:otherwise>ΔZ</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<!-- Setup conversion factor for pressure values -->
<!-- Pressure values in JobXML file are always in millibars (hPa) -->
<xsl:variable name="PressConvFactor">
  <xsl:choose>
    <xsl:when test="$PressUnit='MilliBar'">1.0</xsl:when>
    <xsl:when test="$PressUnit='InchHg'">0.029529921</xsl:when>
    <xsl:when test="$PressUnit='mmHg'">0.75006</xsl:when>
    <xsl:otherwise>1.0</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<xsl:variable name="prodVersion">
  <xsl:choose>
    <xsl:when test="/JOBFile/@productVersion">
      <xsl:value-of select="/JOBFile/@product"/>
      <xsl:value-of select="' '"/>
      <xsl:value-of select="/JOBFile/@productVersion"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>Trimble Survey Controller </xsl:text>
      <xsl:value-of select="format-number(/JOBFile/@version div 100, $DecPl2, 'Standard')"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<xsl:variable name="schemaVersion" select="JOBFile/@version"/>

<xsl:variable name="WGS84SemiMajorAxis" select="6378137.000"/>
<xsl:variable name="WGS84Flattening" select="298.257222101"/>
<xsl:variable name="WGS84EccentricitySquared" select="0.00669438002290"/>
<xsl:variable name="Pi" select="3.14159265358979323846264"/>
<xsl:variable name="halfPi" select="$Pi div 2.0"/>

<!-- **************************************************************** -->
<!-- ************************** Main Loop *************************** -->
<!-- **************************************************************** -->
<xsl:template match="/" >
  <html>

  <title>Ölçü Raporu</title>
  <h1>Ölçü Raporu</h1>

  <!-- Set the font size for use in tables -->
  <style type="text/css">
    html { font-family: Arial }
    body, table, td, th
    {
      font-size:12px;
    }
  </style>

  <head>
  </head>

  <body>
    <xsl:call-template name="StartTable"/>
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">İş adı</xsl:with-param>
        <xsl:with-param name="Val" select="JOBFile/@jobName"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Oluşturma tarihi</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormattedDateString">
            <xsl:with-param name="date" select="substring-before(JOBFile/@TimeStamp, 'T')"/>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Sürüm</xsl:with-param>
        <xsl:with-param name="Val" select="$prodVersion"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Mesafe Birimi</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:choose>
            <xsl:when test="$DistUnit = 'InternationalFeet'">Uluslararasi feet</xsl:when>
            <xsl:when test="$DistUnit = 'USSurveyFeet'">US harita feet</xsl:when>
            <xsl:otherwise>Metre</xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Açı birimleri</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:choose>
            <xsl:when test="$AngleUnit = 'Gons'">Grad</xsl:when>
            <xsl:when test="$AngleUnit = 'Mils'">Mil</xsl:when>
            <xsl:otherwise>Derece</xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Basınç birimi</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:choose>
            <xsl:when test="$PressUnit = 'InchHg'">inHg</xsl:when>
            <xsl:when test="$PressUnit = 'mmHg'">mmHg</xsl:when>
            <xsl:otherwise>mbar</xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Sıcaklık Birimi</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:choose>
            <xsl:when test="$TempUnit = 'Fahrenheit'">Fahrenhayt</xsl:when>
            <xsl:otherwise>Santigrat</xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
      </xsl:call-template>
    <xsl:call-template name="EndTable"/>
    <xsl:call-template name="SeparatingLine"/>

    <!-- Output the Coordinate System details applying at time of export.                  -->
    <!-- This is also the coordinate system in terms of which all coordinates are computed -->
    <xsl:apply-templates select="JOBFile/Environment/CoordinateSystem"/>
    
    <xsl:if test="($RptContents = $AllStr) or ($RptContents = $FieldBookDataOnlyStr)">
      <xsl:call-template name="SeparatingLine"/>
      <xsl:call-template name="StartTable"/>
        <caption align="top"><p align="left"><b>
          <xsl:text>Toplanan Arazi Verisi</xsl:text>
          <xsl:if test="count(/JOBFile/FieldBook/PointRecord[ECEFDeltas and (Deleted = 'false')]) != 0">
            <xsl:text> (Delta ECEF: </xsl:text>
            <xsl:value-of select="$vectorDeltasType"/>
            <xsl:text>)</xsl:text>
          </xsl:if>
        </b></p></caption>
      <xsl:call-template name="EndTable"/>
      <xsl:call-template name="BlankLine"/>
      <!-- Select the FieldBook node to process -->
      <xsl:apply-templates select="JOBFile/FieldBook" />
    </xsl:if>
    
    <xsl:if test="($RptContents = $AllStr) or ($RptContents = $ReducedCoordinatesOnlyStr)">
      <!-- Select Reductions node to process -->
      <xsl:apply-templates select="JOBFile/Reductions" />
    </xsl:if>

  </body>
  </html>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** FieldBook Node Processing ******************** -->
<!-- **************************************************************** -->
<xsl:template match="FieldBook">
<!-- Process the records under the FieldBook node in the order encountered -->
  <xsl:for-each select="*">
    <xsl:choose>
      <!-- Handle Corrections record -->
      <xsl:when test="name(current()) = 'CorrectionsRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Job Properties record -->
      <xsl:when test="name(current()) = 'JobPropertiesRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Point record -->
      <xsl:when test="name(current()) = 'PointRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Station record -->
      <xsl:when test="name(current()) = 'StationRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle BackBearing record -->
      <xsl:when test="name(current()) = 'BackBearingRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Atmosphere record -->
      <xsl:when test="name(current()) = 'AtmosphereRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle StationResiduals record -->
      <xsl:when test="name(current()) = 'StationResiduals'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle BaseSurveyOptions record -->
      <xsl:when test="name(current()) = 'BaseSurveyOptionsRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle RoverSurveyOptions record -->
      <xsl:when test="name(current()) = 'RoverSurveyOptionsRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle SurveyEvent record -->
      <xsl:when test="name(current()) = 'SurveyEventRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Reference record (GPS base point) -->
      <xsl:when test="name(current()) = 'ReferenceRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Initialisation record -->
      <xsl:when test="name(current()) = 'InitialisationRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Feature Coding record -->
      <xsl:when test="name(current()) = 'FeatureCodingRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Instrument record -->
      <xsl:when test="name(current()) = 'InstrumentRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Instrument Details record -->
      <xsl:when test="name(current()) = 'InstrumentDetailsRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Rounds mean turned angles residuals record -->
      <xsl:when test="name(current()) = 'RoundsMeanTurnedAngleResiduals'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Road definition record -->
      <xsl:when test="name(current()) = 'RoadRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Note record -->
      <xsl:when test="name(current()) = 'NoteRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Line record -->
      <xsl:when test="name(current()) = 'LineRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Arc record -->
      <xsl:when test="name(current()) = 'ArcRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Inverse record -->
      <xsl:when test="name(current()) = 'InverseRecord'">
        <xsl:apply-templates select="current()"/>
      </xsl:when>

      <!-- Handle Calibration Point record -->
      <xsl:when test="name(current()) = 'CalibrationPointRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle GPS Equipment record -->
      <xsl:when test="name(current()) = 'GPSEquipmentRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Post Process record -->
      <xsl:when test="name(current()) = 'PostProcessRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Coordinate System record -->
      <xsl:when test="name(current()) = 'CoordinateSystemRecord'">
        <xsl:if test="$DetailedRpt = $YesStr">
          <xsl:apply-templates select="current()"/> 
        </xsl:if>
      </xsl:when>

      <!-- Handle Projection record -->
      <xsl:when test="name(current()) = 'ProjectionRecord'">
        <xsl:if test="$DetailedRpt = $YesStr">
          <xsl:apply-templates select="current()"/> 
        </xsl:if>
      </xsl:when>
      
      <!-- Handle Datum record -->
      <xsl:when test="name(current()) = 'DatumRecord'">
        <xsl:if test="$DetailedRpt = $YesStr">
          <xsl:apply-templates select="current()"/> 
        </xsl:if>
      </xsl:when>

      <!-- Handle Horizontal Adjustment record -->
      <xsl:when test="name(current()) = 'HorizontalAdjustmentRecord'">
        <xsl:if test="$DetailedRpt = $YesStr">
          <xsl:apply-templates select="current()"/> 
        </xsl:if>
      </xsl:when>

      <!-- Handle Vertical Adjustment record -->
      <xsl:when test="name(current()) = 'VerticalAdjustmentRecord'">
        <xsl:if test="$DetailedRpt = $YesStr">
          <xsl:apply-templates select="current()"/> 
        </xsl:if>
      </xsl:when>

      <!-- Handle Traverse Definition record -->
      <xsl:when test="name(current()) = 'TraverseDefinitionRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle Traverse Adjustment record -->
      <xsl:when test="name(current()) = 'TraverseAdjustmentRecord'">
      <!-- TraverseAdjustmentRecords can be written out a number of -->
      <!-- times within a file but we are only really interested in -->
      <!-- the one preceding a TraverseClosureRecord -->
      <xsl:if test="name(following-sibling::*[1]) = 'TraverseClosureRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:if>

      </xsl:when>

      <!-- Handle Traverse Closure record -->
     <xsl:when test="name(current()) = 'TraverseClosureRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle COGO Transformation record -->
     <xsl:when test="name(current()) = 'CogoTransformationRecord'">
        <xsl:apply-templates select="current()"/> 
      </xsl:when>

      <!-- Handle area computation record -->
     <xsl:when test="name(current()) = 'ComputeAreaRecord'">
        <xsl:apply-templates select="current()"/>
      </xsl:when>

      <!-- Handle subdivide area computation record -->
     <xsl:when test="name(current()) = 'SubdivideAreaRecord'">
        <xsl:apply-templates select="current()"/>
      </xsl:when>

      <!-- Handle volume computation record -->
     <xsl:when test="name(current()) = 'VolumeRecord'">
        <xsl:apply-templates select="current()"/>
      </xsl:when>

      <!-- Handle tilt sensor calibration record -->
     <xsl:when test="name(current()) = 'TiltSensorCalibrationRecord'">
        <xsl:apply-templates select="current()"/>
      </xsl:when>

      <!-- Handle SBAS offset record -->
     <xsl:when test="name(current()) = 'SBASOffsetRecord'">
        <xsl:apply-templates select="current()"/>
      </xsl:when>

    </xsl:choose>
  </xsl:for-each>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** Reductions Node Processing ******************* -->
<!-- **************************************************************** -->
<xsl:template match="Reductions">
  <xsl:call-template name="BlankLine"/>
  <xsl:call-template name="SeparatingLine"/>
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left"><b>Survey Controller Düzeltilmiş Noktalar</b></p></caption>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="BlankLine"/>
  <xsl:choose>
    <xsl:when test="@error">  <!-- There is an error attribute so the reduced coords have not been computed -->
      <xsl:value-of select="@error"/>  <!-- Display the error message -->
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates select="Point"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** CorrectionsRecord Output ********************* -->
<!-- **************************************************************** -->
<xsl:template match="CorrectionsRecord">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Düzeltmeler</p></caption>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Güney semt (grid)</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:if test="SouthAzimuth[.='true']">Evet</xsl:if>
        <xsl:if test="SouthAzimuth[.='false']">Hayır</xsl:if>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Grid koord.</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:if test="GridOrientation[.='IncreasingNorthEast']">Kuzey-Doğu artım</xsl:if>
        <xsl:if test="GridOrientation[.='IncreasingSouthWest']">Güney-Batı artım</xsl:if>
        <xsl:if test="GridOrientation[.='IncreasingNorthWest']">Kuzey-Batı artım</xsl:if>
        <xsl:if test="GridOrientation[.='IncreasingSouthEast']">Güney-Doğu artım</xsl:if>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Manyetik sapma</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="MagneticDeclination"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Kenarlar</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:if test="Distances[.='GroundDistance']">Yersel</xsl:if>
        <xsl:if test="Distances[.='GridDistance']">Grid</xsl:if>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Komşu dengelemesi</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:if test="NeighbourhoodAdjustment/Applied[.='true']">Açık</xsl:if>
        <xsl:if test="NeighbourhoodAdjustment/Applied[.='false']">Kapalı</xsl:if>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:if test="NeighbourhoodAdjustment/Applied[.='true']">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Ağırlık katsayısı</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:variable name="WeightExp" select="NeighbourhoodAdjustment/WeightExponent" />
          <xsl:value-of select="format-number($WeightExp, $DecPl1, 'Standard')" />    
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** JobPropertiesRecord Output ******************* -->
<!-- **************************************************************** -->
<xsl:template match="JobPropertiesRecord">
  <xsl:if test="Reference != '' or Description != '' or Operator != '' or JobNote != ''">
    <xsl:call-template name="StartTable"/>
      <caption align="top"><p align="left">İş'in özellikleri</p></caption>
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Referans</xsl:with-param>
        <xsl:with-param name="Val" select="Reference"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Açıklama</xsl:with-param>
        <xsl:with-param name="Val" select="Description"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Operatör</xsl:with-param>
        <xsl:with-param name="Val" select="Operator"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Notlar</xsl:with-param>
        <xsl:with-param name="Val" select="JobNote"/>
      </xsl:call-template>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
  </xsl:if>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** FeatureCodingRecord Output ******************* -->
<!-- **************************************************************** -->
<xsl:template match="FeatureCodingRecord">
  <xsl:if test="LibraryName != ''">
    <xsl:call-template name="StartTable"/>
      <caption align="top"><p align="left">Öznitelik kütüphanesi</p></caption>
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Kütüphane adı</xsl:with-param>
        <xsl:with-param name="Val" select="LibraryName"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Kütüp.dosya ismi</xsl:with-param>
        <xsl:with-param name="Val" select="SourceFilename"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Öznitelik Desteği</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:if test="AttributesStored[.='true']">Evet</xsl:if>
          <xsl:if test="AttributesStored[.='false']">Hayır</xsl:if>
        </xsl:with-param>
      </xsl:call-template>

  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
  </xsl:if>
</xsl:template>


<!-- **************************************************************** -->
<!-- **************** CoordinateSystemRecord Output ***************** -->
<!-- **************************************************************** -->
<xsl:template match="CoordinateSystemRecord">
  <xsl:if test="SystemName != '' or ZoneName != '' or DatumName != ''">
    <xsl:call-template name="StartTable"/>
      <caption align="top"><p align="left">Koordinat sistemi</p></caption>
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Sistem</xsl:with-param>
        <xsl:with-param name="Val" select="SystemName"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Zone</xsl:with-param>
        <xsl:with-param name="Val" select="ZoneName"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Datum</xsl:with-param>
        <xsl:with-param name="Val" select="DatumName"/>
      </xsl:call-template>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
  </xsl:if>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** InstrumentRecord Output ********************* -->
<!-- **************************************************************** -->
<xsl:template match="InstrumentRecord">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Cihaz</p></caption>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Cihaz tipi</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="InstrumentTypeText">
          <xsl:with-param name="Type" select="Type"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">EDM Refrak. Katsayısı</xsl:with-param>
      <xsl:with-param name="Val" select="format-number(RefractiveIndex, $DecPl1, 'Standard')"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">EDM Taşıyıcı Dalgaboyu</xsl:with-param>
      <xsl:with-param name="Val" select="format-number(CarrierWavelength, $DecPl1, 'Standard')"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Yatay Daire Modu</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:if test="SetHorizontalCircleMode[.='DoNothing']">Yok</xsl:if>
        <xsl:if test="SetHorizontalCircleMode[.='Zero']">Sıfıra bağla</xsl:if>
        <xsl:if test="SetHorizontalCircleMode[.='SetToAzimuth']">Semte bağla</xsl:if>
        <xsl:if test="SetHorizontalCircleMode[.='SetHorizontalNull']">Yok</xsl:if>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Yatay Açı Presizyonu</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="HorizontalAnglePrecision"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Düşey Açı Presizyonu</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="VerticalAnglePrecision"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">EDM presizyonu</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:value-of select="format-number(EDMPrecision * 1000, $DecPl0, 'Standard')"/><xsl:text>mm +</xsl:text>
        <xsl:value-of select="EDMppm"/><xsl:text>ppm</xsl:text>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:if test="CenteringError != 0">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Cihaz ortalama hatası</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(CenteringError * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="BacksightCenteringError != 0">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Geri bakış merkezleme hatası</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(BacksightCenteringError * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** Instrument Type Text Output ****************** -->
<!-- **************************************************************** -->
<xsl:template name="InstrumentTypeText">
  <xsl:param name="Type"/>

  <xsl:choose>
    <xsl:when test="$Type = 'TrimbleTTS'">Trimble TTS</xsl:when>
    <xsl:when test="$Type = 'Trimble3300'">Trimble 3300</xsl:when>
    <xsl:when test="$Type = 'Trimble3600Elta'">Trimble 3600 Elta</xsl:when>
    <xsl:when test="$Type = 'Trimble3600GDM'">Trimble 3600 GDM</xsl:when>
    <xsl:when test="$Type = 'Trimble600M'">Trimble 600M</xsl:when>
    <xsl:when test="$Type = 'Trimble5600'">Trimble 5600</xsl:when>
    <xsl:when test="$Type = 'TrimbleSSeries'">Trimble S Series</xsl:when>
    <xsl:when test="$Type = 'TrimbleVXandSSeries'">Trimble VX/S Series</xsl:when>
    <xsl:when test="($Type = 'SETBasic') or ($Type = 'SETEnhanced')">Sokkia SET</xsl:when>
    <xsl:when test="$Type = 'Geodimeter400'">Geodimeter 400</xsl:when>
    <xsl:when test="$Type = 'Geodimeter500Servo'">Geodimeter 500 Servo</xsl:when>
    <xsl:when test="$Type = 'Geodimeter600'">Geodimeter 600</xsl:when>
    <xsl:when test="$Type = 'Geodimeter600Servo'">Geodimeter 600 Servo</xsl:when>
    <xsl:when test="$Type = 'Geodimeter600Robotic'">Geodimeter 600 Robotic</xsl:when>
    <xsl:when test="$Type = 'Geodimeter4000'">Geodimeter 4000</xsl:when>
    <xsl:when test="$Type = 'LeicaTC300'">Leica TC300</xsl:when>
    <xsl:when test="$Type = 'LeicaTC500'">Leica TC500</xsl:when>
    <xsl:when test="$Type = 'LeicaTC800'">Leica TC800</xsl:when>
    <xsl:when test="($Type = 'LeicaT1000_6') or ($Type = 'LeicaT1000_14')">Leica T1000</xsl:when>
    <xsl:when test="$Type = 'LeicaTC1100'">Leica TC1100</xsl:when>
    <xsl:when test="$Type = 'LeicaTC1100ServoGeoCom'">Leica TC1100 Servo</xsl:when>
    <xsl:when test="$Type = 'LeicaTC1100RoboticGeoCom'">Leica TC1100 Robotic</xsl:when>
    <xsl:when test="$Type = 'LeicaTC1600'">Leica TC1600</xsl:when>
    <xsl:when test="$Type = 'LeicaTC2000'">Leica TC2000</xsl:when>
    <xsl:when test="$Type = 'Nikon'">Nikon</xsl:when>
    <xsl:when test="$Type = 'Pentax'">Pentax</xsl:when>
    <xsl:when test="$Type = 'TopconGeneric'">Topcon</xsl:when>
    <xsl:when test="$Type = 'Topcon500'">Topcon 500</xsl:when>
    <xsl:when test="$Type = 'ZeissElta2'">Zeiss Elta2</xsl:when>
    <xsl:when test="$Type = 'ZeissElta3'">Zeiss Elta3</xsl:when>
    <xsl:when test="$Type = 'ZeissElta4'">Zeiss Elta4</xsl:when>
    <xsl:when test="$Type = 'ZeissEltaC'">Zeiss EltaC</xsl:when>
    <xsl:when test="$Type = 'ZeissRecEltaE'">Zeiss RecEltaE</xsl:when>
    <xsl:when test="$Type = 'ZeissRSeries'">Zeiss R Series</xsl:when>
    <xsl:when test="$Type = 'Manual'">Elle</xsl:when>
    <xsl:otherwise>Bilinmeyen</xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- *************** InstrumentDetailsRecord Output ***************** -->
<!-- **************************************************************** -->
<xsl:template match="InstrumentDetailsRecord">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Cihaz detayları</p></caption>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Model</xsl:with-param>
      <xsl:with-param name="Val" select="Model"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Seri No</xsl:with-param>
      <xsl:with-param name="Val" select="Serial"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Firmware sürümü</xsl:with-param>
      <xsl:with-param name="Val" select="FirmwareVersion"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Yatay kolimasyon</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="InstrumentAppliedHorizontalCollimation"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Düşey kolimasyon</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="InstrumentAppliedVerticalCollimation"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Muylu eksen düzeltmesi</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="TrunionAxisTiltCorrection"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************** PointRecord Output ************************ -->
<!-- **************************************************************** -->
<xsl:template match="PointRecord">
  <xsl:if test="Deleted = 'false'">  <!-- only output if not deleted -->
    <xsl:if test="Grid">
      <xsl:call-template name="GridPoint"/> 
    </xsl:if>

    <xsl:if test="Circle">
      <xsl:call-template name="Observation"/> 
    </xsl:if>

    <xsl:if test="MTA">
      <xsl:call-template name="MeanTurnedAngle"/> 
    </xsl:if>

    <xsl:if test="ECEF or ECEFDeltas">
      <xsl:call-template name="GPSPosOrDeltas"/>
      <xsl:if test="($DetailedRpt = $YesStr) and QualityControl1/Warnings">
        <xsl:call-template name="OutputGNSSWarningsTable"/>
      </xsl:if>
    </xsl:if>

    <xsl:if test="WGS84">
      <xsl:call-template name="WGS84Pos"/> 
    </xsl:if>

    <xsl:if test="Polar">
      <xsl:call-template name="Polar"/> 
    </xsl:if>

    <xsl:if test="Features">  <!-- Point has feature and attribute details - write them out -->
      <xsl:call-template name="FeatureAndAttributes"/> 
    </xsl:if>

    <xsl:if test="Stakeout">  <!-- Point has stakeout data - write it out -->
      <xsl:call-template name="Stakeout"/> 
    </xsl:if>

    <xsl:if test="LaserOffset">
      <xsl:call-template name="LaserOffset"/> 
    </xsl:if>

    <xsl:if test="ResectionStandardErrors">
      <xsl:call-template name="ResectionStandardErrors"/> 
    </xsl:if>

    <xsl:if test="EnteredData">
      <xsl:call-template name="EnteredData"/> 
    </xsl:if>

    <xsl:if test="Measure3DAxes">
      <xsl:call-template name="Measure3DAxes"/>
    </xsl:if>
  </xsl:if>
</xsl:template>


<!-- **************************************************************** -->
<!-- **************** Grid Point Details Output ********************* -->
<!-- **************************************************************** -->
<xsl:template name="GridPoint">
  <xsl:param name="reductionsPoint" select="'false'"/>
  
  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1"><xsl:text>Nokta</xsl:text>
        <xsl:if test="Method = 'TraverseAdjusted'"><xsl:text> (Dengelenmiş)</xsl:text></xsl:if>
      </xsl:with-param>
      <xsl:with-param name="Val1" select="Name"/>

      <xsl:with-param name="Hdr2">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'"><xsl:value-of select="$northPrompt"/></xsl:when>
          <xsl:otherwise><xsl:value-of select="$eastPrompt"/></xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">
            <xsl:value-of select="format-number(Grid/North * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="format-number(Grid/East * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'"><xsl:value-of select="$eastPrompt"/></xsl:when>
          <xsl:otherwise><xsl:value-of select="$northPrompt"/></xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">
            <xsl:value-of select="format-number(Grid/East * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="format-number(Grid/North * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr4" select="$elevPrompt"/>
      <xsl:with-param name="Val4">
        <xsl:choose>
          <xsl:when test="$reductionsPoint != 'false'">
            <!-- Check to see if the referenced PointRecord has an EchoSounding element -->
            <!-- and if so apply the depth value to get the resultant elevation.        -->
            <xsl:variable name="ptRecID" select="ID"/>
            <xsl:choose>
              <xsl:when test="/JOBFile/FieldBook/PointRecord[@ID = $ptRecID]/EchoSounding">
                <xsl:variable name="depth" select="/JOBFile/FieldBook/PointRecord[@ID = $ptRecID]/EchoSounding/Depth"/>
                <xsl:value-of select="format-number((Grid/Elevation - $depth) * $ElevConvFactor, $DecPl3, 'Standard')"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="format-number(Grid/Elevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="format-number(Grid/Elevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr5">Kod</xsl:with-param>
      <xsl:with-param name="Val5" select="Code"/>
    </xsl:call-template>
    <!-- Now output any point descriptions -->
    <xsl:call-template name="OutputDescriptions"/>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* WGS-84 Position Output ********************* -->
<!-- **************************************************************** -->
<xsl:template name="WGS84Pos">
  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Nokta</xsl:with-param>
      <xsl:with-param name="Val1" select="Name"/>

      <xsl:with-param name="Hdr2">Enlem</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:call-template name="FormatLatLong">
          <xsl:with-param name="theAngle" select="WGS84/Latitude"/>
          <xsl:with-param name="northLbl">K</xsl:with-param>
          <xsl:with-param name="eastLbl">S</xsl:with-param>
          <xsl:with-param name="southLbl">G</xsl:with-param>
          <xsl:with-param name="westLbl">B</xsl:with-param>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">Boylam</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:call-template name="FormatLatLong">
          <xsl:with-param name="theAngle" select="WGS84/Longitude"/>
          <xsl:with-param name="isLat" select="'false'"/>
          <xsl:with-param name="northLbl">K</xsl:with-param>
          <xsl:with-param name="eastLbl">S</xsl:with-param>
          <xsl:with-param name="southLbl">G</xsl:with-param>
          <xsl:with-param name="westLbl">B</xsl:with-param>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">Yükseklik</xsl:with-param>
      <xsl:with-param name="Val4" select="format-number(WGS84/Height * $ElevConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr5">Kod</xsl:with-param>
      <xsl:with-param name="Val5" select="Code"/>
    </xsl:call-template>
    <!-- Now output any point descriptions -->
    <xsl:call-template name="OutputDescriptions"/>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- **************** Observation Details Output ******************** -->
<!-- **************************************************************** -->
<xsl:template name="Observation">
  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1"><xsl:text>Nokta</xsl:text>
        <xsl:if test="Classification = 'BackSight'"><xsl:text> (Geri)</xsl:text></xsl:if>
      </xsl:with-param>
      <xsl:with-param name="Val1" select="Name"/>

      <xsl:with-param name="Hdr2">YA</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="Circle/HorizontalCircle"/>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">DA</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="Circle/VerticalCircle"/>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">EM</xsl:with-param>
      <xsl:with-param name="Val4" select="format-number(Circle/EDMDistance * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr5">Kod</xsl:with-param>
      <xsl:with-param name="Val5" select="Code"/>
    </xsl:call-template>
    <!-- Now output any point descriptions -->
    <xsl:call-template name="OutputDescriptions"/>

    <xsl:if test="($DetailedRpt = $YesStr) and
                  ((string(number(Circle/HorizontalCircleStandardError)) != 'NaN') or
                   (string(number(Circle/VerticalCircleStandardError)) != 'NaN') or
                   (string(number(Circle/EDMDistanceStandardError)) != 'NaN'))">
      <!-- Add a second line containing the observation std error values -->
      <xsl:call-template name="OutputTableLine">
        <xsl:with-param name="Hdr1">Std Hatalar</xsl:with-param> <!-- No value associated with this -->

        <xsl:with-param name="Hdr2">YA</xsl:with-param>
        <xsl:with-param name="Val2">
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="Circle/HorizontalCircleStandardError"/>
          </xsl:call-template>
        </xsl:with-param>

        <xsl:with-param name="Hdr3">DA</xsl:with-param>
        <xsl:with-param name="Val3">
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="Circle/VerticalCircleStandardError"/>
          </xsl:call-template>
        </xsl:with-param>

        <xsl:with-param name="Hdr4">EM</xsl:with-param>
        <xsl:with-param name="Val4" select="format-number(Circle/EDMDistanceStandardError * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <!-- Add a third line containing the target ht and prism constant values -->
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Refl.Yüksekliği</xsl:with-param>
      <xsl:with-param name="Val1"> 
        <xsl:for-each select="key('tgtID-search', TargetID)[1]">
          <xsl:value-of select="format-number(TargetHeight * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:for-each>
      </xsl:with-param>
      
      <xsl:with-param name="Hdr2">Prizma sabiti</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:for-each select="key('tgtID-search', TargetID)[1]">
          <xsl:value-of select="format-number(PrismConstant * 1000, $DecPl1, 'Standard')"/><xsl:text>mm</xsl:text>
        </xsl:for-each>
      </xsl:with-param>
    </xsl:call-template>      
  <xsl:call-template name="EndTable"/>

  <xsl:if test="DistanceOffset"> <!-- Add Distance offset details -->
    <xsl:call-template name="StartTable"/>
      <xsl:variable name="offsetStr">
        <xsl:choose>
          <xsl:when test="DistanceOffset/Direction">  <!-- This is a pre v11.30 distance offset record -->
            <xsl:variable name="dirStr">
              <xsl:if test="DistanceOffset/Direction = 'Right'">Sağ</xsl:if>
              <xsl:if test="DistanceOffset/Direction = 'Left'">Sol</xsl:if>
              <xsl:if test="DistanceOffset/Direction = 'Out'">Dışarı</xsl:if>
              <xsl:if test="DistanceOffset/Direction = 'In'">İçeri</xsl:if>
            </xsl:variable>
            <xsl:value-of select="concat(format-number(DistanceOffset/Distance * $DistConvFactor, $DecPl3, 'Standard'), ' ', $dirStr)"/>
          </xsl:when>
          <xsl:otherwise>  <!-- This must be the new v11.30 form of distance offset record -->
            <xsl:variable name="LeftRightStr">
              <xsl:if test="DistanceOffset/LeftRightOffset != 0.0">
                <xsl:value-of select="format-number(concat(substring('-',2 - (DistanceOffset/LeftRightOffset &lt; 0)), '1') * DistanceOffset/LeftRightOffset * $DistConvFactor, $DecPl3, 'Standard')"/> <!-- Output the absolute value -->
                <xsl:if test="DistanceOffset/LeftRightOffset &lt; 0.0"> Sol</xsl:if>
                <xsl:if test="DistanceOffset/LeftRightOffset &gt;= 0.0"> Sağ</xsl:if>
              </xsl:if>
            </xsl:variable>
            <xsl:variable name="InOutStr">
              <xsl:if test="DistanceOffset/InOutOffset != 0.0">
                <xsl:value-of select="format-number(concat(substring('-',2 - (DistanceOffset/InOutOffset &lt; 0)), '1') * DistanceOffset/InOutOffset * $DistConvFactor, $DecPl3, 'Standard')"/> <!-- Output the absolute value -->
                <xsl:if test="DistanceOffset/InOutOffset &lt; 0.0"> İçeri</xsl:if>
                <xsl:if test="DistanceOffset/InOutOffset &gt;= 0.0"> Dışarı</xsl:if>
              </xsl:if>
            </xsl:variable>
            <xsl:variable name="DownUpStr">
              <xsl:if test="DistanceOffset/DownUpOffset != 0.0">
                <xsl:value-of select="format-number(concat(substring('-',2 - (DistanceOffset/DownUpOffset &lt; 0)), '1') * DistanceOffset/DownUpOffset * $DistConvFactor, $DecPl3, 'Standard')"/> <!-- Output the absolute value -->
                <xsl:if test="DistanceOffset/DownUpOffset &lt; 0.0"> Aşağı</xsl:if>
                <xsl:if test="DistanceOffset/DownUpOffset &gt;= 0.0"> Yukarı</xsl:if>
              </xsl:if>
            </xsl:variable>
            <xsl:variable name="tempStr">
              <xsl:choose>
                <xsl:when test="(string-length($LeftRightStr) != 0) and (string-length($InOutStr) != 0)">
                  <xsl:value-of select="concat($LeftRightStr, ', ', $InOutStr)"/>
                </xsl:when>
                <xsl:when test="(string-length($LeftRightStr) != 0) and (string-length($InOutStr) = 0)">
                  <xsl:value-of select="$LeftRightStr"/>
                </xsl:when>
                <xsl:when test="(string-length($LeftRightStr) = 0) and (string-length($InOutStr) != 0)">
                  <xsl:value-of select="$InOutStr"/>
                </xsl:when>
                <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
              </xsl:choose>
            </xsl:variable>
            <xsl:choose>
              <xsl:when test="(string-length($tempStr) != 0) and (string-length($DownUpStr) != 0)">
                <xsl:value-of select="concat($tempStr, ', ', $DownUpStr)"/>
              </xsl:when>
              <xsl:when test="(string-length($tempStr) != 0) and (string-length($DownUpStr) = 0)">
                <xsl:value-of select="$tempStr"/>
              </xsl:when>
              <xsl:when test="(string-length($tempStr) = 0) and (string-length($DownUpStr) != 0)">
                <xsl:value-of select="$DownUpStr"/>
              </xsl:when>
              <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
            </xsl:choose>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr"><xsl:text>Mesafe ofseti</xsl:text><xsl:value-of select="concat(' (', Name, ')')"/></xsl:with-param>
        <xsl:with-param name="Val" select="$offsetStr"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Ham Gözlem</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:text>YA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="DistanceOffset/RawObservation/HorizontalCircle"/>
          </xsl:call-template>
          <xsl:text> DA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="DistanceOffset/RawObservation/VerticalCircle"/>
          </xsl:call-template>
          <xsl:text> EM: </xsl:text>
          <xsl:value-of select="format-number(DistanceOffset/RawObservation/EDMDistance * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:with-param>
      </xsl:call-template>
    <xsl:call-template name="EndTable"/>
  </xsl:if>

  <xsl:if test="CircularObject"> <!-- Add circular object details -->
    <xsl:call-template name="StartTable"/>
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr"><xsl:text>Eksentrik obje</xsl:text><xsl:value-of select="concat(' (', Name, ')')"/></xsl:with-param>
        <xsl:with-param name="Val"><xsl:text>Yarıçap: </xsl:text><xsl:value-of select="format-number(CircularObject/Radius * $DistConvFactor, $DecPl3, 'Standard')"/></xsl:with-param>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">İlk Ham Gözlem</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:text>YA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="CircularObject/FirstRawObservation/HorizontalCircle"/>
          </xsl:call-template>
          <xsl:text> DA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="CircularObject/FirstRawObservation/VerticalCircle"/>
          </xsl:call-template>
          <xsl:text> EM: </xsl:text>
          <xsl:value-of select="format-number(CircularObject/FirstRawObservation/EDMDistance * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:with-param>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">İkinci Ham Gözlem</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:text>YA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="CircularObject/SecondRawObservation/HorizontalCircle"/>
          </xsl:call-template>
          <xsl:text> DA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="CircularObject/SecondRawObservation/VerticalCircle"/>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    <xsl:call-template name="EndTable"/>
  </xsl:if>

  <xsl:if test="RemoteObject"> <!-- Add Remote object details -->
    <xsl:call-template name="StartTable"/>
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr"><xsl:text>Uzak obje</xsl:text><xsl:value-of select="concat(' (', Name, ')')"/></xsl:with-param>
          <xsl:with-param name="Val">
            <xsl:variable name="ObjHeight">
              <xsl:if test="RemoteObject/ObjectHeight != ''">
                <xsl:text>Obje yüksekliği</xsl:text>
                <xsl:value-of select="concat(': ', format-number(RemoteObject/ObjectHeight * $DistConvFactor, $DecPl3, 'Standard'), ' ')"/>
              </xsl:if>
            </xsl:variable>
            <xsl:variable name="ObjWidth">
              <xsl:if test="RemoteObject/ObjectWidth != ''">
                <xsl:text>Obje genişliği</xsl:text>
                <xsl:value-of select="concat(': ', format-number(RemoteObject/ObjectWidth * $DistConvFactor, $DecPl3, 'Standard'))"/>
              </xsl:if>
            </xsl:variable>
            <xsl:value-of select="concat($ObjHeight, $ObjWidth)"/>
          </xsl:with-param>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Ham Gözlem</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:text>YA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="RemoteObject/RawObservation/HorizontalCircle"/>
          </xsl:call-template>
          <xsl:text> DA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="RemoteObject/RawObservation/VerticalCircle"/>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    <xsl:call-template name="EndTable"/>
  </xsl:if>

  <xsl:if test="AngleOffset"> <!-- Add Angle offset details -->
    <xsl:call-template name="StartTable"/>
      <xsl:variable name="offsetStr">
        <xsl:choose>
          <xsl:when test="Method = 'HorizontalAngleOffset'">YA ofset</xsl:when>
          <xsl:when test="Method = 'VerticalAngleOffset'">D.Açı ofseti</xsl:when>
          <xsl:otherwise>Açı ofseti</xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr" select="concat($offsetStr, ' (', Name, ')')"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">İlk Ham Gözlem</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:text>YA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="AngleOffset/FirstRawObservation/HorizontalCircle"/>
          </xsl:call-template>
          <xsl:text> DA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="AngleOffset/FirstRawObservation/VerticalCircle"/>
          </xsl:call-template>
          <xsl:text> EM: </xsl:text>
          <xsl:value-of select="format-number(AngleOffset/FirstRawObservation/EDMDistance * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:with-param>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">İkinci Ham Gözlem</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:text>YA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="AngleOffset/SecondRawObservation/HorizontalCircle"/>
          </xsl:call-template>
          <xsl:text> DA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="AngleOffset/SecondRawObservation/VerticalCircle"/>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    <xsl:call-template name="EndTable"/>
  </xsl:if>

  <xsl:if test="DualPrismOffset"> <!-- Add Dual prism offset details -->
    <xsl:call-template name="StartTable"/>
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr"><xsl:text>Çift prizma ofseti</xsl:text><xsl:value-of select="concat(' (', Name, ')')"/></xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:text>BC mesafesi: </xsl:text>
          <xsl:value-of select="format-number(DualPrismOffset/DistanceBC * $DistConvFactor, $DecPl3, 'Standard')"/>
          <xsl:text> Hesaplanan AB: </xsl:text>
          <xsl:value-of select="format-number(DualPrismOffset/CalculatedDistanceAB * $DistConvFactor, $DecPl3, 'Standard')"/>
          <xsl:text> A prizması sabiti: </xsl:text>
          <xsl:value-of select="format-number(DualPrismOffset/PrismConstantA * 1000, $DecPl3, 'Standard')"/>
          <xsl:text>mm B prizması sabiti: </xsl:text>
          <xsl:value-of select="format-number(DualPrismOffset/PrismConstantB * 1000, $DecPl3, 'Standard')"/>
          <xsl:text>mm</xsl:text>
        </xsl:with-param>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">A Prizması Gözlemi</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:text>YA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="DualPrismOffset/PrismAObservation/HorizontalCircle"/>
          </xsl:call-template>
          <xsl:text> DA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="DualPrismOffset/PrismAObservation/VerticalCircle"/>
          </xsl:call-template>
          <xsl:text> EM: </xsl:text>
          <xsl:value-of select="format-number(DualPrismOffset/PrismAObservation/EDMDistance * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:with-param>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">B Prizması Gözlemi</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:text>YA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="DualPrismOffset/PrismBObservation/HorizontalCircle"/>
          </xsl:call-template>
          <xsl:text> DA: </xsl:text>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="DualPrismOffset/PrismBObservation/VerticalCircle"/>
          </xsl:call-template>
          <xsl:text> EM: </xsl:text>
          <xsl:value-of select="format-number(DualPrismOffset/PrismBObservation/EDMDistance * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:with-param>
      </xsl:call-template>
    <xsl:call-template name="EndTable"/>
  </xsl:if>

  <xsl:if test="ObservationPolarDeltas">
    <xsl:call-template name="StartTable"/>

      <xsl:call-template name="OutputTableLine">
        <xsl:with-param name="Hdr1">Deltalar</xsl:with-param>
        <xsl:with-param name="Val1" select="Name"/>

        <xsl:with-param name="Hdr2">Semt A.</xsl:with-param>
        <xsl:with-param name="Val2">
          <xsl:call-template name="FormatAzimuth">
            <xsl:with-param name="theAzimuth" select="ObservationPolarDeltas/Azimuth"/>
            <xsl:with-param name="northLbl">K</xsl:with-param>
            <xsl:with-param name="eastLbl">S</xsl:with-param>
            <xsl:with-param name="southLbl">G</xsl:with-param>
            <xsl:with-param name="westLbl">B</xsl:with-param>
          </xsl:call-template>
        </xsl:with-param>
        
        <xsl:with-param name="Hdr3">YM</xsl:with-param>
        <xsl:with-param name="Val3" select="format-number(ObservationPolarDeltas/HorizontalDistance * $DistConvFactor, $DecPl3, 'Standard')"/>

        <xsl:with-param name="Hdr4">K.Frk</xsl:with-param>
        <xsl:with-param name="Val4" select="format-number(ObservationPolarDeltas/VerticalDistance * $DistConvFactor, $DecPl3, 'Standard')"/>

      </xsl:call-template>
    <xsl:call-template name="EndTable"/>
  </xsl:if>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************************* Polar Output ************************* -->
<!-- **************************************************************** -->
<xsl:template name="Polar">
  <xsl:call-template name="StartTable"/>
    <xsl:variable name="AzType">
      <xsl:if test="AzimuthType[.='Grid']">Azimut (grid)</xsl:if>
      <xsl:if test="AzimuthType[.='Magnetic']">Semt (mag)</xsl:if>
      <xsl:if test="AzimuthType[.='Local']">Semt (lokal)</xsl:if>
      <xsl:if test="AzimuthType[.='WGS84']">Semt (WGS84)</xsl:if>
      <xsl:if test="AzimuthType[.='Sun']">Semt A. (Güneş)</xsl:if>
    </xsl:variable>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Polar</xsl:with-param>
      <xsl:with-param name="Val1" select="Name"/>

      <xsl:with-param name="Hdr2" select="$AzType"/>
      <xsl:with-param name="Val2">
        <xsl:call-template name="FormatAzimuth">
          <xsl:with-param name="theAzimuth" select="Polar/Azimuth"/>
          <xsl:with-param name="northLbl">K</xsl:with-param>
          <xsl:with-param name="eastLbl">S</xsl:with-param>
          <xsl:with-param name="southLbl">G</xsl:with-param>
          <xsl:with-param name="westLbl">B</xsl:with-param>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">YM</xsl:with-param>
      <xsl:with-param name="Val3" select="format-number(Polar/HorizontalDistance * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr4">K.Frk</xsl:with-param>
      <xsl:with-param name="Val4" select="format-number(Polar/VerticalDistance * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr5">Kod</xsl:with-param>
      <xsl:with-param name="Val5" select="Code"/>
    </xsl:call-template>
    <!-- Now output any point descriptions -->
    <xsl:call-template name="OutputDescriptions"/>

    <!-- Add second line providing the source point for the polar data -->
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr2">Kaynak nokta</xsl:with-param>
      <xsl:with-param name="Val2" select="SourcePoint"/>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
</xsl:template>



<!-- **************************************************************** -->
<!-- ************** Mean Turned Angle Details Output **************** -->
<!-- **************************************************************** -->
<xsl:template name="MeanTurnedAngle">
  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Nokta (ODA)</xsl:with-param>
      <xsl:with-param name="Val1" select="Name"/>

      <xsl:with-param name="Hdr2">YA</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="MTA/HorizontalCircle"/>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">DA</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="MTA/VerticalCircle"/>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">EM</xsl:with-param>
      <xsl:with-param name="Val4" select="format-number(MTA/EDMDistance * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr5">Kod</xsl:with-param>
      <xsl:with-param name="Val5" select="Code"/>
    </xsl:call-template>
    <!-- Now output any point descriptions -->
    <xsl:call-template name="OutputDescriptions"/>

    <xsl:if test="($DetailedRpt = $YesStr) and
                  (MTA/HorizontalCircleStandardError != '' or
                   MTA/HorizontalCircleStandardError != '' or 
                   MTA/EDMDistanceStandardError != '')">
      <!-- Add a second line containing the observation std error values -->
      <xsl:call-template name="OutputTableLine">
        <xsl:with-param name="Hdr1">Std Hatalar</xsl:with-param> <!-- No value associated with this -->

        <xsl:with-param name="Hdr2">YA</xsl:with-param>
        <xsl:with-param name="Val2">
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="MTA/HorizontalCircleStandardError"/>
          </xsl:call-template>
        </xsl:with-param>

        <xsl:with-param name="Hdr3">DA</xsl:with-param>
        <xsl:with-param name="Val3">
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="MTA/VerticalCircleStandardError"/>
          </xsl:call-template>
        </xsl:with-param>

        <xsl:with-param name="Hdr4">EM</xsl:with-param>
        <xsl:with-param name="Val4" select="format-number(MTA/EDMDistanceStandardError * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <!-- Add a third line containing the target ht and prism constant values -->
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Refl.Yüksekliği</xsl:with-param>
      <xsl:with-param name="Val1"> 
        <xsl:for-each select="key('tgtID-search', TargetID)[1]">
          <xsl:value-of select="format-number(TargetHeight * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:for-each>
      </xsl:with-param>
      
      <xsl:with-param name="Hdr2">Prizma sabiti</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:for-each select="key('tgtID-search', TargetID)[1]">
          <xsl:value-of select="format-number(PrismConstant * 1000, $DecPl1, 'Standard')"/><xsl:text>mm</xsl:text>
        </xsl:for-each>
      </xsl:with-param>
    </xsl:call-template>      
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ********************** GPS Deltas Output *********************** -->
<!-- **************************************************************** -->
<xsl:template name="GPSPosOrDeltas">
  <xsl:call-template name="StartTable"/>

    <xsl:variable name="XPrompt">
      <xsl:if test="ECEF">X</xsl:if>
      <xsl:if test="ECEFDeltas">ΔX</xsl:if>
    </xsl:variable>

    <xsl:variable name="YPrompt">
      <xsl:if test="ECEF">Y</xsl:if>
      <xsl:if test="ECEFDeltas">ΔY</xsl:if>
    </xsl:variable>

    <xsl:variable name="ZPrompt">
      <xsl:if test="ECEF">Z</xsl:if>
      <xsl:if test="ECEFDeltas">ΔZ</xsl:if>
    </xsl:variable>

    <xsl:variable name="deltas">
      <xsl:choose>
        <xsl:when test="ECEFDeltas and ($vectorDeltasType = 'İşaretten işarete')">
          <xsl:call-template name="ComputeMarkToMarkDeltas"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:element name="deltaX">
            <xsl:value-of select="ECEFDeltas/DeltaX"/>
          </xsl:element>

          <xsl:element name="deltaY">
            <xsl:value-of select="ECEFDeltas/DeltaY"/>
          </xsl:element>

          <xsl:element name="deltaZ">
            <xsl:value-of select="ECEFDeltas/DeltaZ"/>
          </xsl:element>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <xsl:variable name="XVal">
      <xsl:if test="ECEF"><xsl:value-of select="format-number(ECEF/X * $DistConvFactor, $DecPl3, 'Standard')"/></xsl:if>
      <xsl:if test="ECEFDeltas"><xsl:value-of select="format-number(msxsl:node-set($deltas)/deltaX * $DistConvFactor, $DecPl3, 'Standard')"/></xsl:if>
    </xsl:variable>

    <xsl:variable name="YVal">
      <xsl:if test="ECEF"><xsl:value-of select="format-number(ECEF/Y * $DistConvFactor, $DecPl3, 'Standard')"/></xsl:if>
      <xsl:if test="ECEFDeltas"><xsl:value-of select="format-number(msxsl:node-set($deltas)/deltaY * $DistConvFactor, $DecPl3, 'Standard')"/></xsl:if>
    </xsl:variable>

    <xsl:variable name="ZVal">
      <xsl:if test="ECEF"><xsl:value-of select="format-number(ECEF/Z * $DistConvFactor, $DecPl3, 'Standard')"/></xsl:if>
      <xsl:if test="ECEFDeltas"><xsl:value-of select="format-number(msxsl:node-set($deltas)/deltaZ * $DistConvFactor, $DecPl3, 'Standard')"/></xsl:if>
    </xsl:variable>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Nokta</xsl:with-param>
      <xsl:with-param name="Val1" select="Name"/>

      <xsl:with-param name="Hdr2" select="$XPrompt"/>
      <xsl:with-param name="Val2" select="$XVal"/>

      <xsl:with-param name="Hdr3" select="$YPrompt"/>
      <xsl:with-param name="Val3" select="$YVal"/>

      <xsl:with-param name="Hdr4" select="$ZPrompt"/>
      <xsl:with-param name="Val4" select="$ZVal"/>

      <xsl:with-param name="Hdr5">Kod</xsl:with-param>
      <xsl:with-param name="Val5" select="Code"/>
    </xsl:call-template>

    <!-- Now output any point descriptions -->
    <xsl:call-template name="OutputDescriptions"/>

    <!-- Output the survey method details -->
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr2">Metod</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:call-template name="SurveyMethodText"/>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">Tip</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:call-template name="PointCreationTypeText"/>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">Klas arama</xsl:with-param>
      <xsl:with-param name="Val4">
        <xsl:call-template name="ClassificationText"/>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:variable name="antennaDetails">
      <xsl:for-each select="key('antID-search', AntennaID)[1]">
        <xsl:copy-of select="*"/>
      </xsl:for-each>
    </xsl:variable>

    <!-- Add second line with antenna details (including tilt distance if available) and hz and vt precision values -->
    <xsl:choose>
      <xsl:when test="DeviceAxisOrientation">
        <!-- Compute the tilt distance -->
        <xsl:variable name="tiltDist">
          <xsl:for-each select="DeviceAxisOrientation/BiVector">
            <xsl:variable name="sineTiltAngle">
              <xsl:variable name="sineXX">
                <xsl:call-template name="Sine">
                  <xsl:with-param name="theAngle" select="XX"/>
                </xsl:call-template>
              </xsl:variable>
              <xsl:variable name="sineYY">
                <xsl:call-template name="Sine">
                  <xsl:with-param name="theAngle" select="YY"/>
                </xsl:call-template>
              </xsl:variable>
              <xsl:call-template name="Sqrt">  <!-- Return hypotenuse sine component -->
                <xsl:with-param name="num" select="$sineXX * $sineXX + $sineYY * $sineYY"/>
              </xsl:call-template>
            </xsl:variable>

            <xsl:value-of select="$sineTiltAngle * msxsl:node-set($antennaDetails)/ReducedHeight"/>
          </xsl:for-each>
        </xsl:variable>

        <xsl:call-template name="OutputTableLine">
          <xsl:with-param name="Hdr1">Anten yüksekliği</xsl:with-param>
          <xsl:with-param name="Val1" select="format-number(msxsl:node-set($antennaDetails)/MeasuredHeight * $DistConvFactor, $DecPl3, 'Standard')"/>

          <xsl:with-param name="Hdr2">Tip</xsl:with-param>
          <xsl:with-param name="Val2">
            <xsl:choose>
              <xsl:when test="msxsl:node-set($antennaDetails)/MeasurementType = 'Corrected'">Düzeltilmiş</xsl:when>
              <xsl:otherwise>Düzeltmesiz</xsl:otherwise>
            </xsl:choose>
          </xsl:with-param>

          <xsl:with-param name="Hdr3">Düzeç mesafesi</xsl:with-param>
          <xsl:with-param name="Val3" select="format-number($tiltDist * $DistConvFactor, $DecPl3, 'Standard')"/>

          <xsl:with-param name="Hdr4">Yat Pres</xsl:with-param>
          <xsl:with-param name="Val4" select="format-number(Precision/Horizontal * $DistConvFactor, $DecPl3, 'Standard')"/>

          <xsl:with-param name="Hdr5">Düş.Pres</xsl:with-param>
          <xsl:with-param name="Val5" select="format-number(Precision/Vertical * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="OutputTableLine">
          <xsl:with-param name="Hdr1">Anten yüksekliği</xsl:with-param>
          <xsl:with-param name="Val1" select="format-number(msxsl:node-set($antennaDetails)/MeasuredHeight * $DistConvFactor, $DecPl3, 'Standard')"/>

          <xsl:with-param name="Hdr2">Tip</xsl:with-param>
          <xsl:with-param name="Val2">
            <xsl:choose>
              <xsl:when test="msxsl:node-set($antennaDetails)/MeasurementType = 'Corrected'">Düzeltilmiş</xsl:when>
              <xsl:otherwise>Düzeltmesiz</xsl:otherwise>
            </xsl:choose>
          </xsl:with-param>

          <xsl:with-param name="Hdr3">Yat Pres</xsl:with-param>
          <xsl:with-param name="Val3" select="format-number(Precision/Horizontal * $DistConvFactor, $DecPl3, 'Standard')"/>

          <xsl:with-param name="Hdr4">Düş.Pres</xsl:with-param>
          <xsl:with-param name="Val4" select="format-number(Precision/Vertical * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>

    <!-- If the point has an EchoSounding element add a line with the deth details and resultant elevation -->
    <xsl:if test="EchoSounding">
      <xsl:call-template name="OutputTableLine">
        <xsl:with-param name="Hdr1">Derinlik</xsl:with-param>
        <xsl:with-param name="Val1" select="format-number(EchoSounding/Depth * $DistConvFactor, $DecPl3, 'Standard')"/>

        <xsl:with-param name="Hdr2">Gecikme</xsl:with-param>
        <xsl:with-param name="Val2">
          <xsl:value-of select="format-number(preceding-sibling::ContinuousParametersRecord[1]/EchoSounderLatency, $DecPl1, 'Standard')"/>
          <xsl:text> Saniye</xsl:text>
        </xsl:with-param>

        <xsl:with-param name="Hdr3">Kot</xsl:with-param>
        <xsl:with-param name="Val3" select="format-number((ComputedGrid/Elevation - EchoSounding/Depth) * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <!-- If writing a detailed report and there are QC details available - write them out -->
    <xsl:if test="$DetailedRpt = $YesStr">
      <xsl:if test="QualityControl1">
        <xsl:for-each select="QualityControl1">
          <xsl:choose>
            <xsl:when test="not(RMS)">   <!-- This is data from a later receiver that doesn't output the RMS value -->
              <xsl:call-template name="OutputTableLine">
                <xsl:with-param name="Hdr1">QC 1</xsl:with-param>

                <xsl:with-param name="Hdr2">PDOP</xsl:with-param>
                <xsl:with-param name="Val2" select="format-number(PDOP, $DecPl1, 'Standard')"/>

                <xsl:with-param name="Hdr3">GDOP</xsl:with-param>
                <xsl:with-param name="Val3" select="format-number(GDOP, $DecPl1, 'Standard')"/>

                <xsl:with-param name="Hdr4">HDOP</xsl:with-param>
                <xsl:with-param name="Val4" select="format-number(HDOP, $DecPl1, 'Standard')"/>

                <xsl:with-param name="Hdr5">VDOP</xsl:with-param>
                <xsl:with-param name="Val5" select="format-number(VDOP, $DecPl1, 'Standard')"/>
              </xsl:call-template>

              <xsl:call-template name="OutputTableLine">
                <xsl:with-param name="Hdr2">Baz veri yaşlanması</xsl:with-param>
                <xsl:with-param name="Val2" select="RTCMAge"/>

                <xsl:with-param name="Hdr3">Uydular</xsl:with-param>
                <xsl:with-param name="Val3" select="NumberOfSatellites"/>

                <xsl:with-param name="Hdr4">Kull. konumlar</xsl:with-param>
                <xsl:with-param name="Val4" select="NumberOfPositionsUsed"/>
              </xsl:call-template>
            </xsl:when>

            <xsl:otherwise>
              <xsl:call-template name="OutputTableLine">
                <xsl:with-param name="Hdr1">QC 1</xsl:with-param>

                <xsl:with-param name="Hdr2">Uydular</xsl:with-param>
                <xsl:with-param name="Val2" select="NumberOfSatellites"/>

                <xsl:with-param name="Hdr3">PDOP</xsl:with-param>
                <xsl:with-param name="Val3" select="format-number(PDOP, $DecPl1, 'Standard')"/>

                <xsl:with-param name="Hdr4">HDOP</xsl:with-param>
                <xsl:with-param name="Val4" select="format-number(HDOP, $DecPl1, 'Standard')"/>

                <xsl:with-param name="Hdr5">VDOP</xsl:with-param>
                <xsl:with-param name="Val5" select="format-number(VDOP, $DecPl1, 'Standard')"/>
              </xsl:call-template>

              <xsl:choose>
                <xsl:when test="RTCMAge">   <!-- Include the Base data age if present -->
                  <xsl:call-template name="OutputTableLine">
                    <xsl:with-param name="Hdr2">Baz veri yaşlanması</xsl:with-param>
                    <xsl:with-param name="Val2" select="RTCMAge"/>

                    <xsl:with-param name="Hdr3">RMS</xsl:with-param>
                    <xsl:with-param name="Val3" select="format-number(RMS, $DecPl3, 'Standard')"/>

                    <xsl:with-param name="Hdr4">Kull. konumlar</xsl:with-param>
                    <xsl:with-param name="Val4" select="NumberOfPositionsUsed"/>
                  </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:call-template name="OutputTableLine">
                    <xsl:with-param name="Hdr2">RMS</xsl:with-param>
                    <xsl:with-param name="Val2" select="format-number(RMS, $DecPl3, 'Standard')"/>

                    <xsl:with-param name="Hdr3">Kull. konumlar</xsl:with-param>
                    <xsl:with-param name="Val3" select="NumberOfPositionsUsed"/>
                  </xsl:call-template>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:for-each>
      </xsl:if>

      <xsl:if test="QualityControl2">
        <xsl:call-template name="OutputTableLine">
          <xsl:with-param name="Hdr1">QC 2</xsl:with-param>

          <xsl:with-param name="Hdr2">VCV xx (m&#0178;)</xsl:with-param>
          <xsl:with-param name="Val2" select="format-number(QualityControl2/VCVxx, $DecPl6, 'Standard')"/>

          <xsl:with-param name="Hdr3">VCV xy (m&#0178;)</xsl:with-param>
          <xsl:with-param name="Val3" select="format-number(QualityControl2/VCVxy, $DecPl6, 'Standard')"/>

          <xsl:with-param name="Hdr4">VCV xz (m&#0178;)</xsl:with-param>
          <xsl:with-param name="Val4" select="format-number(QualityControl2/VCVxz, $DecPl6, 'Standard')"/>
        </xsl:call-template>

        <xsl:call-template name="OutputTableLine">
          <xsl:with-param name="Hdr3">VCV yy (m&#0178;)</xsl:with-param>
          <xsl:with-param name="Val3" select="format-number(QualityControl2/VCVyy, $DecPl6, 'Standard')"/>

          <xsl:with-param name="Hdr4">VCV yz (m&#0178;)</xsl:with-param>
          <xsl:with-param name="Val4" select="format-number(QualityControl2/VCVyz, $DecPl6, 'Standard')"/>
        </xsl:call-template>

        <xsl:call-template name="OutputTableLine">
          <xsl:with-param name="Hdr4">VCV zz (m&#0178;)</xsl:with-param>
          <xsl:with-param name="Val4" select="format-number(QualityControl2/VCVzz, $DecPl6, 'Standard')"/>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="QualityControl3">
        <xsl:call-template name="OutputTableLine">
          <xsl:with-param name="Hdr1">QC 3</xsl:with-param>

          <xsl:with-param name="Hdr2">σ Kuzey</xsl:with-param>
          <xsl:with-param name="Val2" select="format-number(QualityControl3/SigmaNorth, $DecPl3, 'Standard')"/>

          <xsl:with-param name="Hdr3">σ Doğu</xsl:with-param>
          <xsl:with-param name="Val3" select="format-number(QualityControl3/SigmaEast, $DecPl3, 'Standard')"/>

          <xsl:with-param name="Hdr4">σ Kot</xsl:with-param>
          <xsl:with-param name="Val4" select="format-number(QualityControl3/SigmaElevation, $DecPl3, 'Standard')"/>

          <xsl:with-param name="Hdr5">Kovaryans</xsl:with-param>
          <xsl:with-param name="Val5" select="format-number(QualityControl3/CovarianceNorthEast, $DecPl3, 'Standard')"/>
        </xsl:call-template>

        <xsl:call-template name="OutputTableLine">
          <xsl:with-param name="Hdr2">Yarı-major eksen</xsl:with-param>
          <xsl:with-param name="Val2" select="format-number(QualityControl3/SemiMajorAxis, $DecPl3, 'Standard')"/>

          <xsl:with-param name="Hdr3">Yarı-minor eksen</xsl:with-param>
          <xsl:with-param name="Val3" select="format-number(QualityControl3/SemiMinorAxis, $DecPl3, 'Standard')"/>

          <xsl:with-param name="Hdr4">Yöneltme</xsl:with-param>
          <xsl:with-param name="Val4">
            <xsl:call-template name="FormatAngle">
              <xsl:with-param name="theAngle" select="QualityControl2/Orientation"/>
            </xsl:call-template>
          </xsl:with-param>

          <xsl:with-param name="Hdr5">Değişken birim</xsl:with-param>
          <xsl:with-param name="Val5" select="format-number(QualityControl3/UnitVariance, $DecPl3, 'Standard')"/>
        </xsl:call-template>
      </xsl:if>
    </xsl:if>
    
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- *********** Return appropriate text for SurveyMethod *********** -->
<!-- **************************************************************** -->
<xsl:template name="SurveyMethodText">

  <xsl:choose>
    <xsl:when test="SurveyMethod = 'KeyedIn'">Girildi</xsl:when>
    <xsl:when test="SurveyMethod = 'Autonomous'">Otonom</xsl:when>
    <xsl:when test="SurveyMethod = 'Float'">Float</xsl:when>
    <xsl:when test="SurveyMethod = 'Fix'">Fikslendi</xsl:when>
    <xsl:when test="SurveyMethod = 'Copied'">Kopyalandı</xsl:when>
    <xsl:when test="SurveyMethod = 'Code'">Kod</xsl:when>
    <xsl:when test="SurveyMethod = 'WAAS'">WAAS</xsl:when>
    <xsl:when test="SurveyMethod = 'Inertial'">Inertial</xsl:when>
    <xsl:when test="SurveyMethod = 'NetworkFloat'">Float</xsl:when>
    <xsl:when test="SurveyMethod = 'NetworkFix'">Fikslendi</xsl:when>
    <xsl:when test="SurveyMethod = 'OmniSTARHP'">OmniSTAR HP</xsl:when>
    <xsl:when test="SurveyMethod = 'OmniSTARVBS'">OmniSTAR VBS</xsl:when>
    <xsl:when test="SurveyMethod = 'xFillFloat'">xFill Float</xsl:when>
    <xsl:when test="SurveyMethod = 'xFillFix'">xFill fix</xsl:when>
    <xsl:when test="SurveyMethod = 'RTK'">RTK</xsl:when>
    <xsl:when test="SurveyMethod = 'NetworkRTK'">Ağ RTK</xsl:when>
    <xsl:when test="SurveyMethod = 'RTKxFill'">RTK xFill</xsl:when>
    <xsl:otherwise>Girildi</xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- *** Return appropriate text for Method (point creation type) *** -->
<!-- **************************************************************** -->
<xsl:template name="PointCreationTypeText">

  <xsl:choose>
    <xsl:when test="Method = 'Unknown'">Bilinmeyen</xsl:when>
    <xsl:when test="Method = 'Coordinates'">Koordinatlar</xsl:when>
    <xsl:when test="Method = 'FourPointIntersection'">Dört noktadan kesişim</xsl:when>
    <xsl:when test="Method = 'FromABaseline'">Baz hattından</xsl:when>
    <xsl:when test="Method = 'BearingAndDistanceFromAPoint'">Bir noktadan doğ-mes.</xsl:when>
    <xsl:when test="Method = 'BearingDistancePointIntersection'">Doğr-kenar kesişimi</xsl:when>
    <xsl:when test="Method = 'BearingVerticalPlaneIntersection'">Düşey düzlem ve açı</xsl:when>
    <xsl:when test="Method = 'BearingDistanceIntersection'">Doğr-kenar kesişimi</xsl:when>
    <xsl:when test="Method = 'BearingBearingIntersection'">Doğr-doğr kesişimi</xsl:when>
    <xsl:when test="Method = 'DistanceDistanceIntersection'">Ken-ken kesişimi</xsl:when>
    <xsl:when test="Method = 'ProjectPointToLine'">Doğru'ya projeksiyon noktası</xsl:when>
    <xsl:when test="Method = 'ProjectPointToArc'">Yay'a projeksiyon noktası</xsl:when>
    <xsl:when test="Method = 'GpsStaticObservation'">Topo noktası</xsl:when>
    <xsl:when test="Method = 'GpsFastStaticObservation'">HızlıStatik nokta</xsl:when>
    <xsl:when test="Method = 'GpsRTKControlPoint'">Bilinen kontrol noktası</xsl:when>
    <xsl:when test="Method = 'GpsRTKQuickMark'">Hızlı Nokta</xsl:when>
    <xsl:when test="Method = 'Gps2PointOffset'">2 nokta ofset</xsl:when>
    <xsl:when test="Method = 'Gps4PointIntersection'">4 nokta kesişimi</xsl:when>
    <xsl:when test="Method = 'GpsCheckShot'">Kontrol</xsl:when>
    <xsl:when test="Method = 'GpsStakeOutObservation'">Nokta aplikasyonu</xsl:when>
    <xsl:when test="Method = 'GpsCalibrationPoint'">Kalibrasyon noktası</xsl:when>
    <xsl:when test="Method = 'GpsSingleAutonomousPoint'">Otonom</xsl:when>
    <xsl:when test="Method = 'GpsAverageAutonomousPoint'">Ortalamalı otonom nokta</xsl:when>
    <xsl:when test="starts-with(Method, 'GpsContinuous')">Sürekli</xsl:when>
    <xsl:when test="Method = 'CogoCalculated'">Kogo noktası (hesaplanan)</xsl:when>
    <xsl:when test="Method = 'AlignmentOffsetCalculated'">Alinyman ofseti (hesaplanan)</xsl:when>
    <xsl:when test="Method = 'AzimuthOnly'">Sadece semt</xsl:when>
    <xsl:when test="Method = 'AngleOnly'">Sadece açılar</xsl:when>
    <xsl:when test="Method = 'HorizontalAngleOnly'">Sadece YA</xsl:when>
    <xsl:when test="Method = 'DirectReading'">Açılar ve mesafe</xsl:when>
    <xsl:when test="Method = 'AverageMeasurements'">Gözlemler ortalaması</xsl:when>
    <xsl:when test="Method = 'AngleOffset'">Açı ofseti</xsl:when>
    <xsl:when test="Method = 'HorizontalAngleOffset'">YA ofset</xsl:when>
    <xsl:when test="Method = 'VerticalAngleOffset'">D.Açı ofseti</xsl:when>
    <xsl:when test="Method = 'DistanceOffset'">Mesafe ofseti</xsl:when>
    <xsl:when test="Method = 'DualPrismOffset'">Çift prizma ofseti</xsl:when>
    <xsl:when test="Method = 'CircularObject'">Eksentrik obje</xsl:when>
    <xsl:when test="Method = 'RemoteObject'">Uzak obje</xsl:when>
    <xsl:when test="Method = 'RemoteObjectBasePoint'">Uzak obje (baz noktası)</xsl:when>
    <xsl:when test="Method = 'MeanTurnedAngle'">Ort. dönülen açı</xsl:when>
    <xsl:when test="Method = 'Resection'">Kestirme</xsl:when>
    <xsl:when test="Method = 'LaserOffset'">Lazer noktası</xsl:when>
    <xsl:when test="Method = 'CopiedPoint'">Kopyalanan nokta</xsl:when>
    <xsl:when test="Method = 'FromBase'">Baz noktası</xsl:when>
    <xsl:when test="Method = 'TraverseAdjusted'">Poligon dengelendi</xsl:when>
    <xsl:when test="Method = 'TurnedAngleAndDistance'">Dönülen açı ve mesafe</xsl:when>
    <xsl:when test="Method = 'ReflineSetup'">RefHattı</xsl:when>
    <xsl:otherwise>Bilinmeyen</xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ********** Return appropriate text for Classification ********** -->
<!-- **************************************************************** -->
<xsl:template name="ClassificationText">

  <xsl:choose>
    <xsl:when test="Classification = 'None'">Yok</xsl:when>
    <xsl:when test="Classification = 'Check'">Kontrol</xsl:when>
    <xsl:when test="Classification = 'BackSight'">Geribakış</xsl:when>
    <xsl:when test="Classification = 'Stakeout'">Röleve</xsl:when>
    <xsl:when test="Classification = 'Construction'">Kör</xsl:when>
    <xsl:when test="Classification = 'Normal'">Normal</xsl:when>
    <xsl:when test="Classification = 'MTA'">ODA</xsl:when>
    <xsl:when test="Classification = 'Adjusted'">Dengelenmiş</xsl:when>
    <xsl:when test="Classification = 'Averaged'">Ortalaması alınmış</xsl:when>
    <xsl:when test="Classification = 'Control'">Kontrol</xsl:when>
    <xsl:when test="Classification = 'NetworkAdjusted'">Ağda dengelenmiş</xsl:when>
    <xsl:otherwise>Yok</xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******* Output a table showing GNSS warnings if required ******* -->
<!-- **************************************************************** -->
<xsl:template name="OutputGNSSWarningsTable">

  <xsl:variable name="outputWarnings">
    <xsl:for-each select="QualityControl1/Warnings/*">
      <xsl:if test=". = 'Yes'">
        <xsl:element name="item"/>
      </xsl:if>
    </xsl:for-each>
  </xsl:variable>

  <xsl:if test="count(msxsl:node-set($outputWarnings)/*) != 0">
    <xsl:variable name="ptName" select="Name"/>
    <xsl:for-each select="QualityControl1">
    <xsl:variable name="measureWarning">
      <xsl:for-each select="Warnings/*[contains(name(.), 'Warning')]">
        <xsl:if test=". = 'Yes'">
          <xsl:element name="item"/>
        </xsl:if>
      </xsl:for-each>
    </xsl:variable>

    <xsl:variable name="storageWarning">
      <xsl:for-each select="Warnings/*[contains(name(.), 'AtStorage')]">
        <xsl:if test=". = 'Yes'">
          <xsl:element name="item"/>
        </xsl:if>
      </xsl:for-each>
    </xsl:variable>

    <table border="1" cellpadding="2" width="100%">
      <xsl:if test="count(msxsl:node-set($measureWarning)/*) != 0">
        <tr>
          <th align="left" width="25%">
            <xsl:text>Uyarılar (</xsl:text>
            <xsl:value-of select="$ptName"/>
            <xsl:text>)</xsl:text>
          </th>
          <xsl:for-each select="Warnings/*[contains(name(.), 'Warning')]">
            <xsl:if test=". = 'Yes'">
                <xsl:choose>
                  <xsl:when test="name() = 'ExcessVibrationWarning'">
                    <td>
                      <xsl:text>Yüksek titreşim</xsl:text>
                    </td>
                  </xsl:when>
                  <xsl:when test="name() = 'ExcessTiltWarning'">
                    <td>
                      <xsl:text>Aşırı düzeçsiz</xsl:text>
                    </td>
                  </xsl:when>
                  <xsl:when test="name() = 'ExcessMovementWarning'">
                    <td>
                      <xsl:text>Anten hareketli</xsl:text>
                    </td>
                  </xsl:when>
                  <xsl:when test="name() = 'PoorPrecisionsWarning'">
                    <td>
                      <xsl:text>Kötü hassasiyet</xsl:text>
                    </td>
                  </xsl:when>
                </xsl:choose>
            </xsl:if>
          </xsl:for-each>
          <xsl:if test="count(msxsl:node-set($storageWarning)/*) &gt; count(msxsl:node-set($measureWarning)/*)">
            <xsl:call-template name="AddBlankCells">
              <xsl:with-param name="count" select="count(msxsl:node-set($storageWarning)/*) - count(msxsl:node-set($measureWarning)/*)"/>
            </xsl:call-template>
          </xsl:if>
        </tr>
      </xsl:if>

      <xsl:if test="count(msxsl:node-set($storageWarning)/*) != 0">
        <tr>
          <th align="left" width="25%">
            <xsl:text>Saklama koşulları (</xsl:text>
            <xsl:value-of select="$ptName"/>
            <xsl:text>)</xsl:text>
          </th>
          <xsl:for-each select="Warnings/*[contains(name(.), 'AtStorage')]">
            <xsl:if test=". = 'Yes'">
                <xsl:choose>
                  <xsl:when test="name() = 'ExcessVibrationAtStorage'">
                    <td>
                      <xsl:text>Yüksek titreşim</xsl:text>
                    </td>
                  </xsl:when>
                  <xsl:when test="name() = 'ExcessTiltAtStorage'">
                    <td>
                      <xsl:text>Aşırı düzeçsiz</xsl:text>
                    </td>
                  </xsl:when>
                  <xsl:when test="name() = 'ExcessMovementAtStorage'">
                    <td>
                      <xsl:text>Anten hareketli</xsl:text>
                    </td>
                  </xsl:when>
                  <xsl:when test="name() = 'PoorPrecisionsAtStorage'">
                    <td>
                      <xsl:text>Kötü hassasiyet</xsl:text>
                    </td>
                  </xsl:when>
                </xsl:choose>
            </xsl:if>
          </xsl:for-each>
          <xsl:if test="count(msxsl:node-set($measureWarning)/*) &gt; count(msxsl:node-set($storageWarning)/*)">
            <xsl:call-template name="AddBlankCells">
              <xsl:with-param name="count" select="count(msxsl:node-set($measureWarning)/*) - count(msxsl:node-set($storageWarning)/*)"/>
            </xsl:call-template>
          </xsl:if>
        </tr>
      </xsl:if>
    </table>
    </xsl:for-each>
  </xsl:if>
</xsl:template>


<!-- **************************************************************** -->
<!-- *** Recursive routine to add specified number of blank cells *** -->
<!-- **************************************************************** -->
<xsl:template name="AddBlankCells">
  <xsl:param name="count"/>
  
  <xsl:if test="$count &gt; 0">
    <td>&#160;</td>
    <xsl:call-template name="AddBlankCells">
      <xsl:with-param name="count" select="$count - 1"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>


<!-- **************************************************************** -->
<!-- **************** Compute mark to mark deltas ******************* -->
<!-- **************************************************************** -->
<xsl:template name="ComputeMarkToMarkDeltas">

  <!-- First get the base lat, long, height position -->
  <xsl:variable name="basePos">
    <xsl:variable name="baseName" select="RTK_Base"/>
    <xsl:for-each select="/JOBFile/Reductions/Point[Name = $baseName]">
      <xsl:copy-of select="WGS84"/>
    </xsl:for-each>
  </xsl:variable>
  
  <!-- Compute the ECEF position for the base -->
  <xsl:variable name="baseECEF">
    <xsl:element name="X">
      <xsl:call-template name="ecefX">
        <xsl:with-param name="latitude" select="msxsl:node-set($basePos)/WGS84/Latitude"/>
        <xsl:with-param name="longitude" select="msxsl:node-set($basePos)/WGS84/Longitude"/>
        <xsl:with-param name="height" select="msxsl:node-set($basePos)/WGS84/Height"/>
      </xsl:call-template>
    </xsl:element>
    
    <xsl:element name="Y">
      <xsl:call-template name="ecefY">
        <xsl:with-param name="latitude" select="msxsl:node-set($basePos)/WGS84/Latitude"/>
        <xsl:with-param name="longitude" select="msxsl:node-set($basePos)/WGS84/Longitude"/>
        <xsl:with-param name="height" select="msxsl:node-set($basePos)/WGS84/Height"/>
      </xsl:call-template>
    </xsl:element>

    <xsl:element name="Z">
      <xsl:call-template name="ecefZ">
        <xsl:with-param name="latitude" select="msxsl:node-set($basePos)/WGS84/Latitude"/>
        <xsl:with-param name="height" select="msxsl:node-set($basePos)/WGS84/Height"/>
      </xsl:call-template>
    </xsl:element>
  </xsl:variable>
  
  <!-- Apply the antenna height to the base height and compute the base APC ECEF position -->
  <xsl:variable name="baseAntHt">
    <xsl:for-each select="key('refID-search', ReferenceRecordID)">
      <xsl:value-of select="key('antID-search', AntennaID)[1]/ReducedHeight"/>
    </xsl:for-each>
  </xsl:variable>
  <xsl:variable name="baseAPCHeight" select="msxsl:node-set($basePos)/WGS84/Height + $baseAntHt"/>

  <xsl:variable name="baseAPC_ECEF">
    <xsl:element name="X">
      <xsl:call-template name="ecefX">
        <xsl:with-param name="latitude" select="msxsl:node-set($basePos)/WGS84/Latitude"/>
        <xsl:with-param name="longitude" select="msxsl:node-set($basePos)/WGS84/Longitude"/>
        <xsl:with-param name="height" select="$baseAPCHeight"/>
      </xsl:call-template>
    </xsl:element>

    <xsl:element name="Y">
      <xsl:call-template name="ecefY">
        <xsl:with-param name="latitude" select="msxsl:node-set($basePos)/WGS84/Latitude"/>
        <xsl:with-param name="longitude" select="msxsl:node-set($basePos)/WGS84/Longitude"/>
        <xsl:with-param name="height" select="$baseAPCHeight"/>
      </xsl:call-template>
    </xsl:element>

    <xsl:element name="Z">
      <xsl:call-template name="ecefZ">
        <xsl:with-param name="latitude" select="msxsl:node-set($basePos)/WGS84/Latitude"/>
        <xsl:with-param name="height" select="$baseAPCHeight"/>
      </xsl:call-template>
    </xsl:element>
  </xsl:variable>

  <!-- Now apply the ECEF deltas to the base APC position to get the rover APC position -->
  <xsl:variable name="roverAPC_ECEF">
    <xsl:element name="X">
      <xsl:value-of select="msxsl:node-set($baseAPC_ECEF)/X + ECEFDeltas/DeltaX"/>
    </xsl:element>

    <xsl:element name="Y">
      <xsl:value-of select="msxsl:node-set($baseAPC_ECEF)/Y + ECEFDeltas/DeltaY"/>
    </xsl:element>

    <xsl:element name="Z">
      <xsl:value-of select="msxsl:node-set($baseAPC_ECEF)/Z + ECEFDeltas/DeltaZ"/>
    </xsl:element>
  </xsl:variable>
  
  <!-- Convert the rover APC position to lat, long, height -->
  <xsl:variable name="roverAPC">
    <xsl:variable name="latitude">
      <xsl:call-template name="LatFromXYZ">
        <xsl:with-param name="X" select="msxsl:node-set($roverAPC_ECEF)/X"/>
        <xsl:with-param name="Y" select="msxsl:node-set($roverAPC_ECEF)/Y"/>
        <xsl:with-param name="Z" select="msxsl:node-set($roverAPC_ECEF)/Z"/>
      </xsl:call-template>
    </xsl:variable>

    <xsl:element name="latitude">
      <xsl:value-of select="$latitude"/>
    </xsl:element>

    <xsl:element name="longitude">
      <xsl:call-template name="LongFromXYZ">
        <xsl:with-param name="X" select="msxsl:node-set($roverAPC_ECEF)/X"/>
        <xsl:with-param name="Y" select="msxsl:node-set($roverAPC_ECEF)/Y"/>
      </xsl:call-template>
    </xsl:element>

    <xsl:element name="height">
      <xsl:call-template name="HeightFromXYZ">
        <xsl:with-param name="X" select="msxsl:node-set($roverAPC_ECEF)/X"/>
        <xsl:with-param name="Y" select="msxsl:node-set($roverAPC_ECEF)/Y"/>
        <xsl:with-param name="Z" select="msxsl:node-set($roverAPC_ECEF)/Z"/>
        <xsl:with-param name="lat" select="$latitude"/>
      </xsl:call-template>
    </xsl:element>
  </xsl:variable>
  
  <!-- Apply the rover antenna height to the APC position height -->
  <xsl:variable name="roverAntHt" select="key('antID-search', AntennaID)[1]/ReducedHeight"/>
  <xsl:variable name="roverHeight" select="msxsl:node-set($roverAPC)/height - $roverAntHt"/>

  <!-- Compute the ECEF position for the rover -->
  <xsl:variable name="roverECEF">
    <xsl:element name="X">
      <xsl:call-template name="ecefX">
        <xsl:with-param name="latitude" select="msxsl:node-set($roverAPC)/latitude * 180.0 div $Pi"/>
        <xsl:with-param name="longitude" select="msxsl:node-set($roverAPC)/longitude * 180.0 div $Pi"/>
        <xsl:with-param name="height" select="$roverHeight"/>
      </xsl:call-template>
    </xsl:element>

    <xsl:element name="Y">
      <xsl:call-template name="ecefY">
        <xsl:with-param name="latitude" select="msxsl:node-set($roverAPC)/latitude * 180.0 div $Pi"/>
        <xsl:with-param name="longitude" select="msxsl:node-set($roverAPC)/longitude * 180.0 div $Pi"/>
        <xsl:with-param name="height" select="$roverHeight"/>
      </xsl:call-template>
    </xsl:element>

    <xsl:element name="Z">
      <xsl:call-template name="ecefZ">
        <xsl:with-param name="latitude" select="msxsl:node-set($roverAPC)/latitude * 180.0 div $Pi"/>
        <xsl:with-param name="height" select="$roverHeight"/>
      </xsl:call-template>
    </xsl:element>
  </xsl:variable>
  
  <!-- Return the mark to mark deltas -->
  <xsl:element name="deltaX">
    <xsl:value-of select="msxsl:node-set($roverECEF)/X - msxsl:node-set($baseECEF)/X"/>
  </xsl:element>

  <xsl:element name="deltaY">
    <xsl:value-of select="msxsl:node-set($roverECEF)/Y - msxsl:node-set($baseECEF)/Y"/>
  </xsl:element>

  <xsl:element name="deltaZ">
    <xsl:value-of select="msxsl:node-set($roverECEF)/Z - msxsl:node-set($baseECEF)/Z"/>
  </xsl:element>
</xsl:template>


<!-- **************************************************************** -->
<!-- ********************* Laser Offset Output ********************** -->
<!-- **************************************************************** -->
<xsl:template name="LaserOffset">
  <xsl:call-template name="StartTable"/>

    <xsl:variable name="AzType">
      <xsl:if test="AzimuthType[.='Grid']">Grid</xsl:if>
      <xsl:if test="AzimuthType[.='Magnetic']">Mag</xsl:if>
      <xsl:if test="AzimuthType[.='Local']">Lokal</xsl:if>
      <xsl:if test="AzimuthType[.='WGS84']">WGS84</xsl:if>
      <xsl:if test="AzimuthType[.='Sun']">Güneş</xsl:if>
    </xsl:variable>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Lazer noktası</xsl:with-param>

      <xsl:with-param name="Hdr2">Baz noktası</xsl:with-param>
      <xsl:with-param name="Val2" select="BasePoint"/>

      <xsl:with-param name="Hdr3">Lazer yüksekliği</xsl:with-param>
      <xsl:with-param name="Val3" select="format-number(LaserHeight * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr4">Semt A.</xsl:with-param>
      <xsl:with-param name="Val4" select="$AzType"/>

      <xsl:with-param name="Hdr5">
        <xsl:if test="MagneticDeclination">Manyetik sapma</xsl:if>
      </xsl:with-param>
      <xsl:with-param name="Val5">
        <xsl:if test="MagneticDeclination">
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="MagneticDeclination"/>
          </xsl:call-template>
        </xsl:if>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Nokta</xsl:with-param>
      <xsl:with-param name="Val1" select="Name"/>

      <xsl:with-param name="Hdr2">Semt A.</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:call-template name="FormatAzimuth">
          <xsl:with-param name="theAzimuth" select="LaserOffset/Azimuth"/>
          <xsl:with-param name="northLbl">K</xsl:with-param>
          <xsl:with-param name="eastLbl">S</xsl:with-param>
          <xsl:with-param name="southLbl">G</xsl:with-param>
          <xsl:with-param name="westLbl">B</xsl:with-param>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">DA</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="LaserOffset/VerticalAngle"/>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">EM</xsl:with-param>
      <xsl:with-param name="Val4" select="format-number(LaserOffset/SlopeDistance * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr5">Refl.Yüksekliği</xsl:with-param>
      <xsl:with-param name="Val5" select="format-number(LaserTargetHeight * $DistConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- **************** Resection Standard Errors Output ************** -->
<!-- **************************************************************** -->
<xsl:template name="ResectionStandardErrors">
  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Kestirme</xsl:with-param>
      <xsl:with-param name="Val1" select="Name"/>

      <xsl:with-param name="Hdr2">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">Std Hata (K)</xsl:when>
          <xsl:otherwise>Std Hata (S)</xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">
            <xsl:value-of select="format-number(ResectionStandardErrors/NorthStandardError * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="format-number(ResectionStandardErrors/EastStandardError * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">Std Hata (S)</xsl:when>
          <xsl:otherwise>Std Hata (K)</xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">
            <xsl:value-of select="format-number(ResectionStandardErrors/EastStandardError * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="format-number(ResectionStandardErrors/NorthStandardError * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">Std Hata (Kot)</xsl:with-param>
      <xsl:with-param name="Val4" select="format-number(ResectionStandardErrors/ElevationStandardError * $ElevConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** Entered Data Record Output ******************* -->
<!-- **************************************************************** -->
<xsl:template name="EnteredData">

  <xsl:choose>
    <xsl:when test="EnteredData/Method[.='BearingDistanceIntersection'] or 
                    EnteredData/Method[.='BearingBearingIntersection'] or
                    EnteredData/Method[.='DistanceDistanceIntersection']">
      <xsl:call-template name="COGOStdIntersection"/>
    </xsl:when>

    <xsl:when test="EnteredData/Method[.='FourPointIntersection']">
      <xsl:call-template name="FourPointIntersection"/>
    </xsl:when>

    <xsl:when test="EnteredData/Method[.='BearingAndDistanceFromAPoint'] or 
                    (EnteredData/Method[.='BearingDistancePointIntersection'] and
                     EnteredData/AzimuthType[.!='Sun'])">
      <xsl:call-template name="BearingDistanceFromPoint"/>
    </xsl:when>

    <xsl:when test="EnteredData/Method[.='TurnedAngleAndDistance'] or
                    (EnteredData/Method[.='BearingDistancePointIntersection'] and
                     EnteredData/AzimuthType[.='Sun'])">
      <xsl:call-template name="TurnedAngleAndDistance"/>
    </xsl:when>

    <xsl:when test="EnteredData/Method[.='FromABaseline']">
      <xsl:call-template name="FromABaseline"/>
    </xsl:when>

    <xsl:when test="EnteredData/Method[.='BearngVerticalPlaneIntersection']">
      <xsl:call-template name="BearngVerticalPlaneIntersection"/>
    </xsl:when>
  </xsl:choose>

  <xsl:call-template name="BlankLine"/>

</xsl:template>


<!-- **************************************************************** -->
<!-- ******************** 3D Axes Record Output ********************* -->
<!-- **************************************************************** -->
<xsl:template name="Measure3DAxes">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">3B eksen ölçme</p></caption>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Nokta</xsl:with-param>
      <xsl:with-param name="Val1">
        <xsl:value-of select="Name"/>
      </xsl:with-param>
      <xsl:with-param name="Hdr2">1. Nokta</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:value-of select="Measure3DAxes/Point1/Name"/>
      </xsl:with-param>
      <xsl:with-param name="Hdr3">2. Nokta</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:value-of select="Measure3DAxes/Point2/Name"/>
      </xsl:with-param>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>

  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">3B eksene dik farklar</p></caption>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Y.Ofset</xsl:with-param>
      <xsl:with-param name="Val1">
        <xsl:value-of select="format-number(Measure3DAxes/OrthogonalIntersectionPointDetails/HorizontalOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
      <xsl:with-param name="Hdr2">Dik ofset</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:value-of select="format-number(Measure3DAxes/OrthogonalIntersectionPointDetails/PerpendicularOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
      <xsl:with-param name="Hdr3">Radyal ofset</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:value-of select="format-number(Measure3DAxes/OrthogonalIntersectionPointDetails/RadialOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
      <xsl:with-param name="Hdr4">1. noktaya mesafe</xsl:with-param>
      <xsl:with-param name="Val4">
        <xsl:value-of select="format-number(Measure3DAxes/OrthogonalIntersectionPointDetails/DistanceToPoint1 * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
      <xsl:with-param name="Hdr5">2. noktaya mesafe</xsl:with-param>
      <xsl:with-param name="Val5">
        <xsl:value-of select="format-number(Measure3DAxes/OrthogonalIntersectionPointDetails/DistanceToPoint2 * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
    </xsl:call-template>

    <!-- Output the intersection point -->
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Kesim noktası</xsl:with-param>

      <xsl:with-param name="Hdr2">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'"><xsl:value-of select="$northPrompt"/></xsl:when>
          <xsl:otherwise><xsl:value-of select="$eastPrompt"/></xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">
            <xsl:value-of select="format-number(Measure3DAxes/OrthogonalIntersectionPointDetails/IntersectionPoint/North * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="format-number(Measure3DAxes/OrthogonalIntersectionPointDetails/IntersectionPoint/East * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'"><xsl:value-of select="$eastPrompt"/></xsl:when>
          <xsl:otherwise><xsl:value-of select="$northPrompt"/></xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">
            <xsl:value-of select="format-number(Measure3DAxes/OrthogonalIntersectionPointDetails/IntersectionPoint/East * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="format-number(Measure3DAxes/OrthogonalIntersectionPointDetails/IntersectionPoint/North * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr4"><xsl:value-of select="$elevPrompt"/></xsl:with-param>
      <xsl:with-param name="Val4">
        <xsl:value-of select="format-number(Measure3DAxes/OrthogonalIntersectionPointDetails/IntersectionPoint/Elevation * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>

  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">3B eksene düşey farklar</p></caption>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Y.Ofset</xsl:with-param>
      <xsl:with-param name="Val1">
        <xsl:value-of select="format-number(Measure3DAxes/VerticalIntersectionPointDetails/HorizontalOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
      <xsl:with-param name="Hdr2">Dik ofset</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:value-of select="format-number(Measure3DAxes/VerticalIntersectionPointDetails/VerticalOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
      <xsl:with-param name="Hdr3">Radyal ofset</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:value-of select="format-number(Measure3DAxes/VerticalIntersectionPointDetails/RadialOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
      <xsl:with-param name="Hdr4">1. noktaya mesafe</xsl:with-param>
      <xsl:with-param name="Val4">
        <xsl:value-of select="format-number(Measure3DAxes/VerticalIntersectionPointDetails/DistanceToPoint1 * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
      <xsl:with-param name="Hdr5">2. noktaya mesafe</xsl:with-param>
      <xsl:with-param name="Val5">
        <xsl:value-of select="format-number(Measure3DAxes/VerticalIntersectionPointDetails/DistanceToPoint2 * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
    </xsl:call-template>

    <!-- Output the intersection point -->
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Kesim noktası</xsl:with-param>

      <xsl:with-param name="Hdr2">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'"><xsl:value-of select="$northPrompt"/></xsl:when>
          <xsl:otherwise><xsl:value-of select="$eastPrompt"/></xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">
            <xsl:value-of select="format-number(Measure3DAxes/VerticalIntersectionPointDetails/IntersectionPoint/North * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="format-number(Measure3DAxes/VerticalIntersectionPointDetails/IntersectionPoint/East * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'"><xsl:value-of select="$eastPrompt"/></xsl:when>
          <xsl:otherwise><xsl:value-of select="$northPrompt"/></xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">
            <xsl:value-of select="format-number(Measure3DAxes/VerticalIntersectionPointDetails/IntersectionPoint/East * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="format-number(Measure3DAxes/VerticalIntersectionPointDetails/IntersectionPoint/North * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr4"><xsl:value-of select="$elevPrompt"/></xsl:with-param>
      <xsl:with-param name="Val4">
        <xsl:value-of select="format-number(Measure3DAxes/VerticalIntersectionPointDetails/IntersectionPoint/Elevation * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****** Handle Brg-Brg, Brg-Dist and Dist-Dist Int Output ******* -->
<!-- **************************************************************** -->
<xsl:template name="COGOStdIntersection">

  <xsl:variable name="Az1Type">
    <xsl:choose>
      <xsl:when test="EnteredData/AzimuthType[.='Grid']">Semt 1 (grid)</xsl:when>
      <xsl:when test="EnteredData/AzimuthType[.='Local']">Semt 1 (lokal)</xsl:when>
      <xsl:when test="EnteredData/AzimuthType[.='WGS84']">Semt 1 (WGS84)</xsl:when>
      <xsl:otherwise>Azimut 1</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="Az2Type">
    <xsl:choose>
      <xsl:when test="EnteredData/AzimuthType[.='Grid']">Semt 2 (grid)</xsl:when>
      <xsl:when test="EnteredData/AzimuthType[.='Local']">Semt 2 (lokal)</xsl:when>
      <xsl:when test="EnteredData/AzimuthType[.='WGS84']">Semt 2 (WGS84)</xsl:when>
      <xsl:otherwise>Azimut 2</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="Dist1Type">
    <xsl:if test="EnteredData/DistanceType[.='Grid']">1. Kenar (grid)</xsl:if>
    <xsl:if test="EnteredData/DistanceType[.='Ground']">1. Kenar (yersel)</xsl:if>
    <xsl:if test="EnteredData/DistanceType[.='Ellipsoid']">1. Kenar (elip)</xsl:if>
  </xsl:variable>

  <xsl:variable name="Dist2Type">
    <xsl:if test="EnteredData/DistanceType[.='Grid']">2. Kenar (grid)</xsl:if>
    <xsl:if test="EnteredData/DistanceType[.='Ground']">2. Kenar (yersel)</xsl:if>
    <xsl:if test="EnteredData/DistanceType[.='Ellipsoid']">2. Kenar (elip)</xsl:if>
  </xsl:variable>

  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Hesap detayları</xsl:with-param>
      <xsl:with-param name="Val1">
        <xsl:if test="EnteredData/Method[.='BearingDistanceIntersection']">Doğr-kenar kesişimi</xsl:if>
        <xsl:if test="EnteredData/Method[.='BearingBearingIntersection']">Doğr-doğr kesişimi</xsl:if>
        <xsl:if test="EnteredData/Method[.='DistanceDistanceIntersection']">Ken-ken kesişimi</xsl:if>
      </xsl:with-param>

      <xsl:with-param name="Hdr2">1. Nokta</xsl:with-param>
      <xsl:with-param name="Val2" select="EnteredData/PointOne"/>

      <xsl:with-param name="Hdr3">2. Nokta</xsl:with-param>
      <xsl:with-param name="Val3" select="EnteredData/PointTwo"/>

      <xsl:with-param name="Hdr4">
        <xsl:choose>
          <xsl:when test="EnteredData/AzimuthOne != ''">
            <xsl:value-of select="$Az1Type"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$Dist1Type"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val4">
        <xsl:choose>
          <xsl:when test="EnteredData/AzimuthOne != ''">
            <xsl:call-template name="FormatAzimuth">
              <xsl:with-param name="theAzimuth" select="EnteredData/AzimuthOne"/>
              <xsl:with-param name="northLbl">K</xsl:with-param>
              <xsl:with-param name="eastLbl">S</xsl:with-param>
              <xsl:with-param name="southLbl">G</xsl:with-param>
              <xsl:with-param name="westLbl">B</xsl:with-param>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="format-number(EnteredData/DistanceOne * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr5">
        <xsl:choose>
          <xsl:when test="EnteredData/AzimuthTwo != ''">
            <xsl:value-of select="$Az2Type"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$Dist2Type"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val5">
        <xsl:choose>
          <xsl:when test="EnteredData/AzimuthTwo != ''">
            <xsl:call-template name="FormatAzimuth">
              <xsl:with-param name="theAzimuth" select="EnteredData/AzimuthTwo"/>
              <xsl:with-param name="northLbl">K</xsl:with-param>
              <xsl:with-param name="eastLbl">S</xsl:with-param>
              <xsl:with-param name="southLbl">G</xsl:with-param>
              <xsl:with-param name="westLbl">B</xsl:with-param>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="format-number(EnteredData/DistanceTwo * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************* Handle Four Point Intersection Output ************ -->
<!-- **************************************************************** -->
<xsl:template name="FourPointIntersection">

  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Hesap detayları</xsl:with-param>
      <xsl:with-param name="Val1">Dört noktadan kesişim</xsl:with-param>

      <xsl:with-param name="Hdr2">İlk nokta (1.dogru)</xsl:with-param>
      <xsl:with-param name="Val2" select="EnteredData/PointOne"/>

      <xsl:with-param name="Hdr3">Son nokta (1. doğru)</xsl:with-param>
      <xsl:with-param name="Val3" select="EnteredData/PointTwo"/>

      <xsl:with-param name="Hdr4">İlk nokta (2.dogru)</xsl:with-param>
      <xsl:with-param name="Val4" select="EnteredData/PointThree"/>

      <xsl:with-param name="Hdr5">Son nokta (2. doğru)</xsl:with-param>
      <xsl:with-param name="Val5" select="EnteredData/PointFour"/>
    </xsl:call-template>

  <!-- Add a second line with the vertical offset value -->
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr2">Düşey ofset</xsl:with-param>
      <xsl:with-param name="Val2" select="format-number(EnteredData/VerticalOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>

  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******** Handle Bearing and Distance from Point Output ********* -->
<!-- **************************************************************** -->
<xsl:template name="BearingDistanceFromPoint">

  <xsl:variable name="AzType">
    <xsl:choose>
      <xsl:when test="EnteredData/AzimuthType[.='Grid']">Azimut (grid)</xsl:when>
      <xsl:when test="EnteredData/AzimuthType[.='Magnetic']">Semt (mag)</xsl:when>
      <xsl:when test="EnteredData/AzimuthType[.='Local']">Semt (lokal)</xsl:when>
      <xsl:when test="EnteredData/AzimuthType[.='WGS84']">Semt (WGS84)</xsl:when>
      <xsl:otherwise>Semt A.</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="DistType">
    <xsl:if test="EnteredData/DistanceType[.='Grid']">Kenar (grid)</xsl:if>
    <xsl:if test="EnteredData/DistanceType[.='Ground']">Kenar (yersel)</xsl:if>
    <xsl:if test="EnteredData/DistanceType[.='Ellipsoid']">Kenar (elip)</xsl:if>
  </xsl:variable>

  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Hesap detayları</xsl:with-param>
      <xsl:with-param name="Val1">Bir noktadan doğ-mes.</xsl:with-param>

      <xsl:with-param name="Hdr2">İlk nokta</xsl:with-param>
      <xsl:with-param name="Val2" select="EnteredData/PointOne"/>

      <xsl:with-param name="Hdr3" select="$AzType"/>
      <xsl:with-param name="Val3">
        <xsl:call-template name="FormatAzimuth">
          <xsl:with-param name="theAzimuth" select="EnteredData/AzimuthOne"/>
          <xsl:with-param name="northLbl">K</xsl:with-param>
          <xsl:with-param name="eastLbl">S</xsl:with-param>
          <xsl:with-param name="southLbl">G</xsl:with-param>
          <xsl:with-param name="westLbl">B</xsl:with-param>
        </xsl:call-template>
      </xsl:with-param>
      
      <xsl:with-param name="Hdr4" select="$DistType"/>
      <xsl:with-param name="Val4" select="format-number(EnteredData/DistanceOne * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr5">Düşey ofset</xsl:with-param>
      <xsl:with-param name="Val5" select="format-number(EnteredData/VerticalOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- *********** Handle Turned Angle and Distance Output ************ -->
<!-- **************************************************************** -->
<xsl:template name="TurnedAngleAndDistance">

  <xsl:variable name="AzType">
    <xsl:choose>
      <xsl:when test="EnteredData/AzimuthType[.='Grid']">Azimut (grid)</xsl:when>
      <xsl:when test="EnteredData/AzimuthType[.='Magnetic']">Semt (mag)</xsl:when>
      <xsl:when test="EnteredData/AzimuthType[.='Local']">Semt (lokal)</xsl:when>
      <xsl:when test="EnteredData/AzimuthType[.='WGS84']">Semt (WGS84)</xsl:when>
      <xsl:otherwise>Semt A.</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="DistType">
    <xsl:if test="EnteredData/DistanceType[.='Grid']">Kenar (grid)</xsl:if>
    <xsl:if test="EnteredData/DistanceType[.='Ground']">Kenar (yersel)</xsl:if>
    <xsl:if test="EnteredData/DistanceType[.='Ellipsoid']">Kenar (elip)</xsl:if>
  </xsl:variable>

  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Hesap detayları</xsl:with-param>
      <xsl:with-param name="Val1">
        <xsl:choose>
        <xsl:when test="EnteredData/AzimuthType = 'Sun'">Bir noktadan doğr-mes.</xsl:when>
        <xsl:otherwise>Dönülen açı ve mesafe</xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr2">İlk nokta</xsl:with-param>
      <xsl:with-param name="Val2" select="EnteredData/PointOne"/>

      <xsl:with-param name="Hdr3">
        <xsl:choose>
          <xsl:when test="EnteredData/PointTwo != ''">Son nokta</xsl:when>
          <xsl:otherwise><xsl:value-of select="$AzType"/></xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:choose>
          <xsl:when test="EnteredData/PointTwo != ''">
            <xsl:value-of select="EnteredData/PointTwo"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:call-template name="FormatAzimuth">
              <xsl:with-param name="theAzimuth" select="EnteredData/AzimuthOne"/>
              <xsl:with-param name="northLbl">K</xsl:with-param>
              <xsl:with-param name="eastLbl">S</xsl:with-param>
              <xsl:with-param name="southLbl">G</xsl:with-param>
              <xsl:with-param name="westLbl">B</xsl:with-param>
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">
        <xsl:choose>
          <xsl:when test="EnteredData/AzimuthType = 'Sun'">Güneşten açı</xsl:when>
          <xsl:otherwise>Donülen açı</xsl:otherwise>
         </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val4">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="EnteredData/TurnedAngle"/>
        </xsl:call-template>
      </xsl:with-param>      
    </xsl:call-template>

  <!-- Add a second line with the dist and vertical offset values -->
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr2" select="$DistType"/>
      <xsl:with-param name="Val2" select="format-number(EnteredData/DistanceOne * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr3">Düşey ofset</xsl:with-param>
      <xsl:with-param name="Val3" select="format-number(EnteredData/VerticalOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>

  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- **************** Handle From a Baseline Output ***************** -->
<!-- **************************************************************** -->
<xsl:template name="FromABaseline">

  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Hesap detayları</xsl:with-param>
      <xsl:with-param name="Val1">Baz hattından</xsl:with-param>

      <xsl:with-param name="Hdr2">İlk nokta</xsl:with-param>
      <xsl:with-param name="Val2" select="EnteredData/PointOne"/>

      <xsl:with-param name="Hdr3">Son nokta</xsl:with-param>
      <xsl:with-param name="Val3" select="EnteredData/PointTwo"/>

      <xsl:with-param name="Hdr4">Mesafe</xsl:with-param>
      <xsl:with-param name="Val4" select="format-number(EnteredData/DistanceOne * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr5">Doğrultu</xsl:with-param>
      <xsl:with-param name="Val5">
        <xsl:if test="EnteredData/DirectionAlongLine[.='InFromStart']">Baştan</xsl:if>
        <xsl:if test="EnteredData/DirectionAlongLine[.='OutFromStart']">Baştan dışarıya</xsl:if>
        <xsl:if test="EnteredData/DirectionAlongLine[.='InFromEnd']">Sondan</xsl:if>
        <xsl:if test="EnteredData/DirectionAlongLine[.='OutFromEnd']">Sondan dışarıya</xsl:if>
      </xsl:with-param>
    </xsl:call-template>

    <!-- Add a second line with the offset value and distance type -->
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr2">Ofset</xsl:with-param>
      <xsl:with-param name="Val2" select="format-number(EnteredData/DistanceTwo * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr3">Kenarlar</xsl:with-param>
      <xsl:with-param name="Val3" select="EnteredData/DistanceType"/>
    </xsl:call-template>
    
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- *********** Handle Vertical Plane Intersection Output ********** -->
<!-- **************************************************************** -->
<xsl:template name="BearngVerticalPlaneIntersection">

  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Hesap detayları</xsl:with-param>
      <xsl:with-param name="Val1">Düşey düzlem ve açı</xsl:with-param>

      <xsl:with-param name="Hdr2">1. Nokta</xsl:with-param>
      <xsl:with-param name="Val2" select="EnteredData/PointOne"/>

      <xsl:with-param name="Hdr3">2. Nokta</xsl:with-param>
      <xsl:with-param name="Val3" select="EnteredData/PointTwo"/>

      <xsl:with-param name="Hdr4">YA</xsl:with-param>
      <xsl:with-param name="Val4">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="EnteredData/VerticalPlaneIntersectionRay/HorizontalCircle"/>
        </xsl:call-template>
      </xsl:with-param>      

      <xsl:with-param name="Hdr5">DA</xsl:with-param>
      <xsl:with-param name="Val5">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="EnteredData/VerticalPlaneIntersectionRay/VerticalCircle"/>
        </xsl:call-template>
      </xsl:with-param>      
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- *************** Features and Attributes Output ***************** -->
<!-- **************************************************************** -->
<xsl:template name="FeatureAndAttributes">
  <xsl:for-each select="Features/Feature">
    <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr"><xsl:text>Öznitelik</xsl:text><xsl:value-of select="concat(' (', ../../Name, ')')"/></xsl:with-param>
      <xsl:with-param name="Val" select="@Name"/>
    </xsl:call-template>

    <xsl:for-each select="Attribute">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr" select="Name"/>
        <xsl:with-param name="Val" select="Value"/>
      </xsl:call-template>
    </xsl:for-each>

    <xsl:call-template name="EndTable"/>
  </xsl:for-each>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************** Point/Line/Arc Descriptions Output ************** -->
<!-- **************************************************************** -->
<xsl:template name="OutputDescriptions">
  <xsl:param name="lineArc" select="'false'"/>
  
  <xsl:if test="Description1 or Description2">  <!-- One or other of the elements is present -->
    <xsl:choose>
      <xsl:when test="$lineArc = 'true'">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr" select="Description1/@Name"/>
          <xsl:with-param name="Val" select="Description1"/>
        </xsl:call-template>

        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr" select="Description2/@Name"/>
          <xsl:with-param name="Val" select="Description2"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="OutputTableLine">
          <xsl:with-param name="Hdr2" select="Description1/@Name"/>
          <xsl:with-param name="Val2" select="Description1"/>

          <xsl:with-param name="Hdr3" select="Description2/@Name"/>
          <xsl:with-param name="Val3" select="Description2"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:if>
</xsl:template>


<!-- **************************************************************** -->
<!-- ********************* Stakeout Data Output ********************* -->
<!-- **************************************************************** -->
<xsl:template name="Stakeout">
  <xsl:if test="Stakeout/PointDesign">
    <xsl:call-template name="PointDesign"/>
  </xsl:if>

  <xsl:if test="Stakeout/LineDesign">
    <xsl:call-template name="LineDesign"/>
  </xsl:if>

  <xsl:if test="Stakeout/ArcDesign">
    <xsl:call-template name="ArcDesign"/>
  </xsl:if>

  <xsl:if test="Stakeout/SlopeDesign">
    <xsl:call-template name="SlopeDesign"/>
  </xsl:if>

  <xsl:if test="Stakeout/DTMDesign">
    <xsl:call-template name="DTMDesign"/>
  </xsl:if>

  <xsl:if test="Stakeout/RoadDesign">
    <xsl:call-template name="RoadDesign"/>
  </xsl:if>

  <xsl:if test="Stakeout/GridDeltas">
    <xsl:call-template name="GridDeltas"/>
  </xsl:if>

  <xsl:if test="Stakeout/LinearDeltas">
    <xsl:call-template name="LinearDeltas"/>
  </xsl:if>

  <xsl:if test="Stakeout/DTMDeltas">
    <xsl:call-template name="DTMDeltas"/>
  </xsl:if>

  <xsl:if test="Stakeout/PolarDeltas">
    <xsl:call-template name="PolarDeltas"/>
  </xsl:if>

  <xsl:if test="Stakeout/CatchPoint">
    <xsl:call-template name="CatchPoint"/>
  </xsl:if>

  <xsl:if test="Stakeout/CatchPointTemplateReport">
    <xsl:call-template name="CatchPointTemplateRpt"/>
  </xsl:if>

  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Point Stakeout Data Output ****************** -->
<!-- **************************************************************** -->
<xsl:template name="PointDesign">
  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">
        <xsl:text>Nokta aplikasyonu</xsl:text>
        <xsl:value-of select="concat(' (', Name, ')')"/>
      </xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:text>Dizayn nokta: </xsl:text><xsl:value-of select="Stakeout/PointDesign/Name"/>
        <xsl:text>Kod: </xsl:text><xsl:value-of select="Stakeout/PointDesign/Code"/>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Metod</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="StakeoutMethodText">
          <xsl:with-param name="Method" select="Stakeout/PointDesign/StakeoutMethod"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* Line Stakeout Data Output ****************** -->
<!-- **************************************************************** -->
<xsl:template name="LineDesign">
  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">
        <xsl:text>Doğru aplikasyonu</xsl:text>
        <xsl:value-of select="concat(' (', Name, ')')"/>
      </xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:text>Doğru adı: </xsl:text>
        <xsl:value-of select="Stakeout/LineDesign/Name"/>
        <xsl:text> Kod: </xsl:text>
        <xsl:value-of select="Stakeout/LineDesign/Code"/>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Metod</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="StakeoutMethodText">
          <xsl:with-param name="Method" select="Stakeout/LineDesign/StakeoutMethod"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:if test="Stakeout/LineDesign/Station != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">
          <xsl:choose>
            <xsl:when test="$useChainageTerminology = 'true'">Chainage</xsl:when>
            <xsl:otherwise>İstasyon</xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormatStationVal">
            <xsl:with-param name="stationVal" select="Stakeout/LineDesign/Station"/>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>
    
    <xsl:if test="Stakeout/LineDesign/Offset != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Ofset</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(Stakeout/LineDesign/Offset * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Stakeout/LineDesign/Elevation != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr" select="$elevPrompt"/>
        <xsl:with-param name="Val" select="format-number(Stakeout/LineDesign/Elevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>
    
    <xsl:if test="Stakeout/LineDesign/VerticalOffset != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">D.Ofset</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(Stakeout/LineDesign/VerticalOffset * $ElevConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Stakeout/LineDesign/OriginalDesignElevation and (string(number(Stakeout/LineDesign/OriginalDesignElevation)) != 'NaN')">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Orijinal proje kotu</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(Stakeout/LineDesign/OriginalDesignElevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* Arc Stakeout Data Output ******************* -->
<!-- **************************************************************** -->
<xsl:template name="ArcDesign">
  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">
        <xsl:text>Yay aplikasyonu</xsl:text>
        <xsl:value-of select="concat(' (', Name, ')')"/>
      </xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:text>Yay adı: </xsl:text><xsl:value-of select="Stakeout/ArcDesign/Name"/>
        <xsl:text> Kod: </xsl:text><xsl:value-of select="Stakeout/ArcDesign/Code"/>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Metod</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="StakeoutMethodText">
          <xsl:with-param name="Method" select="Stakeout/ArcDesign/StakeoutMethod"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:if test="Stakeout/ArcDesign/Station != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">
          <xsl:choose>
            <xsl:when test="$useChainageTerminology = 'true'">Chainage</xsl:when>
            <xsl:otherwise>İstasyon</xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormatStationVal">
            <xsl:with-param name="stationVal" select="Stakeout/ArcDesign/Station"/>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Stakeout/ArcDesign/Offset != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Ofset</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(Stakeout/ArcDesign/Offset * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Stakeout/ArcDesign/Elevation != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr" select="$elevPrompt"/>
        <xsl:with-param name="Val" select="format-number(Stakeout/ArcDesign/Elevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>
    
    <xsl:if test="Stakeout/ArcDesign/VerticalOffset != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">D.Ofset</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(Stakeout/ArcDesign/VerticalOffset * $ElevConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Stakeout/ArcDesign/OriginalDesignElevation and (string(number(Stakeout/ArcDesign/OriginalDesignElevation)) != 'NaN')">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Orijinal proje kotu</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(Stakeout/ArcDesign/OriginalDesignElevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** Slope Stakeout Data Output ******************* -->
<!-- **************************************************************** -->
<xsl:template name="SlopeDesign">
  <xsl:if test="Stakeout/SlopeDesign/SlopeLeft">
    <xsl:call-template name="StartTable"/>
      <caption align="top">
        <p align="left">
        <xsl:text>Aplikasyon - Sola eğim: </xsl:text>
        <xsl:call-template name="SlopeMethodText">
          <xsl:with-param name="Method" select="Stakeout/SlopeDesign/SlopeLeft/Type"/>
        </xsl:call-template>
        </p>
      </caption>

      <xsl:call-template name="OutputTableLine">
        <xsl:with-param name="Hdr1">Eğim</xsl:with-param>

        <xsl:with-param name="Hdr2">YM</xsl:with-param>
        <xsl:with-param name="Val2" select="format-number(Stakeout/SlopeDesign/SlopeLeft/HorizontalDistance  * $DistConvFactor, $DecPl3, 'Standard')"/>

        <xsl:with-param name="Hdr3">K.Frk</xsl:with-param>
        <xsl:with-param name="Val3" select="format-number(Stakeout/SlopeDesign/SlopeLeft/VerticalDistance  * $DistConvFactor, $DecPl3, 'Standard')"/>

        <xsl:with-param name="Hdr4">Eğik mes</xsl:with-param>
        <xsl:with-param name="Val4" select="format-number(Stakeout/SlopeDesign/SlopeLeft/SlopeDistance  * $DistConvFactor, $DecPl3, 'Standard')"/>

        <xsl:with-param name="Hdr5">Eğim</xsl:with-param>
        <xsl:with-param name="Val5" select="concat(format-number(Stakeout/SlopeDesign/SlopeLeft/Grade, $DecPl2, 'Standard'), '%')"/>
      </xsl:call-template>
    <xsl:call-template name="EndTable"/>
  </xsl:if>

  <xsl:if test="Stakeout/SlopeDesign/SlopeRight">
    <xsl:call-template name="StartTable"/>
      <caption align="top">
        <p align="left">
        <xsl:text>Aplikasyon - Sağa eğim: </xsl:text>
        <xsl:call-template name="SlopeMethodText">
          <xsl:with-param name="Method" select="Stakeout/SlopeDesign/SlopeRight/Type"/>
        </xsl:call-template>
        </p>
      </caption>

      <xsl:call-template name="OutputTableLine">
        <xsl:with-param name="Hdr1">Eğim</xsl:with-param>

        <xsl:with-param name="Hdr2">YM</xsl:with-param>
        <xsl:with-param name="Val2" select="format-number(Stakeout/SlopeDesign/SlopeRight/HorizontalDistance  * $DistConvFactor, $DecPl3, 'Standard')"/>

        <xsl:with-param name="Hdr3">K.Frk</xsl:with-param>
        <xsl:with-param name="Val3" select="format-number(Stakeout/SlopeDesign/SlopeRight/VerticalDistance  * $DistConvFactor, $DecPl3, 'Standard')"/>

        <xsl:with-param name="Hdr4">Eğik mes</xsl:with-param>
        <xsl:with-param name="Val4" select="format-number(Stakeout/SlopeDesign/SlopeRight/SlopeDistance  * $DistConvFactor, $DecPl3, 'Standard')"/>

        <xsl:with-param name="Hdr5">Eğim</xsl:with-param>
        <xsl:with-param name="Val5" select="concat(format-number(Stakeout/SlopeDesign/SlopeRight/Grade, $DecPl2, 'Standard'), '%')"/>
      </xsl:call-template>
    <xsl:call-template name="EndTable"/>
  </xsl:if>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* DTM Stakeout Data Output ******************* -->
<!-- **************************************************************** -->
<xsl:template name="DTMDesign">
  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">
        <xsl:text>SAM aplikasyonu</xsl:text><xsl:value-of select="concat(' (', Name, ')')"/>
      </xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:text>Yüzey: </xsl:text><xsl:value-of select="Stakeout/DTMDesign/Name"/>
        <xsl:text> Düşey ofset: </xsl:text><xsl:value-of select="format-number(Stakeout/DTMDesign/VerticalOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
    </xsl:call-template>

  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- *************** Road Design Stakeout Data Output *************** -->
<!-- **************************************************************** -->
<xsl:template name="RoadDesign">
  <xsl:call-template name="StartTable"/>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">
        <xsl:choose>
          <xsl:when test="$useRailTerminology = 'true'">Demiryolu aplikasyonu</xsl:when>
          <xsl:otherwise>Yol aplikasyonu</xsl:otherwise>
        </xsl:choose>
        <xsl:value-of select="concat(' (', Name, ')')"/>
      </xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:choose>
          <xsl:when test="$useRailTerminology = 'true'">Demiryolu adı: </xsl:when>
          <xsl:otherwise>Yol adı: </xsl:otherwise>
        </xsl:choose>
        <xsl:value-of select="Stakeout/RoadDesign/Name"/>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Dizayn kodu</xsl:with-param>
      <xsl:with-param name="Val" select="Stakeout/RoadDesign/Code"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Metod</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="StakeoutMethodText">
          <xsl:with-param name="Method" select="Stakeout/RoadDesign/StakeoutMethod"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:if test="Stakeout/RoadDesign/Station != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">
          <xsl:choose>
            <xsl:when test="$useChainageTerminology = 'true'">Chainage</xsl:when>
            <xsl:otherwise>İstasyon</xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:choose>
            <xsl:when test="Stakeout/RoadDesign/EquatedStation"> 
              <xsl:call-template name="FormatStationVal">
                <xsl:with-param name="stationVal" select="Stakeout/RoadDesign/EquatedStation/Station"/>
                <xsl:with-param name="zoneVal" select="Stakeout/RoadDesign/EquatedStation/Zone"/>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <xsl:call-template name="FormatStationVal">
                <xsl:with-param name="stationVal" select="Stakeout/RoadDesign/Station"/>
              </xsl:call-template>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>
    
    <xsl:if test="Stakeout/RoadDesign/Offset != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Ofset</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(Stakeout/RoadDesign/Offset * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Stakeout/RoadDesign/Elevation != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Proje kotu</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(Stakeout/RoadDesign/Elevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>
    
    <xsl:if test="Stakeout/RoadDesign/HorizontalConstructionOffset and 
                  Stakeout/RoadDesign/HorizontalConstructionOffset != 0 and
                  Stakeout/RoadDesign/HorizontalConstructionOffset != ''">
      <xsl:variable name="offsetAppliedAs">
        <xsl:choose>
          <xsl:when test="Stakeout/RoadDesign/HorizontalConstructionOffsetApplied = 'Horizontal'">Yatay</xsl:when>
          <xsl:otherwise>Eğim</xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">İnşaat Yat.Ofset</xsl:with-param>
        <xsl:with-param name="Val" select="concat(format-number(Stakeout/RoadDesign/HorizontalConstructionOffset * $DistConvFactor, $DecPl3, 'Standard'),
                                                  ' (', $offsetAppliedAs, ')')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Stakeout/RoadDesign/VerticalConstructionOffset and 
                  Stakeout/RoadDesign/VerticalConstructionOffset != 0 and
                  Stakeout/RoadDesign/VerticalConstructionOffset != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">İnşaat D.Ofset</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(Stakeout/RoadDesign/VerticalConstructionOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Stakeout/RoadDesign/StationConstructionOffset and 
                  Stakeout/RoadDesign/StationConstructionOffset != 0 and
                  Stakeout/RoadDesign/StationConstructionOffset != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">
          <xsl:choose>
            <xsl:when test="$useChainageTerminology = 'true'">Construction chainage offset</xsl:when>
            <xsl:otherwise>Proje istasyon ofseti</xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
        <xsl:with-param name="Val" select="format-number(Stakeout/RoadDesign/StationConstructionOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>
    
    <xsl:if test="Stakeout/RoadDesign/StationClass != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">
          <xsl:choose>
            <xsl:when test="$useChainageTerminology = 'true'">Chainage class</xsl:when>
            <xsl:otherwise>İstasyon tipi</xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="StationClassString">
            <xsl:with-param name="ClassStr" select="Stakeout/RoadDesign/StationClass"/>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Stakeout/RoadDesign/SideSlopeGrade and 
                  Stakeout/RoadDesign/SideSlopeGrade != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Proje yan eğimi</xsl:with-param>
        <xsl:with-param name="Val" select="concat(format-number(Stakeout/RoadDesign/SideSlopeGrade, $DecPl2, 'Standard'), '%')"/>
      </xsl:call-template>
    </xsl:if>
    
    <xsl:if test="Stakeout/RoadDesign/DitchOffset and 
                  Stakeout/RoadDesign/DitchOffset != 0 and
                  Stakeout/RoadDesign/DitchOffset != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Hendek yarma genişliği</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(Stakeout/RoadDesign/DitchOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>
    
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** Stakeout Grid Deltas Output ****************** -->
<!-- **************************************************************** -->
<xsl:template name="GridDeltas">
  <xsl:if test="Stakeout/GridDeltas/DeltaNorth != '' or
                Stakeout/GridDeltas/DeltaEast != '' or 
                Stakeout/GridDeltas/DeltaElevation != ''">
    <xsl:call-template name="StartTable"/>

      <xsl:call-template name="OutputTableLine">
        <xsl:with-param name="Hdr1">Aplikasyon</xsl:with-param>
        <xsl:with-param name="Val1">Deltalar: Grid</xsl:with-param>

        <xsl:with-param name="Hdr2">
          <xsl:choose>
            <xsl:when test="$NECoords = 'true'"><xsl:value-of select="$dNorthPrompt"/></xsl:when>
            <xsl:otherwise><xsl:value-of select="$dEastPrompt"/></xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
        <xsl:with-param name="Val2">
          <xsl:choose>
            <xsl:when test="$NECoords = 'true'">
              <xsl:value-of select="format-number(Stakeout/GridDeltas/DeltaNorth * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="format-number(Stakeout/GridDeltas/DeltaEast * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>

        <xsl:with-param name="Hdr3">
          <xsl:choose>
            <xsl:when test="$NECoords = 'true'"><xsl:value-of select="$dEastPrompt"/></xsl:when>
            <xsl:otherwise><xsl:value-of select="$dNorthPrompt"/></xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
        <xsl:with-param name="Val3">
          <xsl:choose>
            <xsl:when test="$NECoords = 'true'">
              <xsl:value-of select="format-number(Stakeout/GridDeltas/DeltaEast * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="format-number(Stakeout/GridDeltas/DeltaNorth * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>

        <xsl:with-param name="Hdr4" select="$dElevPrompt"/>
        <xsl:with-param name="Val4" select="format-number(Stakeout/GridDeltas/DeltaElevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    <xsl:call-template name="EndTable"/>
  </xsl:if>
</xsl:template>


<!-- **************************************************************** -->
<!-- **************** Stakeout Linear Deltas Output ***************** -->
<!-- **************************************************************** -->
<xsl:template name="LinearDeltas">
  <xsl:if test="Stakeout/LinearDeltas/DeltaStation != '' or
                Stakeout/LinearDeltas/DeltaOffset != '' or 
                Stakeout/LinearDeltas/DeltaElevation != ''">
    <xsl:call-template name="StartTable"/>

      <xsl:call-template name="OutputTableLine">
        <xsl:with-param name="Hdr1">Aplikasyon</xsl:with-param>
        <xsl:with-param name="Val1">Deltalar: Doğrusal</xsl:with-param>

        <xsl:with-param name="Hdr2">
          <xsl:choose>
            <xsl:when test="$useChainageTerminology = 'true'">Δ Chainage</xsl:when>
            <xsl:otherwise>Δ İstasyon</xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
        <xsl:with-param name="Val2" select="format-number(Stakeout/LinearDeltas/DeltaStation * $DistConvFactor, $DecPl3, 'Standard')"/>

        <xsl:with-param name="Hdr3">ΔOfset</xsl:with-param>
        <xsl:with-param name="Val3" select="format-number(Stakeout/LinearDeltas/DeltaOffset * $DistConvFactor, $DecPl3, 'Standard')"/>

        <xsl:with-param name="Hdr4" select="$dElevPrompt"/>
        <xsl:with-param name="Val4" select="format-number(Stakeout/LinearDeltas/DeltaElevation * $ElevConvFactor, $DecPl3, 'Standard')"/>

        <xsl:with-param name="Hdr5">
          <xsl:if test="Stakeout/LinearDeltas/GradeToLine != ''">Doğru'ya eğim</xsl:if>
        </xsl:with-param>
        <xsl:with-param name="Val5">
          <xsl:if test="Stakeout/LinearDeltas/GradeToLine != ''">
            <xsl:value-of select="concat(format-number(Stakeout/LinearDeltas/GradeToLine, $DecPl2, 'Standard'), '%')"/>
          </xsl:if>
        </xsl:with-param>
      </xsl:call-template>
    <xsl:call-template name="EndTable"/>
  </xsl:if>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** Stakeout Polar Deltas Output ***************** -->
<!-- **************************************************************** -->
<xsl:template name="PolarDeltas">
  <xsl:if test="Stakeout/PolarDeltas/Azimuth != '' or
                Stakeout/PolarDeltas/HorizontalDistance != '' or 
                Stakeout/PolarDeltas/VerticalDistance != ''">
    <xsl:call-template name="StartTable"/>

      <xsl:call-template name="OutputTableLine">
        <xsl:with-param name="Hdr1">Aplikasyon</xsl:with-param>
        <xsl:with-param name="Val1">Deltalar: Polar</xsl:with-param>

        <xsl:with-param name="Hdr2">Semt A.</xsl:with-param>
        <xsl:with-param name="Val2">
          <xsl:call-template name="FormatAzimuth">
            <xsl:with-param name="theAzimuth" select="Stakeout/PolarDeltas/Azimuth"/>
            <xsl:with-param name="northLbl">K</xsl:with-param>
            <xsl:with-param name="eastLbl">S</xsl:with-param>
            <xsl:with-param name="southLbl">G</xsl:with-param>
            <xsl:with-param name="westLbl">B</xsl:with-param>
          </xsl:call-template>
        </xsl:with-param>
        
        <xsl:with-param name="Hdr3">YM</xsl:with-param>
        <xsl:with-param name="Val3" select="format-number(Stakeout/PolarDeltas/HorizontalDistance * $DistConvFactor, $DecPl3, 'Standard')"/>

        <xsl:with-param name="Hdr4">K.Frk</xsl:with-param>
        <xsl:with-param name="Val4" select="format-number(Stakeout/PolarDeltas/VerticalDistance * $DistConvFactor, $DecPl3, 'Standard')"/>

      </xsl:call-template>
    <xsl:call-template name="EndTable"/>
  </xsl:if>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** Stakeout Catch Point Output ****************** -->
<!-- **************************************************************** -->
<xsl:template name="CatchPoint">
  <xsl:call-template name="StartTable"/>

    <xsl:variable name="catchPtLbl"/>
    <xsl:choose>
      <xsl:when test="Stakeout/CatchPoint/VerticalDistanceToHingePoint &gt; 0">Şev Kazığı (Dolgu)</xsl:when>
      <xsl:otherwise>Şev kazığı (Yarma)</xsl:otherwise>
    </xsl:choose>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1" select="$catchPtLbl"/>

      <xsl:with-param name="Hdr2">Ofset</xsl:with-param>
      <xsl:with-param name="Val2" select="format-number(Stakeout/CatchPoint/Offset * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr3" select="$elevPrompt"/>
      <xsl:with-param name="Val3" select="format-number(Stakeout/CatchPoint/Elevation * $ElevConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr4">Eklem noktasina Y.Mes</xsl:with-param>
      <xsl:with-param name="Val4" select="format-number(Stakeout/CatchPoint/HorizontalDistanceToHingePoint * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr5">
        <xsl:choose>
          <xsl:when test="$useRailTerminology = 'true'">Dayanak noktasına kaldır</xsl:when>
          <xsl:otherwise>Eklem noktasına D.Mes</xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val5" select="format-number(Stakeout/CatchPoint/VerticalDistanceToHingePoint * $DistConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr2">Eğim</xsl:with-param>
      <xsl:with-param name="Val2" select="concat(format-number(Stakeout/CatchPoint/AsStakedSideSlopeGrade, $DecPl2, 'Standard'), '%')"/>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************** Catch Point Template Report Output ************** -->
<!-- **************************************************************** -->
<xsl:template name="CatchPointTemplateRpt">
  <xsl:call-template name="StartTable"/>
    <xsl:for-each select="Stakeout/CatchPointTemplateReport">
      <xsl:call-template name="OutputTableLine">
        <xsl:with-param name="Hdr1">Şev kazığı</xsl:with-param>

        <xsl:with-param name="Hdr2">Noktaya</xsl:with-param>
        <xsl:with-param name="Val2" select="Code"/>

        <xsl:with-param name="Hdr3">YM</xsl:with-param>
        <xsl:with-param name="Val3" select="format-number(HorizontalDistance * $DistConvFactor, $DecPl3, 'Standard')"/>

        <xsl:with-param name="Hdr4">K.Frk</xsl:with-param>
        <xsl:with-param name="Val4" select="format-number(DeltaElevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:for-each>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** DTM Stakeout Deltas Output ****************** -->
<!-- **************************************************************** -->
<xsl:template name="DTMDeltas">
  <xsl:call-template name="StartTable"/>
      <xsl:call-template name="OutputTableLine">
        <xsl:with-param name="Hdr1">Aplikasyon</xsl:with-param>
        <xsl:with-param name="Val1">SAM</xsl:with-param>

        <xsl:with-param name="Hdr2" select="$dElevPrompt"/>
        <xsl:with-param name="Val2">
          <xsl:choose>
            <xsl:when test="$schemaVersion &gt;= 5.2">
              <xsl:value-of select="format-number(Stakeout/DTMDeltas/DeltaElevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="format-number(Stakeout/DTMDeltas/DeltaElevation * -1 * $ElevConvFactor, $DecPl3, 'Standard')"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
    </xsl:call-template>

  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** Stakeout Method Text Output ****************** -->
<!-- **************************************************************** -->
<xsl:template name="StakeoutMethodText">
  <xsl:param name="Method"/>
  
  <xsl:choose>
    <xsl:when test="$Method = 'ToThePoint'">Nokta'ya</xsl:when>
    <xsl:when test="$Method = 'FromAPoint'">Sabit noktadan</xsl:when>
    <xsl:when test="$Method = 'FromStartPosition'">Başlangıç konumundan</xsl:when>
    <xsl:when test="$Method = 'FromLastPointStaked'">Aplike edilen son noktadan</xsl:when>
    <xsl:when test="$Method = 'ToTheLine'">Doğru'ya</xsl:when>
    <xsl:when test="$Method = 'ToTheArc'">Yay'a</xsl:when>
    <xsl:when test="$Method = 'PointOffsetFromLine'">
      <xsl:choose>
        <xsl:when test="$useChainageTerminology = 'true'">Chainage/offset from line</xsl:when>
        <xsl:otherwise>Doğru'dan istasyon/ofset</xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:when test="$Method = 'PointOffsetFromArc'">
      <xsl:choose>
        <xsl:when test="$useChainageTerminology = 'true'">Chainage/offset from arc</xsl:when>
        <xsl:otherwise>Yay'dan istasyon/ofset</xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:when test="$Method = 'OffsetLine'">Doğru ofset</xsl:when>
    <xsl:when test="$Method = 'OffsetArc'">Yay ofseti</xsl:when>
    <xsl:when test="$Method = 'PointOnLine'">Doğru'ya</xsl:when>
    <xsl:when test="$Method = 'PointOnArc'">Yay'a</xsl:when>
    <xsl:when test="$Method = 'IntersectionPointOfArc'">Yay kesişim noktası</xsl:when>
    <xsl:when test="$Method = 'CentrePointOfArc'">Yay merkez noktası</xsl:when>
    <xsl:when test="$Method = 'SlopeFromLine'">Doğru'dan eğim</xsl:when>
    <xsl:when test="$Method = 'SlopeFromArc'">Yay'dan eğim</xsl:when>
    <xsl:when test="$Method = 'StationAndOffset'">
      <xsl:choose>
        <xsl:when test="$useChainageTerminology = 'true'">Chainage and offset</xsl:when>
        <xsl:otherwise>İstasyon ve ofset</xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:when test="$Method = 'PositionOnRoad'">
      <xsl:choose>
        <xsl:when test="$useRailTerminology = 'true'">Demiryolundaki konum</xsl:when>
        <xsl:otherwise>Yoldaki konum</xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:when test="$Method = 'SideSlopeFromAlignment'">Eksenden yan eğim</xsl:when>
    <xsl:when test="$Method = 'StationOnString'">
      <xsl:choose>
        <xsl:when test="$useChainageTerminology = 'true'">Chainage on string</xsl:when>
        <xsl:otherwise>Dizi üzerinde istasyon</xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:when test="$Method = 'ToTheDTM'">SAM aplikasyonu</xsl:when>
    <xsl:otherwise>Bilinmeyen</xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* Line Method Text Output ******************** -->
<!-- **************************************************************** -->
<xsl:template name="LineMethodText">
  <xsl:param name="Method"/>
  
  <xsl:choose>
    <xsl:when test="$Method = 'TwoPoints'">İki nokta</xsl:when>
    <xsl:when test="$Method = 'BearingAndDistance'">Doğrultu ve mesafe</xsl:when>
    <xsl:otherwise>Bilinmeyen</xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************** Arc Method Text Output ******************** -->
<!-- **************************************************************** -->
<xsl:template name="ArcMethodText">
  <xsl:param name="Method"/>
  
  <xsl:choose>
    <xsl:when test="$Method = 'TwoPointsAndRadius'">İki nokta ve yarıçap</xsl:when>
    <xsl:when test="$Method = 'ArcLengthAndRadius'">Yay boyu ve yarıçapı</xsl:when>
    <xsl:when test="$Method = 'DeltaAngleAndRadius'">Delta açısı ve yarıçap</xsl:when>
    <xsl:when test="$Method = 'IntersectionPointAndTangents'">Kesişen nokta ve teğetler</xsl:when>
    <xsl:otherwise>Bilinmeyen</xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* Slope Method Text Output ******************* -->
<!-- **************************************************************** -->
<xsl:template name="SlopeMethodText">
  <xsl:param name="Method"/>
  
  <xsl:choose>
    <xsl:when test="$Method = 'HorizontalAndVerticalDistance'">Yat. ve Düş. mes.</xsl:when>
    <xsl:when test="$Method = 'GradeAndSlopeDistance'">Eğim ve eğik mes.</xsl:when>
    <xsl:when test="$Method = 'GradeAndHorizontalDistance'">Eğim ve yat. mes.</xsl:when>
    <xsl:otherwise>Bilinmeyen</xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Station Class Text Output ******************* -->
<!-- **************************************************************** -->
<xsl:template name="StationClassText">
  <xsl:param name="Class"/>
  
  <xsl:choose>
    <xsl:when test="$Class = 'StraightToSpiral'">(TS)</xsl:when>
    <xsl:when test="$Class = 'SpiralToArc'">(SC)</xsl:when>
    <xsl:when test="$Class = 'ArcToSpiral'">(CS)</xsl:when>
    <xsl:when test="$Class = 'SpiralToStraight'">(ST)</xsl:when>
    <xsl:when test="$Class = 'SpiralToSpiral'">(SS)</xsl:when>
    <xsl:when test="$Class = 'StraightToArc'">(PC)</xsl:when>
    <xsl:when test="$Class = 'ArcToStraight'">(PT)</xsl:when>
    <xsl:when test="$Class = 'IntersectionPoint'">(PI)</xsl:when>
    <xsl:when test="$Class = 'CrossSection'">(XS)</xsl:when>
    <xsl:when test="$Class = 'VerticalCurveStart'">(VCS)</xsl:when>
    <xsl:when test="$Class = 'VerticalCurveEnd'">(VCE)</xsl:when>
    <xsl:when test="$Class = 'VerticalPoint'">(VPI)</xsl:when>
    <xsl:when test="$Class = 'RoadStart'">(RS)</xsl:when>
    <xsl:when test="$Class = 'RoadEnd'">(RE)</xsl:when>
    <xsl:when test="$Class = 'TemplateAssignment'">(T)</xsl:when>
    <xsl:when test="$Class = 'SuperelevationStart'">(SES)</xsl:when>
    <xsl:when test="$Class = 'WideningStart'">(WS)</xsl:when>
    <xsl:when test="$Class = 'WideningEnd'">(WE)</xsl:when>
    <xsl:when test="$Class = 'SuperelevationEnd'">(SEE)</xsl:when>
    <xsl:when test="$Class = 'WideningMaxium'">(WM)</xsl:when>
    <xsl:when test="$Class = 'WideningMaximum'">(WM)</xsl:when>
    <xsl:when test="$Class = 'SuperelevationMaximum'">(SEM)</xsl:when>
    <xsl:when test="$Class = 'VerticalSagPoint'">(LO)</xsl:when>
    <xsl:when test="$Class = 'VerticalSummitPoint'">(HI)</xsl:when>
    <xsl:when test="$Class = 'SuperelevationEqual'">(SEQ)</xsl:when>
    <xsl:when test="$Class = 'SuperelevationInterest'">(SE)</xsl:when>
    <xsl:when test="$Class = 'StationEquation'">
      <xsl:choose>
        <xsl:when test="$useChainageTerminology = 'true'">(CHEQ)</xsl:when>
        <xsl:otherwise>(STEQ)</xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>Bilinmeyen</xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Station Class Text Output ******************* -->
<!-- **************************************************************** -->
<xsl:template name="StationClassString">
  <xsl:param name="ClassStr"/>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'StraightToSpiral'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'SpiralToArc'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'ArcToSpiral'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'SpiralToStraight'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'SpiralToSpiral'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'StraightToArc'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'ArcToStraight'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'IntersectionPoint'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'CrossSection'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'VerticalCurveStart'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'VerticalCurveEnd'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'VerticalPoint'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'RoadStart'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'RoadEnd'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'TemplateAssignment'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'SuperelevationStart'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'WideningStart'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'WideningEnd'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'SuperelevationEnd'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'WideningMaxium'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'WideningMaximum'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'SuperelevationMaximum'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'VerticalSagPoint'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'VerticalSummitPoint'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'SuperelevationEqual'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'SuperelevationInterest'"/>
  </xsl:call-template>

  <xsl:call-template name="OutputStationClassItem">
    <xsl:with-param name="FullString" select="$ClassStr"/>
    <xsl:with-param name="ItemString" select="'StationEquation'"/>
  </xsl:call-template>

</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Output Station Class Item ******************* -->
<!-- **************************************************************** -->
<xsl:template name="OutputStationClassItem">
  <xsl:param name="FullString"/>
  <xsl:param name="ItemString"/>

  <xsl:if test="contains($FullString, $ItemString)">
    <xsl:if test="not(starts-with($FullString, $ItemString))">
      <xsl:value-of select="', '"/>
    </xsl:if>
    <xsl:call-template name="StationClassText">
      <xsl:with-param name="Class" select="$ItemString"/>
    </xsl:call-template>
  </xsl:if>
  
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** GPSEquipmentRecord Output ******************* -->
<!-- **************************************************************** -->
<xsl:template match="GPSEquipmentRecord">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">GNSS alıcısı</p></caption>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Alıcı tipi</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:choose>
          <xsl:when test="ReceiverType = ''">Bilinmeyen</xsl:when>
          <xsl:otherwise><xsl:value-of select="ReceiverType"/></xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Seri No</xsl:with-param>
      <xsl:with-param name="Val" select="ReceiverSerialNumber"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Firmware sürümü</xsl:with-param>
      <xsl:with-param name="Val" select="ReceiverFirmwareVersion"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Anten tipi</xsl:with-param>
      <xsl:with-param name="Val" select="AntennaType"/>
    </xsl:call-template>

    <xsl:if test="AntennaSerialNumber != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Anten seri numarası</xsl:with-param>
        <xsl:with-param name="Val" select="AntennaSerialNumber"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Ölçme metodu</xsl:with-param>
      <xsl:with-param name="Val" select="AntennaMeasurementMethod"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Şerit metre ayarı</xsl:with-param>
      <xsl:with-param name="Val" select="format-number(AntennaTapeAdjustment * $DistConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Yatay ofset</xsl:with-param>
      <xsl:with-param name="Val" select="format-number(AntennaHorizontalOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Düşey ofset</xsl:with-param>
      <xsl:with-param name="Val" select="format-number(AntennaVerticalOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>

  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- **************** CalibrationPointRecord Output ***************** -->
<!-- **************************************************************** -->
<xsl:template match="CalibrationPointRecord">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Kalibrasyon noktası</p></caption>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Grid</xsl:with-param>
      <xsl:with-param name="Val1" select="GridPointName"/>

      <xsl:with-param name="Hdr2">WGS84</xsl:with-param>
      <xsl:with-param name="Val2" select="WGS84PointName"/>

      <xsl:with-param name="Hdr3">Boyutlar</xsl:with-param>
      <xsl:with-param name="Val3" select="Dimension"/>

      <xsl:with-param name="Hdr4">Y.Fark</xsl:with-param>
      <xsl:with-param name="Val4" select="format-number(HorizontalResidual * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr5">D.Fark</xsl:with-param>
      <xsl:with-param name="Val5" select="format-number(VerticalResidual * $DistConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- *************** BaseSurveyOptionsRecord Output ***************** -->
<!-- **************************************************************** -->
<xsl:template match="BaseSurveyOptionsRecord">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Baz seçenekleri</p></caption>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Tepe açısı</xsl:with-param>
      <xsl:with-param name="Val1" select="ElevationMask"/>

      <xsl:with-param name="Hdr2">PDOP sınırı</xsl:with-param>
      <xsl:with-param name="Val2" select="PDOPMask"/>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************** RoverSurveyOptionsRecord Output ***************** -->
<!-- **************************************************************** -->
<xsl:template match="RoverSurveyOptionsRecord">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Gezici seçenekleri</p></caption>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Tepe açısı</xsl:with-param>
      <xsl:with-param name="Val1" select="ElevationMask"/>

      <xsl:with-param name="Hdr2">PDOP sınırı</xsl:with-param>
      <xsl:with-param name="Val2" select="PDOPMask"/>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** SurveyEventRecord Output ********************* -->
<!-- **************************************************************** -->
<xsl:template match="SurveyEventRecord">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Ölçü aşaması</p></caption>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Ölçü aşaması</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="SurveyEventText">
          <xsl:with-param name="Event" select="Event"/>
        </xsl:call-template>
      </xsl:with-param> 
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* Survey Event Text Output ******************* -->
<!-- **************************************************************** -->
<xsl:template name="SurveyEventText">
  <xsl:param name="Event"/>
  
  <xsl:choose>
    <xsl:when test="$Event = 'StartBaseSurvey'">Baz başlatıldı</xsl:when>
    <xsl:when test="$Event = 'StartRoverSurvey'">Gezici başlatıldı</xsl:when>
    <xsl:when test="$Event = 'AbortSurvey'">Ölçü iptal ediliyor</xsl:when>
    <xsl:when test="$Event = 'EndSurvey'">Ölçü sonu</xsl:when>
    <xsl:when test="$Event = 'BaseStarted'">Baz başlatıldı</xsl:when>
    <xsl:when test="$Event = 'ReceiverModeSetError'">Alıcı modu ayar hatası</xsl:when>
    <xsl:when test="$Event = 'CommunicationsError'">İletişim hatası</xsl:when>
    <xsl:when test="$Event = 'InfillSystemAdopted'">Infill başlatıldı</xsl:when>
    <xsl:when test="$Event = 'RealtimeSystemAdopted'">Infill durduruldu</xsl:when>
    <xsl:when test="$Event = 'StartContinuous'">Sürekli detay (Başla)</xsl:when>
    <xsl:when test="$Event = 'EndContinuous'">Sürekli detay (Bitir)</xsl:when>
    <xsl:otherwise>Bilinmeyen</xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* ReferenceRecord Output ********************* -->
<!-- **************************************************************** -->
<xsl:template match="ReferenceRecord">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Baz noktası</p></caption>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Nokta</xsl:with-param>
      <xsl:with-param name="Val1" select="PointName"/>

      <xsl:with-param name="Hdr2">Anten yüksekliği</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:for-each select="key('antID-search', AntennaID)[1]">
          <xsl:value-of select="format-number(MeasuredHeight * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:for-each>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">Tip</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:for-each select="key('antID-search', AntennaID)[1]">
          <xsl:choose>
            <xsl:when test="MeasurementType = 'Corrected'">Düzeltilmiş</xsl:when>
            <xsl:otherwise>Düzeltmesiz</xsl:otherwise>
          </xsl:choose>
        </xsl:for-each>
      </xsl:with-param>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* PostProcessRecord Output ******************* -->
<!-- **************************************************************** -->
<xsl:template match="PostProcessRecord">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Postproses dosyası</p></caption>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Dosya adı</xsl:with-param>
      <xsl:with-param name="Val1" select="FileName"/>

      <xsl:with-param name="Hdr2">Başlatıldı</xsl:with-param>

      <xsl:with-param name="Hdr3">GPS haftası</xsl:with-param>
      <xsl:with-param name="Val3" select="StartTime/GPSWeek"/>

      <xsl:with-param name="Hdr4">Saniye</xsl:with-param>
      <xsl:with-param name="Val4" select="StartTime/Seconds"/>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** InitialisationRecord Output ****************** -->
<!-- **************************************************************** -->
<xsl:template match="InitialisationRecord">
  <xsl:call-template name="StartTable"/>
    <caption align="top">
      <p align="left">
      <xsl:text>Init durumu: </xsl:text>
      <xsl:call-template name="InitialisationEventText">
        <xsl:with-param name="Event" select="InitialisationEvent"/>
      </xsl:call-template>
      </p>
    </caption>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">GPS haftası</xsl:with-param>
      <xsl:with-param name="Val1" select="Time/GPSWeek"/>

      <xsl:with-param name="Hdr2">Saniye</xsl:with-param>
      <xsl:with-param name="Val2" select="Time/Seconds"/>

      <xsl:with-param name="Hdr3">Init tipi</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:call-template name="InitialisationTypeText">
          <xsl:with-param name="Type" select="InitialisationType"/>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">Ölçü tipi</xsl:with-param>
      <xsl:with-param name="Val4">
        <xsl:choose>
          <xsl:when test="SurveyType = 'RealTime'">Real-time</xsl:when>
          <xsl:when test="SurveyType = 'PostProcess'">Postproses</xsl:when>
          <xsl:otherwise>Infill</xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr5">Init sayımı</xsl:with-param>
      <xsl:with-param name="Val5" select="InitialisationCounter"/>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- *************** Initialisation Event Text Output *************** -->
<!-- **************************************************************** -->
<xsl:template name="InitialisationEventText">
  <xsl:param name="Event"/>
  
  <xsl:choose>
    <xsl:when test="$Event = 'GainedInitialisation'">Sağlandı</xsl:when>
    <xsl:when test="$Event = 'LostInitialisation'">Kayıp</xsl:when>
    <xsl:when test="$Event = 'FailedInitialisation'">Başarısız</xsl:when>
    <xsl:when test="$Event = 'BadInitialisation'">Başarısız</xsl:when>
    <xsl:when test="$Event = 'HighRMS'">Yüksek RMS</xsl:when>
    <xsl:when test="$Event = 'GoodRMS'">İyi RMS</xsl:when>
    <xsl:when test="$Event = 'UserCancelled'">Kullanıcı iptal etti</xsl:when>
    <xsl:otherwise>Bilinmeyen</xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- *************** Initialisation Type Text Output **************** -->
<!-- **************************************************************** -->
<xsl:template name="InitialisationTypeText">
  <xsl:param name="Type"/>
  
  <xsl:choose>
    <xsl:when test="$Type = 'Plate'">Plaka</xsl:when>
    <xsl:when test="$Type = 'KnownPoint'">Bilinen nokta</xsl:when>
    <xsl:when test="$Type = 'NewPoint'">Yeni nokta</xsl:when>
    <xsl:when test="$Type = 'OnTheFly'">Hareket halinde</xsl:when>
    <xsl:when test="$Type = 'Null'">Sıfır</xsl:when>
    <xsl:otherwise>Bilinmeyen</xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** AtmosphereRecord Output ********************* -->
<!-- **************************************************************** -->
<xsl:template match="AtmosphereRecord">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Atmosfer</p></caption>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Basınç</xsl:with-param>
      <xsl:with-param name="Val1">
        <xsl:variable name="Press" select="Pressure" />
        <xsl:choose>
          <xsl:when test="string(number($Press))='NaN'"><xsl:value-of select="string('?')"/></xsl:when> <!-- could use &#160; for space -->
          <xsl:otherwise>
            <xsl:variable name="PUnit">
              <xsl:choose>
                <xsl:when test="$PressUnit='mmHg'">mmHg</xsl:when>
                <xsl:when test="$PressUnit='InchHg'">inHg</xsl:when>
                <xsl:otherwise>mbar</xsl:otherwise>
              </xsl:choose>
            </xsl:variable>
          <xsl:value-of select="concat(format-number($Press * $PressConvFactor, $DecPl2, 'Standard'), $PUnit)"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr2">Sıcaklık</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:variable name="Temp" select="Temperature" />
        <xsl:choose>
          <xsl:when test="string(number($Temp))='NaN'"><xsl:value-of select="string('?')"/></xsl:when> <!-- could use &#160; for space -->
          <xsl:otherwise>
            <xsl:variable name="TUnit">
              <xsl:choose>
                <xsl:when test="$TempUnit='Fahrenheit'">&#0176;F</xsl:when>
                <xsl:otherwise>&#0176;C</xsl:otherwise>
              </xsl:choose>
            </xsl:variable>
            <xsl:choose>
              <xsl:when test="$TempUnit='Fahrenheit'">
                <xsl:value-of select="concat(format-number($Temp * 1.8 + 32, $DecPl1, 'Standard'), $TUnit)"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="concat(format-number($Temp, $DecPl1, 'Standard'), $TUnit)"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">ppm</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:choose>
          <xsl:when test="PPM = ''">&#160;</xsl:when>
          <xsl:otherwise><xsl:value-of select="format-number(PPM, $DecPl1, 'Standard')"/></xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Eğrilik düzeltmesi</xsl:with-param>
      <xsl:with-param name="Val1">
        <xsl:choose>
          <xsl:when test="ApplyEarthCurvatureCorrection = 'true'">Evet</xsl:when>
          <xsl:otherwise>Hayır</xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Hdr2">Refraksiyon düzeltmesi</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:choose>
          <xsl:when test="ApplyRefractionCorrection = 'true'">Evet</xsl:when>
          <xsl:otherwise>Hayır</xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Hdr3">Refraksiyon kats.</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:choose>
          <xsl:when test="(ApplyRefractionCorrection = 'false') or (RefractionCoefficient = '')">&#160;</xsl:when>
          <xsl:otherwise><xsl:value-of select="RefractionCoefficient"/></xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************** StationRecord Output ********************** -->
<!-- **************************************************************** -->
<xsl:template match="StationRecord">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">İstasyon kurulumu</p></caption>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">İstasyon</xsl:with-param>
      <xsl:with-param name="Val1" select="StationName"/>
      <xsl:with-param name="Hdr2">Alet yüksekliği</xsl:with-param>
      <xsl:with-param name="Val2" select="format-number(TheodoliteHeight * $DistConvFactor, $DecPl3, 'Standard')"/>
      <xsl:with-param name="Hdr3">İstasyon tipi</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:if test="StationType[.='StationSetup']">İstasyon kurulumu</xsl:if>
        <xsl:if test="StationType[.='StationSetupPlus']">İstasyon bilgisi +</xsl:if>
        <xsl:if test="StationType[.='StandardResection']">Kestirme (Standart)</xsl:if>
        <xsl:if test="StationType[.='HelmertResection']">Kestirme (Helmert)</xsl:if>
      </xsl:with-param>
      <xsl:with-param name="Hdr4">Ölçek faktörü</xsl:with-param>
      <xsl:with-param name="Val4" select="format-number(ScaleFactor, $DecPl8, 'Standard')"/>
      <xsl:with-param name="Hdr5">Std Hata</xsl:with-param>
      <xsl:with-param name="Val5" select="format-number(ScaleFactorStandardError, $DecPl8, 'Standard')"/>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** BackBearingRecord Output ********************* -->
<!-- **************************************************************** -->
<xsl:template match="BackBearingRecord">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Yöneltme</p></caption>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">İstasyon</xsl:with-param>
      <xsl:with-param name="Val1" select="Station"/>

      <xsl:with-param name="Hdr2">Geribakış noktası</xsl:with-param>
      <xsl:with-param name="Val2" select="BackSight"/>

      <xsl:with-param name="Hdr3">Yöneltme düzeltmesi</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="OrientationCorrection"/>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">Yönelt. Std Hata</xsl:with-param>
      <xsl:with-param name="Val4">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="OrientationCorrectionStandardError"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Station Residuals Output ******************** -->
<!-- **************************************************************** -->
<xsl:template match="StationResiduals">
  <xsl:call-template name="SeparatingLine"/>
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Farklar (İstasyon)</p></caption>
  <xsl:call-template name="EndTable"/>
  <xsl:apply-templates select="ResidualsRecord"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Residual Details Output ********************* -->
<!-- **************************************************************** -->
<xsl:template match="ResidualsRecord">
  <xsl:call-template name="StartTable"/>
    <!-- First line contains the grid residuals -->
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Nokta</xsl:with-param>
      <xsl:with-param name="Val1" select="PointName"/>

      <xsl:with-param name="Hdr2">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">ΔYu</xsl:when>
          <xsl:otherwise>ΔSağ</xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">
            <xsl:value-of select="format-number(GridResidual/DeltaNorth * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="format-number(GridResidual/DeltaEast * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">ΔSağ</xsl:when>
          <xsl:otherwise>ΔYu</xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">
            <xsl:value-of select="format-number(GridResidual/DeltaEast * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="format-number(GridResidual/DeltaNorth * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>

      <xsl:with-param name="Hdr4" select="$dElevPrompt"/>
      <xsl:with-param name="Val4" select="format-number(GridResidual/DeltaElevation * $ElevConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr5">Kullanılan</xsl:with-param>
      <xsl:with-param name="Val5">
        <xsl:choose>
          <xsl:when test="ObservationUsedInSolutionFor = 'VerticalOnly'">Sadece düşey</xsl:when>
          <xsl:when test="ObservationUsedInSolutionFor = 'HorizontalOnly'">Sadece yatay</xsl:when>
          <xsl:when test="ObservationUsedInSolutionFor = 'HorizontalAndVertical'">Yatay+Düşey</xsl:when>
          <xsl:otherwise>Kullanılmayan</xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
    </xsl:call-template>

    <!-- Second line has the angular and distance residuals -->
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr2">ΔYA</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="AngleResidual/HorizontalCircle"/>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">ΔDA</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="AngleResidual/VerticalCircle"/>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">ΔEM</xsl:with-param>
      <xsl:with-param name="Val4">
        <xsl:value-of select="format-number(AngleResidual/SlopeDistance * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
    </xsl:call-template>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* Rounds Residuals Output ******************** -->
<!-- **************************************************************** -->
<xsl:template match="RoundsMeanTurnedAngleResiduals">
  <xsl:variable name="angleFactor">
    <xsl:choose> <!-- Residual angle values in JobXML files from Survey Controllers v12.10 and earlier were incorrectly in radians -->
      <xsl:when test="contains($prodVersion, 'Trimble Survey Controller') and
                      (number(substring($prodVersion, string-length($prodVersion) - 4, 5)) &lt;= 12.10)">
        <xsl:value-of select="180.0 div $Pi"/>
      </xsl:when>
      <xsl:otherwise>1</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:call-template name="SeparatingLine"/>
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Farklar (Silsileler)</p></caption>
  <xsl:for-each select="MeanTurnedAngleResiduals">
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Nokta</xsl:with-param>
      <xsl:with-param name="Val1" select="PointName"/>
    
      <xsl:with-param name="Hdr2">Silsile</xsl:with-param>
      <xsl:with-param name="Val2" select="Round"/>

      <xsl:with-param name="Hdr3">ΔYA</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="HorizontalAngleResidual * $angleFactor"/>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">ΔDA</xsl:with-param>
      <xsl:with-param name="Val4">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="VerticalAngleResidual * $angleFactor"/>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr5">ΔEM</xsl:with-param>
      <xsl:with-param name="Val5">
        <xsl:value-of select="format-number(SlopeDistanceResidual * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:for-each>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ********************* Road Record Output *********************** -->
<!-- **************************************************************** -->
<xsl:template match="RoadRecord">
  <xsl:if test="Deleted = 'false'">  <!-- Road definition has not been deleted -->
    <xsl:call-template name="StartTable"/>
      <caption align="top"><p align="left">Yol</p></caption>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">
          <xsl:choose>
            <xsl:when test="$useRailTerminology = 'true'">Demiryolu adı</xsl:when>
            <xsl:otherwise>Yol adı</xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
        <xsl:with-param name="Val" select="Name"/>
      </xsl:call-template>
    <xsl:call-template name="EndTable"/>
    <xsl:call-template name="SeparatingLine"/>
  </xsl:if>  
</xsl:template>


<!-- **************************************************************** -->
<!-- ********************* Note Record Output *********************** -->
<!-- **************************************************************** -->
<xsl:template match="NoteRecord">
  <xsl:call-template name="StartTable"/>

  <xsl:for-each select="Notes/Note">
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Not</xsl:with-param>
      <xsl:with-param name="Val" select="."/>
    </xsl:call-template>
  </xsl:for-each>

  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ********************* Line Record Output *********************** -->
<!-- **************************************************************** -->
<xsl:template match="LineRecord">
  <xsl:if test="Deleted = 'false'">  <!-- Line definition has not been deleted -->
    <xsl:call-template name="StartTable"/>
      <caption align="top"><p align="left">Doğru</p></caption>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Doğru</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:text>İsim: </xsl:text><xsl:value-of select="Name"/>
          <xsl:text> Kod: </xsl:text><xsl:value-of select="Code"/>
        </xsl:with-param>
      </xsl:call-template>

      <!-- Output any descriptions assigned to the line -->
      <xsl:call-template name="OutputDescriptions">
        <xsl:with-param name="lineArc" select="'true'"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Tanım</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="LineMethodText">
            <xsl:with-param name="Method" select="Method"/>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>

      <xsl:if test="StartPoint and StartPoint != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">İlk nokta</xsl:with-param>
          <xsl:with-param name="Val" select="StartPoint"/>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="EndPoint and EndPoint != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Son nokta</xsl:with-param>
          <xsl:with-param name="Val" select="EndPoint"/>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="Azimuth and Azimuth != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Semt A.</xsl:with-param>
          <xsl:with-param name="Val">
            <xsl:call-template name="FormatAzimuth">
              <xsl:with-param name="theAzimuth" select="Azimuth"/>
              <xsl:with-param name="northLbl">K</xsl:with-param>
              <xsl:with-param name="eastLbl">S</xsl:with-param>
              <xsl:with-param name="southLbl">G</xsl:with-param>
              <xsl:with-param name="westLbl">B</xsl:with-param>
            </xsl:call-template>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="Length and Length != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Uzunluk</xsl:with-param>
          <xsl:with-param name="Val" select="format-number(Length * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="Grade and Grade != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Eğim</xsl:with-param>
          <xsl:with-param name="Val" select="concat(format-number(Grade, $DecPl2, 'Standard'), '%')"/>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="StartStation and StartStation != ''">
        <xsl:variable name="startStn">
          <xsl:call-template name="FormatStationVal">
            <xsl:with-param name="stationVal" select="StartStation"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">
            <xsl:choose>
              <xsl:when test="$useChainageTerminology = 'true'">Chainage</xsl:when>
              <xsl:otherwise>İstasyon detayları</xsl:otherwise>
            </xsl:choose>
          </xsl:with-param>
          <xsl:with-param name="Val">
            <xsl:choose>
              <xsl:when test="$useChainageTerminology = 'true'">Start chainage: </xsl:when>
              <xsl:otherwise>Baş.Km.: </xsl:otherwise>
            </xsl:choose>
            <xsl:value-of select="$startStn"/>
            <xsl:choose>
              <xsl:when test="$useChainageTerminology = 'true'"> Chainage interval: </xsl:when>
              <xsl:otherwise> İstasyon aralığı: </xsl:otherwise>
            </xsl:choose>
            <xsl:value-of select="format-number(StationInterval * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:if>
    <xsl:call-template name="EndTable"/>
  </xsl:if>  
</xsl:template>


<!-- **************************************************************** -->
<!-- ********************** Arc Record Output *********************** -->
<!-- **************************************************************** -->
<xsl:template match="ArcRecord">
  <xsl:if test="Deleted = 'false'">  <!-- Arc definition has not been deleted -->
    <xsl:call-template name="StartTable"/>
      <caption align="top"><p align="left">Yay</p></caption>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Yay</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:text>İsim: </xsl:text><xsl:value-of select="Name"/>
          <xsl:text> Kod: </xsl:text><xsl:value-of select="Code"/>
        </xsl:with-param>
      </xsl:call-template>

      <!-- Output any descriptions assigned to the arc -->
      <xsl:call-template name="OutputDescriptions">
        <xsl:with-param name="lineArc" select="'true'"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Tanım</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="ArcMethodText">
            <xsl:with-param name="Method" select="Method"/>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>

      <xsl:if test="StartPoint and StartPoint != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">İlk nokta</xsl:with-param>
          <xsl:with-param name="Val" select="StartPoint"/>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="EndPoint and EndPoint != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Son nokta</xsl:with-param>
          <xsl:with-param name="Val" select="EndPoint"/>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="Direction and Direction != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Doğrultu</xsl:with-param>
          <xsl:with-param name="Val" select="Direction"/>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="Radius and Radius != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Yarıçap</xsl:with-param>
          <xsl:with-param name="Val" select="format-number(Radius * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="StartAzimuth and StartAzimuth != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Başl. semti</xsl:with-param>
          <xsl:with-param name="Val">
            <xsl:call-template name="FormatAzimuth">
              <xsl:with-param name="theAzimuth" select="StartAzimuth"/>
              <xsl:with-param name="northLbl">K</xsl:with-param>
              <xsl:with-param name="eastLbl">S</xsl:with-param>
              <xsl:with-param name="southLbl">G</xsl:with-param>
              <xsl:with-param name="westLbl">B</xsl:with-param>
            </xsl:call-template>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="Length and Length != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Uzunluk</xsl:with-param>
          <xsl:with-param name="Val" select="format-number(Length * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="Grade and Grade != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Eğim</xsl:with-param>
          <xsl:with-param name="Val" select="concat(format-number(Grade, $DecPl2, 'Standard'), '%')"/>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="DeltaAngle and DeltaAngle != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Delta açı</xsl:with-param>
          <xsl:with-param name="Val">
            <xsl:call-template name="FormatAngle">
              <xsl:with-param name="theAngle" select="DeltaAngle"/>
            </xsl:call-template>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="IntersectionPoint and IntersectionPoint != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Kesim noktası</xsl:with-param>
          <xsl:with-param name="Val" select="IntersectionPoint"/>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="EndAzimuth and EndAzimuth != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Son semt</xsl:with-param>
          <xsl:with-param name="Val">
            <xsl:call-template name="FormatAzimuth">
              <xsl:with-param name="theAzimuth" select="EndAzimuth"/>
              <xsl:with-param name="northLbl">K</xsl:with-param>
              <xsl:with-param name="eastLbl">S</xsl:with-param>
              <xsl:with-param name="southLbl">G</xsl:with-param>
              <xsl:with-param name="westLbl">B</xsl:with-param>
            </xsl:call-template>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="StartStation and StartStation != ''">
        <xsl:variable name="startStn">
          <xsl:call-template name="FormatStationVal">
            <xsl:with-param name="stationVal" select="StartStation"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">
            <xsl:choose>
              <xsl:when test="$useChainageTerminology = 'true'">Chainage</xsl:when>
              <xsl:otherwise>İstasyon detayları</xsl:otherwise>
            </xsl:choose>
          </xsl:with-param>
          <xsl:with-param name="Val">
            <xsl:choose>
              <xsl:when test="$useChainageTerminology = 'true'">Start chainage: </xsl:when>
              <xsl:otherwise>Baş.Km.: </xsl:otherwise>
            </xsl:choose>
            <xsl:value-of select="$startStn"/>
            <xsl:choose>
              <xsl:when test="$useChainageTerminology = 'true'"> Chainage interval: </xsl:when>
              <xsl:otherwise> İstasyon aralığı: </xsl:otherwise>
            </xsl:choose>
            <xsl:value-of select="format-number(StationInterval * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:if>
    <xsl:call-template name="EndTable"/>
  </xsl:if>  
</xsl:template>


<!-- **************************************************************** -->
<!-- ********************* Inverse Record Output ******************** -->
<!-- **************************************************************** -->
<xsl:template match="InverseRecord">
  <xsl:variable name="AzLbl">
    <xsl:choose>
      <xsl:when test="AzimuthType[.='Grid']">Azimut (grid)</xsl:when>
      <xsl:when test="AzimuthType[.='Magnetic']">Semt (mag)</xsl:when>
      <xsl:when test="AzimuthType[.='Local']">Semt (lokal)</xsl:when>
      <xsl:when test="AzimuthType[.='WGS84']">Semt (WGS84)</xsl:when>
      <xsl:otherwise>Semt A.</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="DistType">
    <xsl:choose>
      <xsl:when test="DistanceType[.='Grid']">Grid</xsl:when>
      <xsl:when test="DistanceType[.='Ground']">Yersel</xsl:when>
      <xsl:when test="DistanceType[.='Ellipsoid']">Elipsoid</xsl:when>
      <xsl:otherwise>Grid</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">İnvers</p></caption>
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Noktadan</xsl:with-param>
      <xsl:with-param name="Val1" select="FromPoint"/>

      <xsl:with-param name="Hdr2">Noktaya</xsl:with-param>
      <xsl:with-param name="Val2" select="ToPoint"/>

      <xsl:with-param name="Hdr3"><xsl:value-of select="$AzLbl"/></xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:call-template name="FormatAzimuth">
          <xsl:with-param name="theAzimuth" select="Azimuth"/>
          <xsl:with-param name="northLbl">K</xsl:with-param>
          <xsl:with-param name="eastLbl">S</xsl:with-param>
          <xsl:with-param name="southLbl">G</xsl:with-param>
          <xsl:with-param name="westLbl">B</xsl:with-param>
        </xsl:call-template>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">YM</xsl:with-param>
      <xsl:with-param name="Val4" select="format-number(HorizontalDistance * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr5">K.Frk</xsl:with-param>
      <xsl:with-param name="Val5" select="format-number(VerticalDistance * $DistConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr3">Eğik mes</xsl:with-param>
      <xsl:with-param name="Val3" select="format-number(SlopeDistance * $DistConvFactor, $DecPl3, 'Standard')"/>

      <xsl:with-param name="Hdr4">Eğim</xsl:with-param>
      <xsl:with-param name="Val4" select="concat(format-number(Grade, $DecPl2, 'Standard'), '%')"/>

      <xsl:with-param name="Hdr5">Mesafe</xsl:with-param>
      <xsl:with-param name="Val5"><xsl:value-of select="$DistType"/></xsl:with-param>

    </xsl:call-template>

  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** ProjectionRecord Output ********************* -->
<!-- **************************************************************** -->
<xsl:template match="ProjectionRecord">
  
  <xsl:call-template name="ProjDetailsOutput"/>

  <xsl:call-template name="LocalSiteOutput"/>
 
</xsl:template>


<!-- **************************************************************** -->
<!-- *************** CoordinateSystem Details Output **************** -->
<!-- **************************************************************** -->
<xsl:template match="CoordinateSystem">

  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Koordinat sistemi (İş)</p></caption>
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Sistem</xsl:with-param>
        <xsl:with-param name="Val" select="SystemName"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Zone</xsl:with-param>
        <xsl:with-param name="Val" select="ZoneName"/>
      </xsl:call-template>

      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Datum</xsl:with-param>
        <xsl:with-param name="Val" select="DatumName"/>
      </xsl:call-template>
  <xsl:call-template name="EndTable"/>

  <xsl:call-template name="ProjDetailsOutput"/>

  <xsl:call-template name="LocalSiteOutput"/>
  
  <xsl:apply-templates select="Datum"/>

  <xsl:apply-templates select="HorizontalAdjustment"/>

  <xsl:apply-templates select="VerticalAdjustment"/>

  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************** Datum Details Output ********************** -->
<!-- **************************************************************** -->
<xsl:template match="Datum">

  <xsl:call-template name="DatumTransformationOutput"/>

</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** DatumRecord Details Output ******************* -->
<!-- **************************************************************** -->
<xsl:template match="DatumRecord">

  <xsl:call-template name="DatumTransformationOutput"/>

</xsl:template>


<!-- **************************************************************** -->
<!-- ************* HorizontalAdjustment Details Output ************** -->
<!-- **************************************************************** -->
<xsl:template match="HorizontalAdjustment">

  <xsl:call-template name="HorizontalAdjustmentOutput"/>

</xsl:template>


<!-- **************************************************************** -->
<!-- ********** HorizontalAdjustmentRecord Details Output *********** -->
<!-- **************************************************************** -->
<xsl:template match="HorizontalAdjustmentRecord">

  <xsl:call-template name="HorizontalAdjustmentOutput"/>

</xsl:template>


<!-- **************************************************************** -->
<!-- ************** VerticalAdjustment Details Output *************** -->
<!-- **************************************************************** -->
<xsl:template match="VerticalAdjustment">

  <xsl:call-template name="VerticalAdjustmentOutput"/>

</xsl:template>


<!-- **************************************************************** -->
<!-- *********** VerticalAdjustmentRecord Details Output ************ -->
<!-- **************************************************************** -->
<xsl:template match="VerticalAdjustmentRecord">

  <xsl:call-template name="VerticalAdjustmentOutput"/>

</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** ProjectionRecord Output ********************* -->
<!-- **************************************************************** -->
<xsl:template name="ProjDetailsOutput">
  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Projeksiyon</p></caption>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Projeksiyon</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="ProjectionTypeText">
          <xsl:with-param name="Type" select="Projection/Type"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:if test="Projection/CentralLatitude">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Enl. Orijin</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormatLatLong">
            <xsl:with-param name="theAngle" select="Projection/CentralLatitude"/>
            <xsl:with-param name="northLbl">K</xsl:with-param>
            <xsl:with-param name="eastLbl">S</xsl:with-param>
            <xsl:with-param name="southLbl">G</xsl:with-param>
            <xsl:with-param name="westLbl">B</xsl:with-param>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>
    
    <xsl:if test="Projection/CentralLongitude">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Boyl.Orijin</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormatLatLong">
            <xsl:with-param name="theAngle" select="Projection/CentralLongitude"/>
            <xsl:with-param name="isLat" select="'false'"/>
            <xsl:with-param name="northLbl">K</xsl:with-param>
            <xsl:with-param name="eastLbl">S</xsl:with-param>
            <xsl:with-param name="southLbl">G</xsl:with-param>
            <xsl:with-param name="westLbl">B</xsl:with-param>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>
    
    <xsl:if test="Projection/OriginHeight">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Kot Orijin</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(Projection/OriginHeight * $ElevConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:choose>
      <xsl:when test="$NECoords = 'true'">
        <xsl:if test="Projection/FalseNorthing">
          <xsl:call-template name="OutputSingleElementTableLine">
            <xsl:with-param name="Hdr">Yukarı düzeltme</xsl:with-param>
            <xsl:with-param name="Val" select="format-number(Projection/FalseNorthing * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:call-template>
        </xsl:if>

        <xsl:if test="Projection/FalseEasting">
          <xsl:call-template name="OutputSingleElementTableLine">
            <xsl:with-param name="Hdr">Sağa düzeltme</xsl:with-param>
            <xsl:with-param name="Val" select="format-number(Projection/FalseEasting * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:call-template>
        </xsl:if>
      </xsl:when>
      <xsl:otherwise>
        <xsl:if test="Projection/FalseEasting">
          <xsl:call-template name="OutputSingleElementTableLine">
            <xsl:with-param name="Hdr">Sağa düzeltme</xsl:with-param>
            <xsl:with-param name="Val" select="format-number(Projection/FalseEasting * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:call-template>
        </xsl:if>

        <xsl:if test="Projection/FalseNorthing">
          <xsl:call-template name="OutputSingleElementTableLine">
            <xsl:with-param name="Hdr">Yukarı düzeltme</xsl:with-param>
            <xsl:with-param name="Val" select="format-number(Projection/FalseNorthing * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:call-template>
        </xsl:if>
      </xsl:otherwise>
    </xsl:choose>
    
    <xsl:if test="Projection/OriginElevation">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Kot düzeltme</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(Projection/OriginElevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Projection/Parallel1">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">1. Paralel</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormatLatLong">
            <xsl:with-param name="theAngle" select="Projection/Parallel1"/>
            <xsl:with-param name="northLbl">K</xsl:with-param>
            <xsl:with-param name="eastLbl">S</xsl:with-param>
            <xsl:with-param name="southLbl">G</xsl:with-param>
            <xsl:with-param name="westLbl">B</xsl:with-param>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>
    
    <xsl:if test="Projection/Parallel2">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">2. Paralel</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormatLatLong">
            <xsl:with-param name="theAngle" select="Projection/Parallel2"/>
            <xsl:with-param name="northLbl">K</xsl:with-param>
            <xsl:with-param name="eastLbl">S</xsl:with-param>
            <xsl:with-param name="southLbl">G</xsl:with-param>
            <xsl:with-param name="westLbl">B</xsl:with-param>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>
    
    <xsl:if test="Projection/Scale">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Ölçek</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(Projection/Scale, $DecPl8, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Projection/Rotation">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Dönme</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="Projection/Rotation"/>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>
    
    <xsl:if test="Projection/Azimuth">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Semt A.</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormatAzimuth">
            <xsl:with-param name="theAzimuth" select="Projection/Azimuth"/>
            <xsl:with-param name="northLbl">K</xsl:with-param>
            <xsl:with-param name="eastLbl">S</xsl:with-param>
            <xsl:with-param name="southLbl">G</xsl:with-param>
            <xsl:with-param name="westLbl">B</xsl:with-param>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>
    
    <xsl:if test="Projection/AzimuthAt">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Semt:</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:if test="Projection/AzimuthAt[.='Equator']">Ekvator</xsl:if>
          <xsl:if test="Projection/AzimuthAt[.='ProjectionCentre']">Projeksiyon merkezi</xsl:if>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Projection/OriginAt">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Orijin=</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:if test="Projection/OriginAt[.='Equator']">Equator</xsl:if>
          <xsl:if test="Projection/OriginAt[.='ProjectionCentre']">Projeksiyon merkezi</xsl:if>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Projection/Rectify">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Koordinat düzeltme</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:if test="Projection/Rectify[.='true']">Evet</xsl:if>
          <xsl:if test="Projection/Rectify[.='false']">Hayır</xsl:if>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Projection/FerroConstant">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Ferro sabiti</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormatLatLong">
            <xsl:with-param name="theAngle" select="Projection/FerroConstant"/>
            <xsl:with-param name="isLat" select="'false'"/>
            <xsl:with-param name="northLbl">K</xsl:with-param>
            <xsl:with-param name="eastLbl">S</xsl:with-param>
            <xsl:with-param name="southLbl">G</xsl:with-param>
            <xsl:with-param name="westLbl">B</xsl:with-param>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Projection/Area">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Danimarka</xsl:with-param>
        <xsl:with-param name="Val" select="Projection/Area"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Projection/ShiftGridFileName and 
                  Projection/ShiftGridFileName != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Grid kaydırma dosyası</xsl:with-param>
        <xsl:with-param name="Val" select="Projection/ShiftGridFileName"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Projection/ProjectionGridFile and
                  Projection/ProjectionGridFile != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Grid projeksiyon dosyası</xsl:with-param>
        <xsl:with-param name="Val" select="Projection/ProjectionGridFile"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Projection/NorthGridFile">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Grid kaydırma dosyası (Yukarı)</xsl:with-param>
        <xsl:with-param name="Val" select="Projection/NorthGridFile"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Projection/EastGridFile">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Grid kaydırma dosyası (Sağa)</xsl:with-param>
        <xsl:with-param name="Val" select="Projection/EastGridFile"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Projection/SouthAzimuth">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Güney semt (grid)</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:if test="Projection/SouthAzimuth[.='true']">Evet</xsl:if>
          <xsl:if test="Projection/SouthAzimuth[.='false']">Hayır</xsl:if>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Projection/GridOrientation">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Grid koord.</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:if test="Projection/GridOrientation[.='IncreasingNorthEast']">Kuzey-Doğu artım</xsl:if>
          <xsl:if test="Projection/GridOrientation[.='IncreasingSouthWest']">Güney-Batı artım</xsl:if>
          <xsl:if test="Projection/GridOrientation[.='IncreasingNorthWest']">Kuzey-Batı artım</xsl:if>
          <xsl:if test="Projection/GridOrientation[.='IncreasingSouthEast']">Güney-Doğu artım</xsl:if>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

    <!-- Include ellipsoid details -->
    <xsl:variable name="semiMajorAxis">
      <xsl:choose>
        <xsl:when test="Ellipsoid">
          <xsl:value-of select="Ellipsoid/EarthRadius"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="preceding-sibling::EllipsoidRecord[1]/EarthRadius"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <xsl:variable name="flattening">
      <xsl:choose>
        <xsl:when test="Ellipsoid">
          <xsl:value-of select="Ellipsoid/Flattening"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="preceding-sibling::EllipsoidRecord[1]/Flattening"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <xsl:if test="Projection/Type != 'ScaleOnly'">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Elipsoid</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:text>Yarı-major eksen</xsl:text>
          <xsl:value-of select="': '"/>
          <xsl:value-of select="format-number($semiMajorAxis * $DistConvFactor, $DecPl3, 'Standard')"/>
          <xsl:value-of select="'  '"/>
          <xsl:text>Flattening</xsl:text>
          <xsl:value-of select="': '"/>
          <xsl:value-of select="format-number(1 div $flattening, $DecPl8, 'Standard')"/>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** Projection Type Text Output ****************** -->
<!-- **************************************************************** -->
<xsl:template name="ProjectionTypeText">
  <xsl:param name="Type"/>
  
  <xsl:choose>
    <xsl:when test="$Type = 'NoProjection'">Projeksiyon yok</xsl:when>
    <xsl:when test="$Type = 'ScaleOnly'">Sadece ölçek faktörü</xsl:when>
    <xsl:when test="$Type = 'Plane'">Düzlem</xsl:when>
    <xsl:when test="$Type = 'Mercator'">Mercator</xsl:when>
    <xsl:when test="$Type = 'TransverseMercator'">Transverse Mercator</xsl:when>
    <xsl:when test="$Type = 'UniversalTransverseMercator'">Universal Transverse Mercator</xsl:when>
    <xsl:when test="$Type = 'Lambert1Parallel'">Lambert Konform Konik 1 Paralel</xsl:when>
    <xsl:when test="$Type = 'Lambert2Parallel'">Lambert Konform Konik 2 Paralel</xsl:when>
    <xsl:when test="$Type = 'ObliqueMercatorAngle'">Eğik Konumlu Mercator Açı</xsl:when>
    <xsl:when test="$Type = 'ObliqueConformalCylindrical'">Eğik Konumlu Konform Silindirik</xsl:when>
    <xsl:when test="$Type = 'PolarStereographic'">Polar Stereografik</xsl:when>
    <xsl:when test="$Type = 'RDStereographic'">R.D. Stereografik</xsl:when>
    <xsl:when test="$Type = 'AlbersEqualAreaConic'">Albers Alan Koruyan Konik</xsl:when>
    <xsl:when test="$Type = 'CassiniSoldner'">Cassini-Soldner</xsl:when>
    <xsl:when test="$Type = 'Krovak'">Krovak</xsl:when>
    <xsl:when test="$Type = 'NewZealandMapGrid'">Yeni Zellanda Harita Ağı</xsl:when>
    <xsl:when test="$Type = 'UnitedKingdomNationalGrid'">UK Ülke Ağı</xsl:when>
    <xsl:when test="$Type = 'Denmark'">Danimarka</xsl:when>
    <xsl:when test="$Type = 'HungarianEOV'">Macaristan EOV</xsl:when>
    <xsl:when test="$Type = 'StereographicDouble'">Stereografik Çift</xsl:when>
    <xsl:when test="$Type = 'RSO'">RSO</xsl:when>
    <xsl:when test="$Type = 'UPSNorth'">UPS kuzey</xsl:when>
    <xsl:when test="$Type = 'UPSSouth'">UPS güney</xsl:when>
    <xsl:when test="$Type = 'ProjectionGrid'">Grid projeksiyonu</xsl:when>
    <xsl:otherwise>Bilinmeyen</xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* LocalSite Details Output ******************* -->
<!-- **************************************************************** -->
<xsl:template name="LocalSiteOutput">

  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Lokal koordinat</p></caption>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Tip</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:if test="LocalSite/Type[.='Grid']">Grid</xsl:if>
        <xsl:if test="LocalSite/Type[.='KeyedInGroundScaleFactor']">Yersel (girilen ölçek faktörü)</xsl:if>
        <xsl:if test="LocalSite/Type[.='CalculatedGroundScaleFactor']">Yersel (hesaplanan ölçek faktörü)</xsl:if>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:if test="LocalSite/ProjectLocationLatitude and
                  LocalSite/ProjectLocationLatitude != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Proje bölgesi (Enlem)</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormatLatLong">
            <xsl:with-param name="theAngle" select="LocalSite/ProjectLocationLatitude"/>
            <xsl:with-param name="northLbl">K</xsl:with-param>
            <xsl:with-param name="eastLbl">S</xsl:with-param>
            <xsl:with-param name="southLbl">G</xsl:with-param>
            <xsl:with-param name="westLbl">B</xsl:with-param>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="LocalSite/ProjectLocationLongitude and
                  LocalSite/ProjectLocationLongitude != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Proje bölgesi (Boylam)</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormatLatLong">
            <xsl:with-param name="theAngle" select="LocalSite/ProjectLocationLongitude"/>
            <xsl:with-param name="isLat" select="'false'"/>
            <xsl:with-param name="northLbl">K</xsl:with-param>
            <xsl:with-param name="eastLbl">S</xsl:with-param>
            <xsl:with-param name="southLbl">G</xsl:with-param>
            <xsl:with-param name="westLbl">B</xsl:with-param>
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="LocalSite/ProjectLocationLongitude and
                  LocalSite/ProjectLocationLongitude != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Proje bölgesi (Yükseklik)</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(LocalSite/ProjectLocationHeight * $ElevConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="LocalSite/GroundScaleFactor and
                  LocalSite/GroundScaleFactor != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Yer ölçek faktörü</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(LocalSite/GroundScaleFactor, $DecPl8, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="LocalSite/NorthingOffset and LocalSite/NorthingOffset != '' and 
                  LocalSite/EastingOffset and LocalSite/EastingOffset != ''">
      <xsl:choose>
        <xsl:when test="$NECoords = 'true'">
          <xsl:call-template name="OutputSingleElementTableLine">
            <xsl:with-param name="Hdr">Yukarı ofseti</xsl:with-param>
            <xsl:with-param name="Val" select="format-number(LocalSite/NorthingOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:call-template>

          <xsl:call-template name="OutputSingleElementTableLine">
            <xsl:with-param name="Hdr">Sağa ofset</xsl:with-param>
            <xsl:with-param name="Val" select="format-number(LocalSite/EastingOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="OutputSingleElementTableLine">
            <xsl:with-param name="Hdr">Sağa ofset</xsl:with-param>
            <xsl:with-param name="Val" select="format-number(LocalSite/EastingOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:call-template>

          <xsl:call-template name="OutputSingleElementTableLine">
            <xsl:with-param name="Hdr">Yukarı ofseti</xsl:with-param>
            <xsl:with-param name="Val" select="format-number(LocalSite/NorthingOffset * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:if>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************** Datum Transformation Details Output ************* -->
<!-- **************************************************************** -->
<xsl:template name="DatumTransformationOutput">

  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Datum transformasyonu</p></caption>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Tip</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:if test="Type[.='NoDatum']">Yok</xsl:if>
        <xsl:if test="Type[.='SevenParameter']">Yedi parametre</xsl:if>
        <xsl:if test="Type[.='ThreeParameter']">Üç parametre</xsl:if>
        <xsl:if test="Type[.='GridDatum']">Datum grid</xsl:if>
      </xsl:with-param>
    </xsl:call-template>
      
    <xsl:if test="EarthRadius and EarthRadius != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Yarı-major eksen</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(EarthRadius * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Flattening and Flattening != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Flattening</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(1.0 div Flattening, $DecPl6, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="RotationX and RotationX != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Dönme X</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="RotationX"/>
            <xsl:with-param name="secDecPlaces">4</xsl:with-param>
            <xsl:with-param name="DMSOutput" select="'true'"/>  <!-- Will override current angle units -->
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="RotationY and RotationY != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Dönme Y</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="RotationY"/>
            <xsl:with-param name="secDecPlaces">4</xsl:with-param>
            <xsl:with-param name="DMSOutput" select="'true'"/>  <!-- Will override current angle units -->
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="RotationZ and RotationZ != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Dönme Z</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="RotationZ"/>
            <xsl:with-param name="secDecPlaces">4</xsl:with-param>
            <xsl:with-param name="DMSOutput" select="'true'"/>  <!-- Will override current angle units -->
          </xsl:call-template>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="TranslationX and TranslationX != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">X'de öteleme</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(TranslationX * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="TranslationY and TranslationY != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Y'de öteleme</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(TranslationY * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="TranslationZ and TranslationZ != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Z'de öteleme</xsl:with-param>
        <xsl:with-param name="Val" select="format-number(TranslationZ * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="Scale and Scale != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Ölçek</xsl:with-param>
        <xsl:with-param name="Val">
          <xsl:value-of select="format-number((Scale - 1.0) * 1000000.0, $DecPl5, 'Standard')"/><xsl:text>ppm</xsl:text>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>

    <xsl:if test="GridName and GridName != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr">Datum Grid Dosyası</xsl:with-param>
        <xsl:with-param name="Val" select="GridName"/>
      </xsl:call-template>
    </xsl:if>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************* Horizontal Adjustment Details Output ************* -->
<!-- **************************************************************** -->
<xsl:template name="HorizontalAdjustmentOutput">

  <xsl:if test="Type != 'NoAdjustment'"> <!-- Don't output table at all if there is no adjustment -->
    <xsl:call-template name="StartTable"/>
      <caption align="top"><p align="left">Yatay dengeleme</p></caption>

      <xsl:if test="OriginNorth and OriginNorth != '' and 
                    OriginEast and OriginEast != ''">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">
            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Kuzey orijin</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(OriginNorth * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:call-template>

            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Doğu orijin</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(OriginEast * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Doğu orijin</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(OriginEast * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:call-template>

            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Kuzey orijin</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(OriginNorth * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:if>

      <xsl:if test="TranslationNorth and TranslationNorth != '' and 
                    TranslationEast and TranslationEast != ''">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">
            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Yukarı öteleme</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(TranslationNorth * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:call-template>

            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Sağa öteleme</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(TranslationEast * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Sağa öteleme</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(TranslationEast * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:call-template>

            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Yukarı öteleme</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(TranslationNorth * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:if>

      <xsl:if test="Rotation and Rotation != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Dönme</xsl:with-param>
          <xsl:with-param name="Val">
            <xsl:call-template name="FormatAngle">
              <xsl:with-param name="theAngle" select="Rotation"/>
              <xsl:with-param name="secDecPlaces">4</xsl:with-param>
            </xsl:call-template>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="ScaleFactor and ScaleFactor != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Ölçek faktörü</xsl:with-param>
          <xsl:with-param name="Val" select="format-number(ScaleFactor, $DecPl8, 'Standard')"/>
        </xsl:call-template>
      </xsl:if>

    <xsl:call-template name="EndTable"/>
  </xsl:if>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************** Vertical Adjustment Details Output ************** -->
<!-- **************************************************************** -->
<xsl:template name="VerticalAdjustmentOutput">

  <xsl:if test="Type != 'NoAdjustment'"> <!-- Don't output table at all if there is no adjustment -->
    <xsl:call-template name="StartTable"/>
      <caption align="top"><p align="left">Düşey dengeleme</p></caption>

      <xsl:if test="OriginNorth and OriginNorth != '' and 
                    OriginEast and OriginEast != ''">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">
            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Kuzey orijin</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(OriginNorth * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:call-template>

            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Doğu orijin</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(OriginEast * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Doğu orijin</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(OriginEast * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:call-template>

            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Kuzey orijin</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(OriginNorth * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:if>

      <xsl:if test="SlopeNorthPerUnit and SlopeNorthPerUnit != '' and 
                    SlopeEastPerUnit and SlopeEastPerUnit != ''">
        <xsl:choose>
          <xsl:when test="$NECoords = 'true'">
            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Kuzey eğim</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(SlopeNorthPerUnit, $DecPl6, 'Standard')"/>
            </xsl:call-template>

            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Doğu eğim</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(SlopeEastPerUnit, $DecPl6, 'Standard')"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Doğu eğim</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(SlopeEastPerUnit, $DecPl6, 'Standard')"/>
            </xsl:call-template>

            <xsl:call-template name="OutputSingleElementTableLine">
              <xsl:with-param name="Hdr">Kuzey eğim</xsl:with-param>
              <xsl:with-param name="Val" select="format-number(SlopeNorthPerUnit, $DecPl6, 'Standard')"/>
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:if>

      <xsl:if test="ConstantAdjustment and ConstantAdjustment != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Sabit dengelemesi</xsl:with-param>
          <xsl:with-param name="Val" select="format-number(ConstantAdjustment * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:call-template>
      </xsl:if>

      <xsl:if test="GeoidName and GeoidName != ''">
        <xsl:call-template name="OutputSingleElementTableLine">
          <xsl:with-param name="Hdr">Geoid dosyası</xsl:with-param>
          <xsl:with-param name="Val" select="GeoidName"/>
        </xsl:call-template>
      </xsl:if>
    <xsl:call-template name="EndTable"/>
  </xsl:if>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* Traverse Definition Output ***************** -->
<!-- **************************************************************** -->
<xsl:template match="TraverseDefinitionRecord">

  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Poligon Tarifi</p></caption>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">İsim</xsl:with-param>
      <xsl:with-param name="Val" select="TraverseName"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Geribakış semti</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="FormatAzimuth">
          <xsl:with-param name="theAzimuth" select="BacksightAzimuth"/>
          <xsl:with-param name="northLbl">K</xsl:with-param>
          <xsl:with-param name="eastLbl">S</xsl:with-param>
          <xsl:with-param name="southLbl">G</xsl:with-param>
          <xsl:with-param name="westLbl">B</xsl:with-param>
        </xsl:call-template>
        <xsl:text> e </xsl:text><xsl:value-of select="BacksightPoint"/>
        <xsl:if test="BacksightAzimuthKeyedIn = 'true'">
          <xsl:text> (Girildi)</xsl:text>
        </xsl:if>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:for-each select="ListOfStations/Item">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr"><xsl:text>Poligon Noktası </xsl:text><xsl:value-of select="@n"/></xsl:with-param>
        <xsl:with-param name="Val" select="."/>
      </xsl:call-template>
    </xsl:for-each>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">İleri bakış semti</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="FormatAzimuth">
          <xsl:with-param name="theAzimuth" select="ForesightAzimuth"/>
          <xsl:with-param name="northLbl">K</xsl:with-param>
          <xsl:with-param name="eastLbl">S</xsl:with-param>
          <xsl:with-param name="southLbl">G</xsl:with-param>
          <xsl:with-param name="westLbl">B</xsl:with-param>
        </xsl:call-template>
        <xsl:text> e </xsl:text><xsl:value-of select="ForesightPoint"/>
        <xsl:if test="ForesightAzimuthKeyedIn = 'true'">
          <xsl:text> (Girildi)</xsl:text>
        </xsl:if>
      </xsl:with-param>
    </xsl:call-template>

  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* Traverse Adjustment Output ***************** -->
<!-- **************************************************************** -->
<xsl:template match="TraverseAdjustmentRecord">

  <xsl:call-template name="StartTable"/>
    <caption align="top"><p align="left">Poligon Dengeleme Metodu</p></caption>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Dengeleme metodu</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:if test="AdjustmentMethod[.='Transit']">Transit</xsl:if>
        <xsl:if test="AdjustmentMethod[.='Compass']">Pusula</xsl:if>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Hata dağılımı (Açısal)</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:if test="AngularErrorDistribution[.='ProportionalToDistance']">Mesafeyle orantılı</xsl:if>
        <xsl:if test="AngularErrorDistribution[.='EqualProportions']">Eşit oranlar</xsl:if>
        <xsl:if test="AngularErrorDistribution[.='None']">Yok</xsl:if>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr"><xsl:text>Hata dağılımı</xsl:text><xsl:value-of select="concat(' (', $elevPrompt, ')')"/></xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:if test="ElevationErrorDistribution[.='ProportionalToDistance']">Mesafeyle orantılı</xsl:if>
        <xsl:if test="ElevationErrorDistribution[.='EqualProportions']">Eşit oranlar</xsl:if>
        <xsl:if test="ElevationErrorDistribution[.='None']">Yok</xsl:if>
      </xsl:with-param>
    </xsl:call-template>

  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************** Traverse Closure Output ******************* -->
<!-- **************************************************************** -->
<xsl:template match="TraverseClosureRecord">

  <xsl:variable name="TraverseName">
    <xsl:for-each select="key('travID-search', TraverseDefinitionID)">
      <xsl:value-of select="TraverseName"/>
    </xsl:for-each>
  </xsl:variable>

  <xsl:variable name="AdjMethod">
    <xsl:if test="preceding-sibling::TraverseAdjustmentRecord[1]/AdjustmentMethod = 'Transit'">Transit</xsl:if>
    <xsl:if test="preceding-sibling::TraverseAdjustmentRecord[1]/AdjustmentMethod = 'Compass'">Pusula</xsl:if>
  </xsl:variable>
  
  <!-- If the traverse has been adjusted output the traverse details in a 'spreadsheet' table.  -->
  <!-- This record needs to be followed by a TraverseAdjusted PointRecord that is not deleted.  -->
  <!-- This is because a traverse may have been adjusted more than once and if this is the case -->
  <!-- then the original traverse adjusted points are deleted.  Therefore if this is not the    -->
  <!-- final adjustment we don't want to output the traverse 'spreadsheet' details              -->
  <!-- Test the first PointRecord after the current TraverseClosureRecord to ensure it is a     -->
  <!-- non-deleted TraverseAdjusted point.                                                      -->
  <xsl:if test="ClosureStatus[.='Adjusted'] and
                following-sibling::PointRecord[1]/Method[.='TraverseAdjusted'] and
                following-sibling::PointRecord[1]/Deleted[.='false']">
    <xsl:call-template name="StartTable"/>
    <caption align="top">
      <p align="left"><xsl:text>Poligon Özeti: </xsl:text><xsl:value-of select="$TraverseName"/></p>
    </caption>
    <xsl:for-each select="TraverseLegs/Leg">
      <xsl:variable name="FromPt" select="FromPoint"/>
      <xsl:variable name="ToPt" select="ToPoint"/>

      <xsl:if test="position() = 1">  <!-- The first traverse leg -->
        <!-- Get the starting point coordinates from the Reductions section -->
        <xsl:variable name="Coords">
          <xsl:for-each select="/JOBFile/Reductions/Point">
            <xsl:if test="Name = $FromPt">
              <xsl:value-of select="concat(Grid/North, '|', Grid/East)"/>
            </xsl:if>
          </xsl:for-each>
        </xsl:variable>
        <xsl:call-template name="OutputTableLine">
          <xsl:with-param name="Hdr1">Nokta</xsl:with-param>
          <xsl:with-param name="Val1" select="FromPoint"/>

          <xsl:with-param name="Hdr4">
            <xsl:if test="$NECoords = 'true'"><xsl:value-of select="$northPrompt"/></xsl:if>
            <xsl:if test="$NECoords != 'true'"><xsl:value-of select="$eastPrompt"/></xsl:if>
          </xsl:with-param>

          <xsl:with-param name="Val4">
            <xsl:if test="$NECoords = 'true'">
              <xsl:value-of select="format-number(number(substring-before($Coords, '|')) * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:if>
            <xsl:if test="$NECoords != 'true'">
              <xsl:value-of select="format-number(number(substring-after($Coords, '|')) * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:if>
          </xsl:with-param>
          
          <xsl:with-param name="Hdr5">
            <xsl:if test="$NECoords = 'true'"><xsl:value-of select="$eastPrompt"/></xsl:if>
            <xsl:if test="$NECoords != 'true'"><xsl:value-of select="$northPrompt"/></xsl:if>
          </xsl:with-param>

          <xsl:with-param name="Val5">
            <xsl:if test="$NECoords = 'true'">
              <xsl:value-of select="format-number(number(substring-after($Coords, '|')) * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:if>
            <xsl:if test="$NECoords != 'true'">
              <xsl:value-of select="format-number(number(substring-before($Coords, '|')) * $DistConvFactor, $DecPl3, 'Standard')"/>
            </xsl:if>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:if>

      <!-- Locate the traverse adjusted coordinates for the ToPoint following this closure record -->
      <xsl:variable name="Coords">
        <xsl:choose>
          <xsl:when test="position() != last()">
            <xsl:for-each select="following::PointRecord[Name = $ToPt]">
              <xsl:if test="(Method = 'TraverseAdjusted') and
                            (Deleted = 'false')">
                <xsl:value-of select="concat(Grid/North, '|', Grid/East, '|')"/>
              </xsl:if>
            </xsl:for-each>
          </xsl:when>
          <xsl:otherwise>  <!-- This is the closing point so get coords from Reductions section -->
            <xsl:for-each select="/JOBFile/Reductions/Point">
              <xsl:if test="Name = $ToPt">
                <xsl:value-of select="concat(Grid/North, '|', Grid/East, '|')"/>
              </xsl:if>
            </xsl:for-each>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

      <xsl:call-template name="OutputTableLine">
        <xsl:with-param name="Hdr1">Nokta</xsl:with-param>
        <xsl:with-param name="Val1" select="ToPoint"/>

        <xsl:with-param name="Hdr2">Semt A.</xsl:with-param>
        <xsl:with-param name="Val2">
          <xsl:call-template name="FormatAzimuth">
            <xsl:with-param name="theAzimuth" select="Polar/Azimuth"/>
            <xsl:with-param name="northLbl">K</xsl:with-param>
            <xsl:with-param name="eastLbl">S</xsl:with-param>
            <xsl:with-param name="southLbl">G</xsl:with-param>
            <xsl:with-param name="westLbl">B</xsl:with-param>
          </xsl:call-template>
        </xsl:with-param>

        <xsl:with-param name="Hdr3">YM</xsl:with-param>
        <xsl:with-param name="Val3" select="format-number(Polar/HorizontalDistance * $DistConvFactor, $DecPl3, 'Standard')"/>

        <xsl:with-param name="Hdr4">
          <xsl:if test="$NECoords = 'true'"><xsl:value-of select="$northPrompt"/></xsl:if>
          <xsl:if test="$NECoords != 'true'"><xsl:value-of select="$eastPrompt"/></xsl:if>
        </xsl:with-param>

        <xsl:with-param name="Val4">
          <xsl:if test="$NECoords = 'true'">
            <xsl:value-of select="format-number(number(substring-before($Coords, '|')) * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:if>
          <xsl:if test="$NECoords != 'true'">
            <xsl:variable name="Temp" select="substring-after($Coords, '|')"/>
            <xsl:value-of select="format-number(number(substring-before($Temp, '|')) * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:if>
        </xsl:with-param>
          
        <xsl:with-param name="Hdr5">
          <xsl:if test="$NECoords = 'true'"><xsl:value-of select="$eastPrompt"/></xsl:if>
          <xsl:if test="$NECoords != 'true'"><xsl:value-of select="$northPrompt"/></xsl:if>
        </xsl:with-param>

        <xsl:with-param name="Val5">
          <xsl:if test="$NECoords = 'true'">
            <xsl:variable name="Temp" select="substring-after($Coords, '|')"/>
            <xsl:value-of select="format-number(number(substring-before($Temp, '|')) * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:if>
          <xsl:if test="$NECoords != 'true'">
            <xsl:value-of select="format-number(number(substring-before($Coords, '|')) * $DistConvFactor, $DecPl3, 'Standard')"/>
          </xsl:if>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:for-each>
    <xsl:call-template name="EndTable"/>
  </xsl:if>

  <!-- Now output the closure details -->
  <xsl:call-template name="StartTable"/>
    <caption align="top">
      <p align="left"><xsl:text>Poligon Kapama Detayları: </xsl:text><xsl:value-of select="$TraverseName"/></p>
    </caption>
    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Dengeleme durumu</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:if test="ClosureStatus[.='NotAdjusted']">Dengelenmemiş</xsl:if>
        <xsl:if test="ClosureStatus[.='Closed']">Kapandı</xsl:if>
        <xsl:if test="ClosureStatus[.='Adjusted']">
          <xsl:text>Dengelenmiş</xsl:text><xsl:value-of select="concat(' (', $AdjMethod, ')')"/>
        </xsl:if>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Açısal kapanma</xsl:with-param>
      <xsl:with-param name="Val">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="AzimuthMisclose"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Kenar kapaması</xsl:with-param>
      <xsl:with-param name="Val" select="format-number(DistanceMisclose * $DistConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Poligon boyu</xsl:with-param>
      <xsl:with-param name="Val" select="format-number(TraverseLength * $DistConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr">Presizyon</xsl:with-param>
      <xsl:with-param name="Val" select="concat('1 : ', format-number(Precision, $DecPl1, 'Standard'))"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr" select="$dNorthPrompt"/>
      <xsl:with-param name="Val" select="format-number(DeltaNorth * $DistConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>

    <xsl:call-template name="OutputSingleElementTableLine">
      <xsl:with-param name="Hdr" select="$dEastPrompt"/>
      <xsl:with-param name="Val" select="format-number(DeltaEast * $DistConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>

    <xsl:if test="DeltaElevation != ''">
      <xsl:call-template name="OutputSingleElementTableLine">
        <xsl:with-param name="Hdr" select="$dElevPrompt"/>
        <xsl:with-param name="Val" select="format-number(DeltaElevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
      </xsl:call-template>
    </xsl:if>

  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>

</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** COGO Transformation Output ****************** -->
<!-- **************************************************************** -->
<xsl:template match="CogoTransformationRecord">

  <xsl:call-template name="StartTable"/>
  <caption align="top">
    <p align="left">
    <xsl:text>Transformasyonlar: (Dönüştürülen noktalar: </xsl:text>
    <xsl:value-of select="concat(NumberOfPointsTransformed, ')')"/>
    </p>
  </caption>
  <xsl:if test="Rotation">
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Dönme</xsl:with-param>
      <xsl:with-param name="Val1">Orijin=</xsl:with-param>

      <xsl:with-param name="Hdr2">Nokta</xsl:with-param>
      <xsl:with-param name="Val2" select="Rotation/RotationOriginPoint"/>
      
      <xsl:with-param name="Hdr3">
        <xsl:if test="$NECoords = 'true'"><xsl:value-of select="$northPrompt"/></xsl:if>
        <xsl:if test="$NECoords != 'true'"><xsl:value-of select="$eastPrompt"/></xsl:if>
      </xsl:with-param>

      <xsl:with-param name="Val3">
        <xsl:if test="$NECoords = 'true'">
          <xsl:value-of select="format-number(Rotation/RotationOriginGrid/North * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:if>
        <xsl:if test="$NECoords != 'true'">
          <xsl:value-of select="format-number(Rotation/RotationOriginGrid/East * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:if>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">
        <xsl:if test="$NECoords = 'true'"><xsl:value-of select="$eastPrompt"/></xsl:if>
        <xsl:if test="$NECoords != 'true'"><xsl:value-of select="$northPrompt"/></xsl:if>
      </xsl:with-param>

      <xsl:with-param name="Val4">
        <xsl:if test="$NECoords = 'true'">
          <xsl:value-of select="format-number(Rotation/RotationOriginGrid/East * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:if>
        <xsl:if test="$NECoords != 'true'">
          <xsl:value-of select="format-number(Rotation/RotationOriginGrid/North * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:if>
      </xsl:with-param>

      <xsl:with-param name="Hdr5" select="$elevPrompt"/>
      <xsl:with-param name="Val5" select="format-number(Rotation/RotationOriginGrid/Elevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Dönme</xsl:with-param>

      <xsl:with-param name="Hdr2">Açı</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="Rotation/RotationAngle"/>
        </xsl:call-template>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:if>
  
  <xsl:if test="Scale">
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Ölçek</xsl:with-param>
      <xsl:with-param name="Val1">Orijin=</xsl:with-param>

      <xsl:with-param name="Hdr2">Nokta</xsl:with-param>
      <xsl:with-param name="Val2" select="Scale/ScaleOriginPoint"/>

      <xsl:with-param name="Hdr3">
        <xsl:if test="$NECoords = 'true'"><xsl:value-of select="$northPrompt"/></xsl:if>
        <xsl:if test="$NECoords != 'true'"><xsl:value-of select="$eastPrompt"/></xsl:if>
      </xsl:with-param>

      <xsl:with-param name="Val3">
        <xsl:if test="$NECoords = 'true'">
          <xsl:value-of select="format-number(Scale/ScaleOriginGrid/North * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:if>
        <xsl:if test="$NECoords != 'true'">
          <xsl:value-of select="format-number(Scale/ScaleOriginGrid/East * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:if>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">
        <xsl:if test="$NECoords = 'true'"><xsl:value-of select="$eastPrompt"/></xsl:if>
        <xsl:if test="$NECoords != 'true'"><xsl:value-of select="$northPrompt"/></xsl:if>
      </xsl:with-param>

      <xsl:with-param name="Val4">
        <xsl:if test="$NECoords = 'true'">
          <xsl:value-of select="format-number(Scale/ScaleOriginGrid/East * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:if>
        <xsl:if test="$NECoords != 'true'">
          <xsl:value-of select="format-number(Scale/ScaleOriginGrid/North * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:if>
      </xsl:with-param>

      <xsl:with-param name="Hdr5" select="$elevPrompt"/>
      <xsl:with-param name="Val5" select="format-number(Scale/ScaleOriginGrid/Elevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Ölçek</xsl:with-param>

      <xsl:with-param name="Hdr2">Ölçek faktörü</xsl:with-param>
      <xsl:with-param name="Val2" select="format-number(Scale/ScaleFactor, $DecPl8, 'Standard')"/>
    </xsl:call-template>
  </xsl:if>

  <xsl:if test="Translation">
    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">Öteleme</xsl:with-param>
      <xsl:with-param name="Val1">Deltalar</xsl:with-param>

      <xsl:with-param name="Hdr2">Tanım</xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:if test="Translation/TranslationDefinitionMethod[.='EnteredDeltas']">Girilen veri</xsl:if>
        <xsl:if test="Translation/TranslationDefinitionMethod[.='TwoPoints']">İki nokta</xsl:if>
      </xsl:with-param>

      <xsl:with-param name="Hdr3">
        <xsl:if test="$NECoords = 'true'"><xsl:value-of select="$dNorthPrompt"/></xsl:if>
        <xsl:if test="$NECoords != 'true'"><xsl:value-of select="$dEastPrompt"/></xsl:if>
      </xsl:with-param>

      <xsl:with-param name="Val3">
        <xsl:if test="$NECoords = 'true'">
          <xsl:value-of select="format-number(Translation/TranslationDeltas/DeltaNorth * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:if>
        <xsl:if test="$NECoords != 'true'">
          <xsl:value-of select="format-number(Translation/TranslationDeltas/DeltaEast * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:if>
      </xsl:with-param>

      <xsl:with-param name="Hdr4">
        <xsl:if test="$NECoords = 'true'"><xsl:value-of select="$dEastPrompt"/></xsl:if>
        <xsl:if test="$NECoords != 'true'"><xsl:value-of select="$dNorthPrompt"/></xsl:if>
      </xsl:with-param>

      <xsl:with-param name="Val4">
        <xsl:if test="$NECoords = 'true'">
          <xsl:value-of select="format-number(Translation/TranslationDeltas/DeltaEast * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:if>
        <xsl:if test="$NECoords != 'true'">
          <xsl:value-of select="format-number(Translation/TranslationDeltas/DeltaNorth * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:if>
      </xsl:with-param>

      <xsl:with-param name="Hdr5" select="$dElevPrompt"/>
      <xsl:with-param name="Val5" select="format-number(Translation/TranslationDeltas/DeltaElevation * $ElevConvFactor, $DecPl3, 'Standard')"/>
    </xsl:call-template>

    <xsl:if test="Translation/TranslationDefinitionMethod[.='TwoPoints']">
      <xsl:call-template name="OutputTableLine">
        <xsl:with-param name="Hdr1">Öteleme</xsl:with-param>

        <xsl:with-param name="Hdr2">Noktalar</xsl:with-param>

        <xsl:with-param name="Hdr3">Noktadan</xsl:with-param>
        <xsl:with-param name="Val3" select="Translation/TranslationFromPoint"/>

        <xsl:with-param name="Hdr4">Noktaya</xsl:with-param>
        <xsl:with-param name="Val4" select="Translation/TranslationToPoint"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:if>

  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>

</xsl:template>


<!-- **************************************************************** -->
<!-- ************* Return an area value string with units *********** -->
<!-- **************************************************************** -->
<xsl:template name="AreaValueString">
  <xsl:param name="area"/>
  
  <xsl:variable name="areaVal" select="$area * $AreaConvFactor"/>
  
  <xsl:choose>
    <xsl:when test="$AreaUnit = 'SquareMetres'">
      <xsl:value-of select="format-number($areaVal, $DecPl2, 'Standard')"/>
      <xsl:text>m²</xsl:text>
    </xsl:when>
    <xsl:when test="$AreaUnit = 'SquareMiles'">
      <xsl:value-of select="format-number($areaVal, $DecPl5, 'Standard')"/>
      <xsl:text>mi²</xsl:text>
    </xsl:when>
    <xsl:when test="$AreaUnit = 'SquareFeet'">
      <xsl:value-of select="format-number($areaVal, $DecPl2, 'Standard')"/>
      <xsl:text>ift²</xsl:text>
    </xsl:when>
    <xsl:when test="$AreaUnit = 'SquareUSSurveyFeet'">
      <xsl:value-of select="format-number($areaVal, $DecPl2, 'Standard')"/>
      <xsl:text>sft²</xsl:text>
    </xsl:when>
    <xsl:when test="$AreaUnit = 'Acres'">
      <xsl:value-of select="format-number($areaVal, $DecPl4, 'Standard')"/>
      <xsl:text>A</xsl:text>
    </xsl:when>
    <xsl:when test="$AreaUnit = 'Hectares'">
      <xsl:value-of select="format-number($areaVal, $DecPl4, 'Standard')"/>
      <xsl:text>YA</xsl:text>
    </xsl:when>
  </xsl:choose>
  
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Compute Area Record Output ****************** -->
<!-- **************************************************************** -->
<xsl:template name="OutputAreaDetails">
  <xsl:call-template name="BlankLine"/>
  <xsl:call-template name="StartTable"/>
  <caption align="top">
    <p align="left">
    <xsl:choose>
      <xsl:when test="name(.) = 'SubdivideAreaRecord'">Alan bölme</xsl:when>
      <xsl:otherwise>Alan hesabı</xsl:otherwise>
    </xsl:choose>
    </p>
  </caption>

    <xsl:call-template name="OutputTableLine">
      <xsl:with-param name="Hdr1">İsim</xsl:with-param>
      <xsl:with-param name="Val1">
        <xsl:value-of select="Name"/>
      </xsl:with-param>
      <xsl:with-param name="Hdr2">
        <xsl:choose>
          <xsl:when test="DistanceType = 'Grid'">Alan (grid)</xsl:when>
          <xsl:when test="DistanceType = 'Ground'">Alan (yersel)</xsl:when>
          <xsl:when test="DistanceType = 'Ellipsoid'">Alan (elip)</xsl:when>
        </xsl:choose>
      </xsl:with-param>
      <xsl:with-param name="Val2">
        <xsl:call-template name="AreaValueString">
          <xsl:with-param name="area" select="Area"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="Hdr3">Perimetre</xsl:with-param>
      <xsl:with-param name="Val3">
        <xsl:value-of select="format-number(Perimeter * $DistConvFactor, $DecPl3, 'Standard')"/>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:if test="name(.) = 'SubdivideAreaRecord'">
      <xsl:call-template name="OutputTableLine">
        <xsl:with-param name="Hdr2">
          <xsl:choose>
            <xsl:when test="DistanceType = 'Grid'">Yeni alan (grid)</xsl:when>
            <xsl:when test="DistanceType = 'Ground'">Yeni alan (yersel)</xsl:when>
            <xsl:when test="DistanceType = 'Ellipsoid'">Yeni alan (elip)</xsl:when>
          </xsl:choose>
        </xsl:with-param>
        <xsl:with-param name="Val2">
          <xsl:call-template name="AreaValueString">
            <xsl:with-param name="area" select="SubArea"/>
          </xsl:call-template>
        </xsl:with-param>
        <xsl:with-param name="Hdr3">Yeni perimetre</xsl:with-param>
        <xsl:with-param name="Val3">
          <xsl:value-of select="format-number(SubPerimeter * $DistConvFactor, $DecPl3, 'Standard')"/>
        </xsl:with-param>
      </xsl:call-template>
      <xsl:for-each select="CreatedPoints/Item">
        <xsl:variable name="ptName"    select="."/>
        <xsl:variable name="north"     select="/JOBFile/Reductions/Point[Name = $ptName]/Grid/North"/>
        <xsl:variable name="east"      select="/JOBFile/Reductions/Point[Name = $ptName]/Grid/East"/>
        <xsl:variable name="elevation" select="/JOBFile/Reductions/Point[Name = $ptName]/Grid/Elevation"/>
        <xsl:variable name="code"      select="/JOBFile/Reductions/Point[Name = $ptName]/Code"/>

        <xsl:call-template name="OutputTableLine">
          <xsl:with-param name="Hdr1">Yeni nokta</xsl:with-param>
          <xsl:with-param name="Val1">
            <xsl:value-of select="."/>
          </xsl:with-param>

          <xsl:with-param name="Hdr2">
            <xsl:choose>
              <xsl:when test="$NECoords = 'true'"><xsl:value-of select="$northPrompt"/></xsl:when>
              <xsl:otherwise><xsl:value-of select="$eastPrompt"/></xsl:otherwise>
            </xsl:choose>
          </xsl:with-param>
          <xsl:with-param name="Val2">
            <xsl:choose>
              <xsl:when test="$NECoords = 'true'">
                <xsl:value-of select="format-number($north * $DistConvFactor, $DecPl3, 'Standard')"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="format-number($east * $DistConvFactor, $DecPl3, 'Standard')"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:with-param>

          <xsl:with-param name="Hdr3">
            <xsl:choose>
              <xsl:when test="$NECoords = 'true'"><xsl:value-of select="$eastPrompt"/></xsl:when>
              <xsl:otherwise><xsl:value-of select="$northPrompt"/></xsl:otherwise>
            </xsl:choose>
          </xsl:with-param>
          <xsl:with-param name="Val3">
            <xsl:choose>
              <xsl:when test="$NECoords = 'true'">
                <xsl:value-of select="format-number($east * $DistConvFactor, $DecPl3, 'Standard')"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="format-number($north * $DistConvFactor, $DecPl3, 'Standard')"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:with-param>

          <xsl:with-param name="Hdr4" select="$elevPrompt"/>
          <xsl:with-param name="Val4" select="format-number($elevation * $ElevConvFactor, $DecPl3, 'Standard')"/>

          <xsl:with-param name="Hdr5">Kod</xsl:with-param>
          <xsl:with-param name="Val5" select="$code"/>
        </xsl:call-template>
      </xsl:for-each>
    </xsl:if>

  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Compute Area Record Output ****************** -->
<!-- **************************************************************** -->
<xsl:template match="ComputeAreaRecord">
  <xsl:call-template name="OutputAreaDetails"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** Subdivide Area Record Output ***************** -->
<!-- **************************************************************** -->
<xsl:template match="SubdivideAreaRecord">
  <xsl:call-template name="OutputAreaDetails"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- *************** Volume Computation Record Output *************** -->
<!-- **************************************************************** -->
<xsl:template match="VolumeRecord">

  <xsl:call-template name="OutputVolumeHeadings"/>

  <xsl:choose>
    <xsl:when test="AdjustedVolumeResults">
      <xsl:call-template name="OutputAdjustedVolumesTable"/>
    </xsl:when>

    <xsl:otherwise>
      <xsl:call-template name="OutputRawVolumesTable"/>
    </xsl:otherwise>
  </xsl:choose>

  <xsl:call-template name="OutputBulkageShrinkageValues"/>

  <xsl:if test="AdjustedVolumeResults">
    <xsl:call-template name="OutputRawVolumesTable"/>
  </xsl:if>

  <xsl:call-template name="OutputAreaValues"/>
  <xsl:call-template name="SeparatingLine"/>

</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** Output volume headings table ***************** -->
<!-- **************************************************************** -->
<xsl:template name="OutputVolumeHeadings">

  <xsl:call-template name="BlankLine"/>
  <xsl:call-template name="StartTable"/>
  <caption align="top"><p align="left">Hacim</p></caption>
    <tr>
      <th align="left" width="25%">Metod</th>
      <td align="left" width="75%">
        <xsl:call-template name="VolumeMethod">
          <xsl:with-param name="method" select="VolumeMethod"/>
        </xsl:call-template>
      </td>
    </tr>

    <xsl:choose>
      <xsl:when test="VolumeMethod = 'AboveAnElevation'">
        <tr>
          <th align="left" width="25%">Yüzey</th>
          <td align="left" width="75%">
            <xsl:value-of select="substring(SurfaceFileName, 1, string-length(SurfaceFileName) - 4)"/>
          </td>
        </tr>
        <tr>
          <th align="left" width="25%">Kot</th>
          <td align="left" width="75%">
            <xsl:value-of select="format-number(ReferenceElevation * $DistConvFactor, $DecPl3, 'Standard')"/>
          </td>
        </tr>
      </xsl:when>

      <xsl:when test="VolumeMethod = 'VoidVolume'">
        <tr>
          <th align="left" width="25%">Yüzey</th>
          <td align="left" width="75%">
            <xsl:value-of select="substring(SurfaceFileName, 1, string-length(SurfaceFileName) - 4)"/>
          </td>
        </tr>
        <tr>
          <th align="left" width="25%">Kot</th>
          <td align="left" width="75%">
            <xsl:value-of select="format-number(ReferenceElevation * $DistConvFactor, $DecPl3, 'Standard')"/>
          </td>
        </tr>
      </xsl:when>

      <xsl:when test="VolumeMethod = 'SurfaceToElevation'">
        <tr>
          <th align="left" width="25%">Yüzey</th>
          <td align="left" width="75%">
            <xsl:value-of select="substring(SurfaceFileName, 1, string-length(SurfaceFileName) - 4)"/>
          </td>
        </tr>
        <tr>
          <th align="left" width="25%">Kot</th>
          <td align="left" width="75%">
            <xsl:value-of select="format-number(ReferenceElevation * $DistConvFactor, $DecPl3, 'Standard')"/>
          </td>
        </tr>
      </xsl:when>

      <xsl:when test="VolumeMethod = 'SurfaceToSurface'">
        <tr>
          <th align="left" width="25%">Baz yüzey</th>
          <td align="left" width="75%">
            <xsl:value-of select="substring(BaseSurfaceFileName, 1, string-length(BaseSurfaceFileName) - 4)"/>
          </td>
        </tr>
        <tr>
          <th align="left" width="25%">Son yüzey</th>
          <td align="left" width="75%">
            <xsl:value-of select="substring(SurfaceFileName, 1, string-length(SurfaceFileName) - 4)"/>
          </td>
        </tr>
      </xsl:when>

      <xsl:when test="VolumeMethod = 'StockpileDepression'">
        <tr>
          <th align="left" width="25%">Yüzey</th>
          <td align="left" width="75%">
            <xsl:value-of select="substring(SurfaceFileName, 1, string-length(SurfaceFileName) - 4)"/>
          </td>
        </tr>
      </xsl:when>
    </xsl:choose>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ********* Return the volume method as a nice string ************ -->
<!-- **************************************************************** -->
<xsl:template name="VolumeMethod">
  <xsl:param name="method"/>

  <xsl:choose>
    <xsl:when test="$method = 'AboveAnElevation'">Kot'un üstünde</xsl:when>
    <xsl:when test="$method = 'VoidVolume'">Boş kübaj</xsl:when>
    <xsl:when test="$method = 'SurfaceToElevation'">Yüzey'den kot'a</xsl:when>
    <xsl:when test="$method = 'SurfaceToSurface'">Yüzey'den yüzey'e</xsl:when>
    <xsl:when test="$method = 'StockpileDepression'">İstif / çöküntü</xsl:when>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- **************** Output adjusted volumes table ***************** -->
<!-- **************************************************************** -->
<xsl:template name="OutputAdjustedVolumesTable">

  <xsl:call-template name="StartTable"/>
  <caption align="top"><p align="left">Düzeltilmiş kübaj</p></caption>
    <tr>
      <xsl:choose>
        <!-- Adjusted cut and fill volumes available -->
        <xsl:when test="(string(number(AdjustedVolumeResults/CutVolume)) != 'NaN') and
                        (string(number(AdjustedVolumeResults/FillVolume)) != 'NaN')">
          <th align="left" width="25%">Dengelenmiş kazı hacmi</th>
          <td align="right" width="25%">
            <xsl:call-template name="VolumeValueString">
              <xsl:with-param name="volume" select="AdjustedVolumeResults/CutVolume"/>
            </xsl:call-template>
          </td>
          <th align="left" width="25%">Düzeltilmiş dolgu hacmi</th>
          <td align="right" width="25%">
            <xsl:call-template name="VolumeValueString">
              <xsl:with-param name="volume" select="AdjustedVolumeResults/FillVolume"/>
            </xsl:call-template>
          </td>
        </xsl:when>
        <!-- Only adjusted cut volume available -->
        <xsl:when test="(string(number(AdjustedVolumeResults/CutVolume)) != 'NaN') and
                        (string(number(AdjustedVolumeResults/FillVolume)) = 'NaN')">
          <th align="left" width="25%">Dengelenmiş kazı hacmi</th>
          <td align="right" width="25%">
            <xsl:call-template name="VolumeValueString">
              <xsl:with-param name="volume" select="AdjustedVolumeResults/CutVolume"/>
            </xsl:call-template>
          </td>
          <td colspan="2">&#160;</td>
        </xsl:when>
        <!-- Only adjusted fill volume available -->
        <xsl:when test="(string(number(AdjustedVolumeResults/CutVolume)) = 'NaN') and
                        (string(number(AdjustedVolumeResults/FillVolume)) != 'NaN')">
          <th align="left" width="25%">Düzeltilmiş dolgu hacmi</th>
          <td align="right" width="25%">
            <xsl:call-template name="VolumeValueString">
              <xsl:with-param name="volume" select="AdjustedVolumeResults/FillVolume"/>
            </xsl:call-template>
          </td>
          <td colspan="2">&#160;</td>
        </xsl:when>
      </xsl:choose>
    </tr>
    <xsl:if test="string(number(AdjustedVolumeResults/CutFillBalance)) != 'NaN'">
      <tr>
        <th align="left" width="25%">Dengelenmiş kazı/dolgu oranı</th>
        <td align="right" width="25%">
          <xsl:call-template name="VolumeValueString">
            <xsl:with-param name="volume" select="AdjustedVolumeResults/CutFillBalance"/>
          </xsl:call-template>
        </td>
        <td colspan="2">&#160;</td>
      </tr>
    </xsl:if>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************** Output raw volumes table ****************** -->
<!-- **************************************************************** -->
<xsl:template name="OutputRawVolumesTable">

  <xsl:call-template name="StartTable"/>
  <caption align="top"><p align="left">Mevcut kübaj</p></caption>
    <tr>
      <xsl:choose>
        <!-- Cut and fill volumes available -->
        <xsl:when test="(string(number(VolumeResults/CutVolume)) != 'NaN') and
                        (string(number(VolumeResults/FillVolume)) != 'NaN')">
          <th align="left" width="25%">Kazı hacmi</th>
          <td align="right" width="25%">
            <xsl:call-template name="VolumeValueString">
              <xsl:with-param name="volume" select="VolumeResults/CutVolume"/>
            </xsl:call-template>
          </td>
          <th align="left" width="25%">Dolgu hacmi</th>
          <td align="right" width="25%">
            <xsl:call-template name="VolumeValueString">
              <xsl:with-param name="volume" select="VolumeResults/FillVolume"/>
            </xsl:call-template>
          </td>
        </xsl:when>
        <!-- Only cut volume available -->
        <xsl:when test="(string(number(VolumeResults/CutVolume)) != 'NaN') and
                        (string(number(VolumeResults/FillVolume)) = 'NaN')">
          <th align="left" width="25%">Kazı hacmi</th>
          <td align="right" width="25%">
            <xsl:call-template name="VolumeValueString">
              <xsl:with-param name="volume" select="VolumeResults/CutVolume"/>
            </xsl:call-template>
          </td>
          <td colspan="2">&#160;</td>
        </xsl:when>
        <!-- Only fill volume available -->
        <xsl:when test="(string(number(VolumeResults/CutVolume)) = 'NaN') and
                        (string(number(VolumeResults/FillVolume)) != 'NaN')">
          <th align="left" width="25%">Dolgu hacmi</th>
          <td align="right" width="25%">
            <xsl:call-template name="VolumeValueString">
              <xsl:with-param name="volume" select="VolumeResults/FillVolume"/>
            </xsl:call-template>
          </td>
          <td colspan="2">&#160;</td>
        </xsl:when>
      </xsl:choose>
    </tr>
    <xsl:if test="string(number(VolumeResults/CutFillBalance)) != 'NaN'">
      <tr>
        <th align="left" width="25%">Kazı/dolgu dengesi</th>
        <td align="right" width="25%">
          <xsl:call-template name="VolumeValueString">
            <xsl:with-param name="volume" select="VolumeResults/CutFillBalance"/>
          </xsl:call-template>
        </td>
        <td colspan="2">&#160;</td>
      </tr>
    </xsl:if>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************ Output the bulkage and shrinkage values *********** -->
<!-- **************************************************************** -->
<xsl:template name="OutputBulkageShrinkageValues">

  <xsl:call-template name="StartTable"/>
    <tr>
      <xsl:choose>
        <!-- Cut and fill volumes available - report both bulkage and shrinkage values -->
        <xsl:when test="(string(number(VolumeResults/CutVolume)) != 'NaN') and
                        (string(number(VolumeResults/FillVolume)) != 'NaN')">
          <th align="left" width="25%">Çekme hacmi (kazı)</th>
          <td align="right" width="25%">
            <xsl:value-of select="format-number(HaulBulkagePercentage, $DecPl1, 'Standard')"/>
            <xsl:text>%</xsl:text>
          </td>
          <th align="left" width="25%">Azaltma (dolgu)</th>
          <td align="right" width="25%">
            <xsl:value-of select="format-number(ShrinkagePercentage, $DecPl1, 'Standard')"/>
            <xsl:text>%</xsl:text>
          </td>
        </xsl:when>
        <!-- Only cut volume available - report only bulkage value -->
        <xsl:when test="(string(number(VolumeResults/CutVolume)) != 'NaN') and
                        (string(number(VolumeResults/FillVolume)) = 'NaN')">
          <th align="left" width="25%">Çekme hacmi (kazı)</th>
          <td align="right" width="25%">
            <xsl:value-of select="format-number(HaulBulkagePercentage, $DecPl1, 'Standard')"/>
            <xsl:text>%</xsl:text>
          </td>
          <td colspan="2">&#160;</td>
        </xsl:when>
        <!-- Only fill volume available - report only shrinkage value -->
        <xsl:when test="(string(number(VolumeResults/CutVolume)) = 'NaN') and
                        (string(number(VolumeResults/FillVolume)) != 'NaN')">
          <th align="left" width="25%">Azaltma (dolgu)</th>
          <td align="right" width="25%">
            <xsl:value-of select="format-number(ShrinkagePercentage, $DecPl1, 'Standard')"/>
            <xsl:text>%</xsl:text>
          </td>
          <td colspan="2">&#160;</td>
        </xsl:when>
      </xsl:choose>
    </tr>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************** Output the area values ******************** -->
<!-- **************************************************************** -->
<xsl:template name="OutputAreaValues">

  <xsl:call-template name="StartTable"/>
    <tr>
      <xsl:choose>
        <!-- Cut and fill areas both available -->
        <xsl:when test="(string(number(CutArea)) != 'NaN') and
                        (string(number(FillArea)) != 'NaN')">
          <th align="left" width="25%">Kazı alanı</th>
          <td align="right" width="25%">
            <xsl:call-template name="AreaValueString">
              <xsl:with-param name="area" select="CutArea"/>
            </xsl:call-template>
          </td>
          <th align="left" width="25%">Dolgu alanı</th>
          <td align="right" width="25%">
            <xsl:call-template name="AreaValueString">
              <xsl:with-param name="area" select="FillArea"/>
            </xsl:call-template>
          </td>
        </xsl:when>
        <!-- Only cut area available -->
        <xsl:when test="(string(number(CutArea)) != 'NaN') and
                        (string(number(FillArea)) = 'NaN')">
          <th align="left" width="25%">Kazı alanı</th>
          <td align="right" width="25%">
            <xsl:call-template name="AreaValueString">
              <xsl:with-param name="area" select="CutArea"/>
            </xsl:call-template>
          </td>
          <td colspan="2">&#160;</td>
        </xsl:when>
        <!-- Only fill area available -->
        <xsl:when test="(string(number(CutArea)) = 'NaN') and
                        (string(number(FillArea)) != 'NaN')">
          <th align="left" width="25%">Dolgu alanı</th>
          <td align="right" width="25%">
            <xsl:call-template name="AreaValueString">
              <xsl:with-param name="area" select="FillArea"/>
            </xsl:call-template>
          </td>
          <td colspan="2">&#160;</td>
        </xsl:when>
      </xsl:choose>
    </tr>
  <xsl:call-template name="EndTable"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************ Return a volume value string with units *********** -->
<!-- **************************************************************** -->
<xsl:template name="VolumeValueString">
  <xsl:param name="volume"/>

  <xsl:variable name="volumeVal" select="$volume * $VolConvFactor"/>

  <xsl:choose>
    <xsl:when test="$VolumeUnit = 'CubicMetres'">
      <xsl:value-of select="format-number($volumeVal, $DecPl2, 'Standard')"/>
      <xsl:text>m&#0179;</xsl:text>
    </xsl:when>
    <xsl:when test="$VolumeUnit = 'CubicFeet'">
      <xsl:value-of select="format-number($volumeVal, $DecPl2, 'Standard')"/>
      <xsl:text>ft&#0179;</xsl:text>
    </xsl:when>
    <xsl:when test="$VolumeUnit = 'CubicUSSurveyFeet'">
      <xsl:value-of select="format-number($volumeVal, $DecPl2, 'Standard')"/>
      <xsl:text>sft&#0179;</xsl:text>
    </xsl:when>
    <xsl:when test="$VolumeUnit = 'CubicYards'">
      <xsl:value-of select="format-number($volumeVal, $DecPl2, 'Standard')"/>
      <xsl:text>yds&#0179;</xsl:text>
    </xsl:when>
    <xsl:when test="$VolumeUnit = 'CubicUSSurveyYards'">
      <xsl:value-of select="format-number($volumeVal, $DecPl4, 'Standard')"/>
      <xsl:text>yds&#0179;</xsl:text>
    </xsl:when>
    <xsl:when test="$VolumeUnit = 'AcreFeet'">
        <xsl:value-of select="format-number($volumeVal, $DecPl5, 'Standard')"/>
        <xsl:text>ac-ft</xsl:text>
    </xsl:when>
    <xsl:when test="$VolumeUnit = 'USAcreFeet'">
        <xsl:value-of select="format-number($volumeVal, $DecPl5, 'Standard')"/>
        <xsl:text>USac-ft</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="format-number($volumeVal, $DecPl2, 'Standard')"/>
      <xsl:text>m&#0179;</xsl:text>
    </xsl:otherwise>
  </xsl:choose>

</xsl:template>


<!-- **************************************************************** -->
<!-- ************ Tilt Sensor Calibration Record Output ************* -->
<!-- **************************************************************** -->
<xsl:template match="TiltSensorCalibrationRecord">

  <xsl:call-template name="StartTable"/>
  <caption align="top"><p align="left">Düzeç kalibrasyonu durumu</p></caption>
    <tr>
      <th align="left">Etkinlik</th>
      <td>
        <xsl:choose>
          <xsl:when test="TiltEvent = 'Calibration'">Kalibrasyon</xsl:when>
          <xsl:otherwise>Ölçü başlama</xsl:otherwise>
        </xsl:choose>
      </td>

      <th align="left">Kalibrasyon bitişi</th>
      <td>
        <xsl:choose>
          <xsl:when test="string(number(CalibrationTimeRemaining)) != 'NaN'">
            <xsl:variable name="days" select="floor(CalibrationTimeRemaining div 3600 div 24)"/>
            <xsl:variable name="hours" select="(CalibrationTimeRemaining - $days * 3600 * 24) div 3600"/>
            <xsl:choose>
              <xsl:when test="$days &gt; 0">
                <xsl:value-of select="$days"/>
                <xsl:text>d </xsl:text>
                <xsl:value-of select="format-number($hours, $DecPl0, 'Standard')"/>
                <xsl:text>s</xsl:text>
              </xsl:when>
            </xsl:choose>
          </xsl:when>
          <xsl:otherwise>&#160;&#160;-</xsl:otherwise>
        </xsl:choose>
      </td>

      <th align="left">Kalibrasyon yaş limiti</th>
      <td>
        <xsl:choose>
          <xsl:when test="string(number(CalibrationTimeoutPeriod)) != 'NaN'">
            <xsl:variable name="days" select="floor(CalibrationTimeoutPeriod div 3600 div 24)"/>
            <xsl:variable name="hours" select="(CalibrationTimeoutPeriod - $days * 3600 * 24) div 3600"/>
            <xsl:choose>
              <xsl:when test="$days &gt; 0">
                <xsl:value-of select="$days"/>
                <xsl:text>d </xsl:text>
                <xsl:value-of select="format-number($hours, $DecPl0, 'Standard')"/>
                <xsl:text>s</xsl:text>
              </xsl:when>
            </xsl:choose>
          </xsl:when>
          <xsl:otherwise>&#160;&#160;-</xsl:otherwise>
        </xsl:choose>
      </td>

      <th align="left">Sensör kalibrasyon durumu</th>
      <td>
        <xsl:choose>
          <xsl:when test="SensorStatus = 'NotInitialised'">Düzeç başlatılmadı</xsl:when>
          <xsl:when test="SensorStatus = 'Faulty'">Düzeç sensörü arızalı</xsl:when>
          <xsl:when test="SensorStatus = 'NotCalibrated'">Düzeç kalibre edilmedi</xsl:when>
          <xsl:when test="SensorStatus = 'CalibratedOk'">Düzeç kalibre edildi</xsl:when>
          <xsl:when test="SensorStatus = 'Cancelled'">Kullanıcı iptal etti</xsl:when>
          <xsl:when test="SensorStatus = 'CalibrationFailed'">Düzeç kalibrasyonu başarısız</xsl:when>
          <xsl:when test="SensorStatus = 'CalibrationExpired'">Düzeç kalibrasyonu yenilenmeli</xsl:when>
          <xsl:when test="SensorStatus = 'StateUnrecognized'">Düzeç durumu anlaşılmıyor</xsl:when>
        </xsl:choose>
      </td>
    </tr>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** SBAS Offset Record Output ******************* -->
<!-- **************************************************************** -->
<xsl:template match="SBASOffsetRecord">

  <xsl:call-template name="StartTable"/>
  <caption align="top"><p align="left">OmniSTAR Ofset</p></caption>
    <tr>
      <th align="left">Baz</th>
      <td>
        <xsl:value-of select="BasePoint"/>
      </td>

      <th align="left">Gezici</th>
      <td>
        <xsl:value-of select="RoverPoint"/>
      </td>

      <th align="left">Tarih/Süre</th>
      <td>
        <xsl:call-template name="FormattedDateString">
          <xsl:with-param name="date" select="substring-before(Date, 'T')"/>
        </xsl:call-template>
        <xsl:value-of select="' '"/>
        <xsl:value-of select="substring-after(Date, 'T')"/>
      </td>

      <th align="left">Not</th>
      <td>
        <xsl:value-of select="ObservationNote"/>
      </td>
    </tr>
    
    <tr>
      <th align="left">σ Kuzey</th>
      <td align="right">
        <xsl:value-of select="format-number(SigmaNorth * $DistConvFactor, $DecPl3, 'Standard')"/>
      </td>
      
      <th align="left">σ Doğu</th>
      <td align="right">
        <xsl:value-of select="format-number(SigmaEast * $DistConvFactor, $DecPl3, 'Standard')"/>
      </td>

      <th align="left">σ Kot</th>
      <td align="right">
        <xsl:value-of select="format-number(SigmaElevation * $DistConvFactor, $DecPl3, 'Standard')"/>
      </td>

      <th>&#160;</th>
      <td>&#160;</td>
    </tr>
    
    <tr>
      <th align="left">Δ Enlem</th>
      <td align="right">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="DeltaLatitude"/>
          <xsl:with-param name="secDecPlaces">4</xsl:with-param>
        </xsl:call-template>
      </td>

      <th align="left">Δ Boylam</th>
      <td align="right">
        <xsl:call-template name="FormatAngle">
          <xsl:with-param name="theAngle" select="DeltaLongitude"/>
          <xsl:with-param name="secDecPlaces">4</xsl:with-param>
        </xsl:call-template>
      </td>

      <th align="left">Δ Yükseklik</th>
      <td align="right">
        <xsl:value-of select="format-number(DeltaHeight * $DistConvFactor, $DecPl3, 'Standard')"/>
      </td>

      <th>&#160;</th>
      <td>&#160;</td>
    </tr>
  <xsl:call-template name="EndTable"/>
  <xsl:call-template name="SeparatingLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** Create Formatted Date String ***************** -->
<!-- **************************************************************** -->
<xsl:template name="FormattedDateString">
  <xsl:param name="date"/>

  <xsl:variable name="month" select="substring($date, 6, 2)"/>

  <xsl:variable name="namedMonth">
    <xsl:choose>
      <xsl:when test="number($month) = 1">Jan</xsl:when>
      <xsl:when test="number($month) = 2">Feb</xsl:when>
      <xsl:when test="number($month) = 3">Mar</xsl:when>
      <xsl:when test="number($month) = 4">Apr</xsl:when>
      <xsl:when test="number($month) = 5">May</xsl:when>
      <xsl:when test="number($month) = 6">Jun</xsl:when>
      <xsl:when test="number($month) = 7">Jul</xsl:when>
      <xsl:when test="number($month) = 8">Aug</xsl:when>
      <xsl:when test="number($month) = 9">Sep</xsl:when>
      <xsl:when test="number($month) = 10">Oct</xsl:when>
      <xsl:when test="number($month) = 11">Nov</xsl:when>
      <xsl:when test="number($month) = 12">Dec</xsl:when>
    </xsl:choose>
  </xsl:variable>

  <xsl:choose>
    <xsl:when test="substring($date, 9, 1) = '0'">
      <xsl:value-of select="substring($date, 10, 1)"/>  <!-- Skip leading 0 -->
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="substring($date, 9, 2)"/>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:value-of select="' '"/>
  <xsl:value-of select="$namedMonth"/>
  <xsl:value-of select="' '"/>
  <xsl:value-of select="substring($date, 1, 4)"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Reductions Point Output ********************* -->
<!-- **************************************************************** -->
<xsl:template match="Point">
  <xsl:call-template name="GridPoint">
    <xsl:with-param name="reductionsPoint" select="'true'"/>
  </xsl:call-template>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Separating Line Output ********************** -->
<!-- **************************************************************** -->
<xsl:template name="SeparatingLine">
  <xsl:choose>
    <xsl:when test="$IncludeBorders != $YesStr">  <!-- Only include separating lines -->
      <hr></hr>                                   <!-- if there are no table borders -->
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="BlankLine"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************************ Output Table Line ********************* -->
<!-- **************************************************************** -->
<xsl:template name="OutputTableLine">
  <xsl:param name="Hdr1" select="''"/>
  <xsl:param name="Val1" select="''"/>
  <xsl:param name="Hdr2" select="''"/>
  <xsl:param name="Val2" select="''"/>
  <xsl:param name="Hdr3" select="''"/>
  <xsl:param name="Val3" select="''"/>
  <xsl:param name="Hdr4" select="''"/>
  <xsl:param name="Val4" select="''"/>
  <xsl:param name="Hdr5" select="''"/>
  <xsl:param name="Val5" select="''"/>

  <tr>
    <th width="9%" align="left"><xsl:value-of select="$Hdr1"/></th>
    <td width="11%" align="right"><xsl:value-of select="$Val1"/></td>
    <th width="9%" align="left"><xsl:value-of select="$Hdr2"/></th>
    <td width="11%" align="right"><xsl:value-of select="$Val2"/></td>
    <th width="9%" align="left"><xsl:value-of select="$Hdr3"/></th>
    <td width="11%" align="right"><xsl:value-of select="$Val3"/></td>
    <th width="9%" align="left"><xsl:value-of select="$Hdr4"/></th>
    <td width="11%" align="right"><xsl:value-of select="$Val4"/></td>
    <th width="9%" align="left"><xsl:value-of select="$Hdr5"/></th>
    <td width="11%" align="right"><xsl:value-of select="$Val5"/></td>
  </tr>
  
</xsl:template>


<!-- **************************************************************** -->
<!-- ************** Output Single Element Table Line **************** -->
<!-- **************************************************************** -->
<xsl:template name="OutputSingleElementTableLine">
  <xsl:param name="Hdr" select="''"/>
  <xsl:param name="Val" select="''"/>

  <tr>
    <th width="20%" align="left"><xsl:value-of select="$Hdr"/></th>
    <td width="80%" align="left"><xsl:value-of select="$Val"/></td>
  </tr>
  
</xsl:template>


<!-- **************************************************************** -->
<!-- ********************* Blank Line Output ************************ -->
<!-- **************************************************************** -->
<xsl:template name="BlankLine">
  <xsl:value-of select="string(' ')"/>
  <br/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************************* Start Table ************************** -->
<!-- **************************************************************** -->
<xsl:template name="StartTable">
  <xsl:choose>
    <xsl:when test="$IncludeBorders = $YesStr">
      <xsl:value-of disable-output-escaping="yes" select="'&lt;table border=1 width=100% cellpadding=2 rules=cols&gt;'"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of disable-output-escaping="yes" select="'&lt;table border=0 width=100% cellpadding=2 rules=cols&gt;'"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************************** End Table *************************** -->
<!-- **************************************************************** -->
<xsl:template name="EndTable">
  <xsl:value-of disable-output-escaping="yes" select="'&lt;/table&gt;'"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Return the ECEF X value ********************* -->
<!-- **************************************************************** -->
<xsl:template name="ecefX">
  <xsl:param name="latitude"/>   <!-- latitude value required in decimal degrees -->
  <xsl:param name="longitude"/>  <!-- longitude value required in decimal degrees -->
  <xsl:param name="height"/>

  <!-- Get the latitude in radians -->
  <xsl:variable name="radLat">
    <xsl:call-template name="AngleInRadians">
      <xsl:with-param name="theAngle" select="$latitude"/>
    </xsl:call-template>
  </xsl:variable>

  <!-- Get the longitude in radians -->
  <xsl:variable name="radLong">
    <xsl:call-template name="AngleInRadians">
      <xsl:with-param name="theAngle" select="$longitude"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="N">
    <xsl:call-template name="RadiusOfCurvature">
      <xsl:with-param name="latitude" select="$radLat"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="cosLat">
    <!-- Cosine of latitude = sin(Pi / 2 - latitude) -->
    <xsl:call-template name="Sine">
      <xsl:with-param name="theAngle" select="$Pi div 2.0 - $radLat"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="cosLong">
    <!-- Cosine of longitude = sin(Pi / 2 - longitude) -->
    <xsl:call-template name="Sine">
      <xsl:with-param name="theAngle" select="$Pi div 2.0 - $radLong"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:value-of select="($N + $height) * $cosLat * $cosLong"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Return the ECEF Y value ********************* -->
<!-- **************************************************************** -->
<xsl:template name="ecefY">
  <xsl:param name="latitude"/>   <!-- latitude value required in decimal degrees -->
  <xsl:param name="longitude"/>  <!-- longitude value required in decimal degrees -->
  <xsl:param name="height"/>

  <!-- Get the latitude in radians -->
  <xsl:variable name="radLat">
    <xsl:call-template name="AngleInRadians">
      <xsl:with-param name="theAngle" select="$latitude"/>
    </xsl:call-template>
  </xsl:variable>

  <!-- Get the longitude in radians -->
  <xsl:variable name="radLong">
    <xsl:call-template name="AngleInRadians">
      <xsl:with-param name="theAngle" select="$longitude"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="N">
    <xsl:call-template name="RadiusOfCurvature">
      <xsl:with-param name="latitude" select="$radLat"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="cosLat">
    <!-- Cosine of latitude = sin(Pi / 2 - latitude) -->
    <xsl:call-template name="Sine">
      <xsl:with-param name="theAngle" select="$Pi div 2.0 - $radLat"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="sinLong">
    <xsl:call-template name="Sine">
      <xsl:with-param name="theAngle" select="$radLong"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:value-of select="($N + $height) * $cosLat * $sinLong"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Return the ECEF Z value ********************* -->
<!-- **************************************************************** -->
<xsl:template name="ecefZ">
  <xsl:param name="latitude"/>  <!-- latitude value required in decimal degrees -->  
  <xsl:param name="height"/>

  <!-- Get the latitude in radians -->
  <xsl:variable name="radLat">
    <xsl:call-template name="AngleInRadians">
      <xsl:with-param name="theAngle" select="$latitude"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="N">
    <xsl:call-template name="RadiusOfCurvature">
      <xsl:with-param name="latitude" select="$radLat"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="sinLat">
    <xsl:call-template name="Sine">
      <xsl:with-param name="theAngle" select="$radLat"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:value-of select="($N * (1.0 - $WGS84EccentricitySquared) + $height) * $sinLat"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ********** Compute the Latitude from the ECEF X,Y,Z ************ -->
<!-- **************************************************************** -->
<xsl:template name="LatFromXYZ">  <!-- Returns latitude value in radians -->
  <xsl:param name="X"/>
  <xsl:param name="Y"/>
  <xsl:param name="Z"/>

  <xsl:variable name="p">
    <xsl:call-template name="pVar">
      <xsl:with-param name="X" select="$X"/>
      <xsl:with-param name="Y" select="$Y"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="r">
    <xsl:call-template name="Sqrt">
      <xsl:with-param name="num" select="$p * $p + $Z * $Z"/>
      <xsl:with-param name="maxiter" select="30"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="oneMinusf" select="1 - 1 div $WGS84Flattening"/>

  <xsl:variable name="u">
    <xsl:call-template name="ArcTanSeries">
      <xsl:with-param name="tanVal" select="($Z div $p) *
                                            ($oneMinusf + $WGS84EccentricitySquared * $WGS84SemiMajorAxis div $r)"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="sinu">
    <xsl:call-template name="Sine">
      <xsl:with-param name="theAngle" select="$u"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="sinuCubed" select="$sinu * $sinu * $sinu"/>

  <xsl:variable name="cosu">
    <xsl:call-template name="Cosine">
      <xsl:with-param name="theAngle" select="$u"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="cosuCubed" select="$cosu * $cosu * $cosu"/>

  <xsl:variable name="rawLat">
    <xsl:call-template name="ArcTanSeries">
      <xsl:with-param name="tanVal" select="($Z * $oneMinusf + $WGS84EccentricitySquared * $WGS84SemiMajorAxis * $sinuCubed) div
                                            ($oneMinusf * ($p - $WGS84EccentricitySquared * $WGS84SemiMajorAxis * $cosuCubed))"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:call-template name="RadianAngleBetweenLimits">
    <xsl:with-param name="anAngle" select="$rawLat"/>
    <xsl:with-param name="minVal" select="-1 * $halfPi"/>
    <xsl:with-param name="maxVal" select="$halfPi"/>
    <xsl:with-param name="incVal" select="$halfPi"/>
  </xsl:call-template>
  <!-- Returns latitude value in radians -->
</xsl:template>


<!-- **************************************************************** -->
<!-- ********** Compute the Longitude from the ECEF X,Y,Z *********** -->
<!-- **************************************************************** -->
<xsl:template name="LongFromXYZ">  <!-- Returns longitude value in radians -->
  <xsl:param name="X"/>
  <xsl:param name="Y"/>

  <xsl:variable name="absX" select="concat(substring('-',2 - ($X &lt; 0)), '1') * $X"/>
  <xsl:variable name="absY" select="concat(substring('-',2 - ($Y &lt; 0)), '1') * $Y"/>

  <xsl:variable name="rawLong">
    <xsl:call-template name="ArcTanSeries">
      <xsl:with-param name="tanVal" select="$absY div $absX"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="rawLong1">
    <xsl:choose>
      <xsl:when test="$X &lt; 0.0">
        <xsl:value-of select="$Pi - $rawLong"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$rawLong"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="rawLong2">
    <xsl:choose>
      <xsl:when test="$Y &lt; 0.0">
        <xsl:value-of select="-1.0 * $rawLong1"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$rawLong1"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:call-template name="RadianAngleBetweenLimits">
    <xsl:with-param name="anAngle" select="$rawLong2"/>
    <xsl:with-param name="minVal" select="-1 * $Pi"/>
    <xsl:with-param name="maxVal" select="$Pi"/>
    <xsl:with-param name="incVal" select="2.0 * $Pi"/>
  </xsl:call-template>
  <!-- Returns longitude value in radians -->
</xsl:template>


<!-- **************************************************************** -->
<!-- ************ Compute the Height from the ECEF X,Y,Z ************ -->
<!-- **************************************************************** -->
<xsl:template name="HeightFromXYZ">
  <xsl:param name="X"/>
  <xsl:param name="Y"/>
  <xsl:param name="Z"/>
  <xsl:param name="lat"/>  <!-- lat value required in radians -->

  <xsl:variable name="p">
    <xsl:call-template name="pVar">
      <xsl:with-param name="X" select="$X"/>
      <xsl:with-param name="Y" select="$Y"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="cosLat">
    <xsl:call-template name="Cosine">
      <xsl:with-param name="theAngle" select="$lat"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="sinLat">
    <xsl:call-template name="Sine">
      <xsl:with-param name="theAngle" select="$lat"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="tempVal">
    <xsl:call-template name="Sqrt">
      <xsl:with-param name="num" select="1.0 - $WGS84EccentricitySquared * $sinLat * $sinLat"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:value-of select="$p * $cosLat + $Z * $sinLat - $WGS84SemiMajorAxis * $tempVal"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************ Return the sine of an angle in radians ************ -->
<!-- **************************************************************** -->
<xsl:template name="Sine">
  <xsl:param name="theAngle"/>
  <xsl:variable name="normalisedAngle">
    <xsl:call-template name="RadianAngleBetweenLimits">
      <xsl:with-param name="anAngle" select="$theAngle"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="theSine">
    <xsl:call-template name="sineIter">
      <xsl:with-param name="pX2" select="$normalisedAngle * $normalisedAngle"/>
      <xsl:with-param name="pRslt" select="$normalisedAngle"/>
      <xsl:with-param name="pElem" select="$normalisedAngle"/>
      <xsl:with-param name="pN" select="1"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:value-of select="number($theSine)"/>
</xsl:template>

<xsl:template name="sineIter">
  <xsl:param name="pX2"/>
  <xsl:param name="pRslt"/>
  <xsl:param name="pElem"/>
  <xsl:param name="pN"/>
  <xsl:param name="pEps" select="0.00000001"/>
  <xsl:variable name="vnextN" select="$pN+2"/>
  <xsl:variable name="vnewElem"  select="-$pElem*$pX2 div ($vnextN*($vnextN - 1))"/>
  <xsl:variable name="vnewResult" select="$pRslt + $vnewElem"/>
  <xsl:variable name="vdiffResult" select="$vnewResult - $pRslt"/>
  <xsl:choose>
    <xsl:when test="$vdiffResult > $pEps or $vdiffResult &lt; -$pEps">
      <xsl:call-template name="sineIter">
        <xsl:with-param name="pX2" select="$pX2"/>
        <xsl:with-param name="pRslt" select="$vnewResult"/>
        <xsl:with-param name="pElem" select="$vnewElem"/>
        <xsl:with-param name="pN" select="$vnextN"/>
        <xsl:with-param name="pEps" select="$pEps"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$vnewResult"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- *************** Return the square root of a value ************** -->
<!-- **************************************************************** -->
<xsl:template name="Sqrt">
  <xsl:param name="num" select="0"/>       <!-- The number you want to find the square root of -->
  <xsl:param name="try" select="1"/>       <!-- The current 'try'.  This is used internally. -->
  <xsl:param name="iter" select="1"/>      <!-- The current iteration, checked against maxiter to limit loop count - used internally -->
  <xsl:param name="maxiter" select="40"/>  <!-- Set this up to insure against infinite loops - used internally -->

  <!-- This template uses Sir Isaac Newton's method of finding roots -->

  <xsl:choose>
    <xsl:when test="$num &lt; 0"></xsl:when>  <!-- Invalid input - no square root of a negative number so return null -->
    <xsl:when test="$try * $try = $num or $iter &gt; $maxiter">
      <xsl:value-of select="$try"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="Sqrt">
        <xsl:with-param name="num" select="$num"/>
        <xsl:with-param name="try" select="$try - (($try * $try - $num) div (2 * $try))"/>
        <xsl:with-param name="iter" select="$iter + 1"/>
        <xsl:with-param name="maxiter" select="$maxiter"/>
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- *************** Return Formatted Station Value ***************** -->
<!-- **************************************************************** -->
<xsl:template name="FormatStationVal">
  <xsl:param name="stationVal"/>
  <xsl:param name="zoneVal" select="''"/>
  <xsl:param name="definedFmt" select="''"/>
  <xsl:param name="stationIndexIncrement" select="''"/>
  <xsl:param name="decPlDefnStr" select="''"/>

  <xsl:variable name="decPl">
    <xsl:choose>
      <xsl:when test="$decPlDefnStr != ''">
        <xsl:value-of select="$decPlDefnStr"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$DecPl3"/>  <!-- Default to 3 decimal places -->
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:choose>
    <xsl:when test="string(number($stationVal)) = 'NaN'">
      <xsl:value-of select="format-number($stationVal, $decPl, 'Standard')"/>  <!-- Return appropriate formatted null value -->
    </xsl:when>
    <xsl:otherwise>
      <xsl:variable name="formatStyle">
        <xsl:choose>
          <xsl:when test="$definedFmt = ''">
            <xsl:value-of select="/JOBFile/Environment/DisplaySettings/StationingFormat"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$definedFmt"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

      <xsl:variable name="stnIndexIncrement">
        <xsl:choose>
          <xsl:when test="string(number($stationIndexIncrement)) = 'NaN'">
            <xsl:value-of select="/JOBFile/Environment/DisplaySettings/StationIndexIncrement"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$stationIndexIncrement"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

      <xsl:variable name="stnVal" select="format-number($stationVal * $DistConvFactor, $decPl, 'Standard')"/>
      <xsl:variable name="signChar">
        <xsl:if test="$stnVal &lt; 0.0">-</xsl:if>
      </xsl:variable>

      <xsl:variable name="absStnVal" select="concat(substring('-',2 - ($stnVal &lt; 0)), '1') * $stnVal"/>

      <xsl:variable name="intPart" select="substring-before(format-number($absStnVal, $DecPl3, 'Standard'), '.')"/>
      <xsl:variable name="decPart" select="substring-after($stnVal, '.')"/>

      <xsl:if test="$formatStyle = '1000.0'">
        <xsl:value-of select="$stnVal"/>
      </xsl:if>

      <xsl:if test="$formatStyle = '10+00.0'">
        <xsl:choose>
          <xsl:when test="string-length($intPart) &gt; 2">
            <xsl:value-of select="concat($signChar, substring($intPart, 1, string-length($intPart) - 2),
                                         '+', substring($intPart, string-length($intPart) - 1, 2))"/>
            <xsl:if test="$decPart != ''">
              <xsl:text>.</xsl:text>
              <xsl:value-of select="$decPart"/>
            </xsl:if>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="concat($signChar, '0+', substring('00', 1, 2 - string-length($intPart)), $intPart)"/>
            <xsl:if test="$decPart != ''">
              <xsl:text>.</xsl:text>
              <xsl:value-of select="$decPart"/>
            </xsl:if>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:if>

      <xsl:if test="$formatStyle = '1+000.0'">
        <xsl:choose>
          <xsl:when test="string-length($intPart) &gt; 3">
            <xsl:value-of select="concat($signChar, substring($intPart, 1, string-length($intPart) - 3),
                                         '+', substring($intPart, string-length($intPart) - 2, 3))"/>
            <xsl:if test="$decPart != ''">
              <xsl:text>.</xsl:text>
              <xsl:value-of select="$decPart"/>
            </xsl:if>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="concat($signChar, '0+', substring('000', 1, 3 - string-length($intPart)), $intPart)"/>
            <xsl:if test="$decPart != ''">
              <xsl:text>.</xsl:text>
              <xsl:value-of select="$decPart"/>
            </xsl:if>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:if>

      <xsl:if test="$formatStyle = 'StationIndex'">
        <xsl:variable name="intIncrement" select="format-number($stnIndexIncrement * $DistConvFactor, $DecPl0, 'Standard')"/>

        <xsl:variable name="afterPlusDigits" select="string-length($intIncrement)"/>
        <xsl:variable name="afterPlusZeros" select="substring('000000000000', 1, $afterPlusDigits)"/>
        <xsl:variable name="afterPlusFmt" select="concat($afterPlusZeros, '.', substring-after($decPl, '.'))"/>

        <xsl:variable name="beforePlus" select="floor($absStnVal div ($stnIndexIncrement * $DistConvFactor))"/>
        <xsl:variable name="afterPlus" select="$absStnVal - $beforePlus * ($stnIndexIncrement * $DistConvFactor)"/>
        <xsl:value-of select="concat($signChar, format-number($beforePlus, '#0'), '+', format-number($afterPlus, $afterPlusFmt, 'Standard'))"/>
      </xsl:if>

      <xsl:if test="$zoneVal != ''">
        <xsl:value-of select="':'"/>
        <xsl:value-of select="format-number($zoneVal,'0')"/>
      </xsl:if>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************ Output Angle in Appropriate Format **************** -->
<!-- **************************************************************** -->
<xsl:template name="FormatAngle">
  <xsl:param name="theAngle"/>
  <xsl:param name="secDecPlaces" select="0"/>
  <xsl:param name="DMSOutput" select="'false'"/>  <!-- Can be used to force DMS output -->
  <xsl:param name="useSymbols" select="'true'"/>
  <xsl:param name="impliedDecimalPt" select="'false'"/>
  <xsl:param name="gonsDecPlaces" select="5"/>    <!-- Decimal places for gons output -->
  <xsl:param name="decDegDecPlaces" select="5"/>  <!-- Decimal places for decimal degrees output -->
  <xsl:param name="outputAsMilligonsOrSecs" select="'false'"/>
  <xsl:param name="outputAsMilligonsOrSecsSqrd" select="'false'"/>
  <xsl:param name="dmsSymbols">&#0176;'"</xsl:param>

  <xsl:variable name="gonsDecPl">
    <xsl:choose>
      <xsl:when test="$gonsDecPlaces = 1"><xsl:value-of select="$DecPl1"/></xsl:when>
      <xsl:when test="$gonsDecPlaces = 2"><xsl:value-of select="$DecPl2"/></xsl:when>
      <xsl:when test="$gonsDecPlaces = 3"><xsl:value-of select="$DecPl3"/></xsl:when>
      <xsl:when test="$gonsDecPlaces = 4"><xsl:value-of select="$DecPl4"/></xsl:when>
      <xsl:when test="$gonsDecPlaces = 5"><xsl:value-of select="$DecPl5"/></xsl:when>
      <xsl:when test="$gonsDecPlaces = 6"><xsl:value-of select="$DecPl6"/></xsl:when>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="decDegDecPl">
    <xsl:choose>
      <xsl:when test="$decDegDecPlaces = 1"><xsl:value-of select="$DecPl1"/></xsl:when>
      <xsl:when test="$decDegDecPlaces = 2"><xsl:value-of select="$DecPl2"/></xsl:when>
      <xsl:when test="$decDegDecPlaces = 3"><xsl:value-of select="$DecPl3"/></xsl:when>
      <xsl:when test="$decDegDecPlaces = 4"><xsl:value-of select="$DecPl4"/></xsl:when>
      <xsl:when test="$decDegDecPlaces = 5"><xsl:value-of select="$DecPl5"/></xsl:when>
      <xsl:when test="$decDegDecPlaces = 6"><xsl:value-of select="$DecPl6"/></xsl:when>
    </xsl:choose>
  </xsl:variable>

  <xsl:choose>
    <!-- Null angle value -->
    <xsl:when test="string(number($theAngle))='NaN'">
      <xsl:value-of select="format-number($theAngle, $DecPl3, 'Standard')"/> <!-- Use the defined null format output -->
    </xsl:when>
    <!-- There is an angle value -->
    <xsl:otherwise>
      <xsl:choose>
        <xsl:when test="($AngleUnit = 'DMSDegrees') or not($DMSOutput = 'false')">
          <xsl:choose>
            <xsl:when test="$outputAsMilligonsOrSecs != 'false'">
              <xsl:value-of select="format-number($theAngle * $AngleConvFactor * 3600.0, '00.0', 'Standard')"/>
            </xsl:when>            
            <xsl:when test="$outputAsMilligonsOrSecsSqrd != 'false'">
              <xsl:value-of select="format-number($theAngle * $AngleConvFactor * 3600.0 * 3600.0, '00.000', 'Standard')"/>
            </xsl:when>            
            <xsl:otherwise>
              <xsl:call-template name="FormatDMSAngle">
                <xsl:with-param name="decimalAngle" select="$theAngle"/>
                <xsl:with-param name="secDecPlaces" select="$secDecPlaces"/>
                <xsl:with-param name="useSymbols" select="$useSymbols"/>
                <xsl:with-param name="impliedDecimalPt" select="$impliedDecimalPt"/>
                <xsl:with-param name="dmsSymbols" select="$dmsSymbols"/>
              </xsl:call-template>
            </xsl:otherwise>
          </xsl:choose>  
        </xsl:when>

        <xsl:otherwise>
          <xsl:variable name="fmtAngle">
            <xsl:choose>
              <xsl:when test="($AngleUnit = 'Gons') and ($DMSOutput = 'false')">
                <xsl:choose>
                  <xsl:when test="$outputAsMilligonsOrSecs != 'false'">
                    <xsl:value-of select="format-number($theAngle * $AngleConvFactor * 1000.0, $DecPl2, 'Standard')"/>
                  </xsl:when>
                  <xsl:when test="$outputAsMilligonsOrSecsSqrd != 'false'">
                    <xsl:value-of select="format-number($theAngle * $AngleConvFactor * 1000.0 * 1000.0, $DecPl4, 'Standard')"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:choose>
                      <xsl:when test="$secDecPlaces &gt; 0">  <!-- More accurate angle output required -->
                        <xsl:value-of select="format-number($theAngle * $AngleConvFactor, $DecPl8, 'Standard')"/>
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:value-of select="format-number($theAngle * $AngleConvFactor, $gonsDecPl, 'Standard')"/>
                      </xsl:otherwise>
                    </xsl:choose>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:when>

              <xsl:when test="($AngleUnit = 'Mils') and ($DMSOutput = 'false')">
                <xsl:choose>
                  <xsl:when test="$secDecPlaces &gt; 0">  <!-- More accurate angle output required -->
                    <xsl:value-of select="format-number($theAngle * $AngleConvFactor, $DecPl6, 'Standard')"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="format-number($theAngle * $AngleConvFactor, $DecPl4, 'Standard')"/>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:when>

              <xsl:when test="($AngleUnit = 'DecimalDegrees') and ($DMSOutput = 'false')">
                <xsl:choose>
                  <xsl:when test="$secDecPlaces &gt; 0">  <!-- More accurate angle output required -->
                    <xsl:value-of select="format-number($theAngle * $AngleConvFactor, $DecPl8, 'Standard')"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="format-number($theAngle * $AngleConvFactor, $decDegDecPl, 'Standard')"/>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:when>
            </xsl:choose>
          </xsl:variable>
          
          <xsl:choose>
            <xsl:when test="$impliedDecimalPt != 'true'">
              <xsl:value-of select="$fmtAngle"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="translate($fmtAngle, '.', '')"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************ Output Azimuth in Appropriate Format ************** -->
<!-- **************************************************************** -->
<xsl:template name="FormatAzimuth">
  <xsl:param name="theAzimuth"/>
  <xsl:param name="secDecPlaces" select="0"/>
  <xsl:param name="DMSOutput" select="'false'"/>  <!-- Can be used to force DMS output -->
  <xsl:param name="useSymbols" select="'true'"/>
  <xsl:param name="quadrantBearings" select="'false'"/>  <!-- Can be used to force quadrant bearing output -->
  <xsl:param name="impliedDecimalPt" select="'false'"/>
  <xsl:param name="northLbl" select="'N'"/>
  <xsl:param name="eastLbl" select="'E'"/>
  <xsl:param name="southLbl" select="'S'"/>
  <xsl:param name="westLbl" select="'W'"/>
  <xsl:param name="dmsSymbols">&#0176;'"</xsl:param>

  <xsl:choose>
    <xsl:when test="(/JOBFile/Environment/DisplaySettings/AzimuthFormat = 'QuadrantBearings') or ($quadrantBearings != 'false')">
      <xsl:call-template name="FormatQuadrantBearing">
        <xsl:with-param name="decimalAngle" select="$theAzimuth"/>
        <xsl:with-param name="secDecPlaces" select="$secDecPlaces"/>
        <xsl:with-param name="impliedDecimalPt" select="$impliedDecimalPt"/>
        <xsl:with-param name="northLbl" select="$northLbl"/>
        <xsl:with-param name="eastLbl" select="$eastLbl"/>
        <xsl:with-param name="southLbl" select="$southLbl"/>
        <xsl:with-param name="westLbl" select="$westLbl"/>
        <xsl:with-param name="dmsSymbols" select="$dmsSymbols"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="FormatAngle">
        <xsl:with-param name="theAngle" select="$theAzimuth"/>
        <xsl:with-param name="secDecPlaces" select="$secDecPlaces"/>
        <xsl:with-param name="DMSOutput" select="$DMSOutput"/>
        <xsl:with-param name="useSymbols" select="$useSymbols"/>
        <xsl:with-param name="impliedDecimalPt" select="$impliedDecimalPt"/>
        <xsl:with-param name="dmsSymbols" select="$dmsSymbols"/>
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ********* Format latitude or Longitude in DMS Format *********** -->
<!-- **************************************************************** -->
<xsl:template name="FormatLatLong">
  <xsl:param name="theAngle"/>
  <xsl:param name="isLat" select="'true'"/>
  <xsl:param name="secDecPlaces" select="5"/>
  <xsl:param name="impliedDecimalPt" select="'false'"/>
  <xsl:param name="northLbl" select="'N'"/>
  <xsl:param name="eastLbl" select="'E'"/>
  <xsl:param name="southLbl" select="'S'"/>
  <xsl:param name="westLbl" select="'W'"/>
  <xsl:param name="leadingLabel" select="'false'"/>
  <xsl:param name="dmsSymbols">&#0176;'"</xsl:param>
  <xsl:param name="decimalDegrees" select="'false'"/>

  <xsl:choose>
    <!-- Null angle value -->
    <xsl:when test="string(number($theAngle)) = 'NaN'">
      <xsl:value-of select="format-number($theAngle, $DecPl3, 'Standard')"/> <!-- Use the defined null format output -->
    </xsl:when>
    <!-- There is a lat or long value -->
    <xsl:otherwise>
      <xsl:variable name="sign">
        <xsl:choose>
          <xsl:when test="$theAngle &lt; '0.0'">
            <xsl:choose>  <!-- Negative value -->
              <xsl:when test="$isLat = 'true'"><xsl:value-of select="$southLbl"/></xsl:when>
              <xsl:otherwise><xsl:value-of select="$westLbl"/></xsl:otherwise>
            </xsl:choose>
          </xsl:when>
          <xsl:otherwise> <!-- Positive value -->
            <xsl:choose>
              <xsl:when test="$isLat = 'true'"><xsl:value-of select="$northLbl"/></xsl:when>
              <xsl:otherwise><xsl:value-of select="$eastLbl"/></xsl:otherwise>
            </xsl:choose>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

      <!-- Convert to a positive angle before changing to DMS format -->
      <xsl:variable name="posAngle" select="concat(substring('-',2 - ($theAngle &lt; 0)), '1') * $theAngle"/>

      <xsl:variable name="latLongAngle">
        <xsl:choose>
          <xsl:when test="$decimalDegrees = 'false'">
            <xsl:call-template name="FormatDMSAngle">
              <xsl:with-param name="decimalAngle" select="$posAngle"/>
              <xsl:with-param name="secDecPlaces" select="$secDecPlaces"/>
              <xsl:with-param name="impliedDecimalPt" select="$impliedDecimalPt"/>
              <xsl:with-param name="dmsSymbols" select="$dmsSymbols"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>  <!-- Output as decimal degrees to 8 decimal places -->
            <xsl:value-of select="format-number($posAngle, $DecPl8, 'Standard')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

      <xsl:choose>
        <xsl:when test="$leadingLabel = 'false'">
          <xsl:value-of select="concat($latLongAngle, $sign)"/>
        </xsl:when>
        <xsl:otherwise>  <!-- Trailing label -->
          <xsl:value-of select="concat($sign, $latLongAngle)"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- *** An intermediate variable of X,Y,Z to lat,long,height conv ** -->
<!-- **************************************************************** -->
<xsl:template name="pVar">
  <xsl:param name="X"/>
  <xsl:param name="Y"/>

  <xsl:call-template name="Sqrt">
    <xsl:with-param name="num" select="$X * $X + $Y * $Y"/>
    <xsl:with-param name="maxiter" select="30"/>
  </xsl:call-template>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******* Return the Radius of Curvature in Prime Vertical ******* -->
<!-- **************************************************************** -->
<xsl:template name="RadiusOfCurvature">
  <xsl:param name="latitude"/>   <!-- Already converted to radians -->

  <xsl:variable name="sinLat">
    <xsl:call-template name="Sine">
      <xsl:with-param name="theAngle" select="$latitude"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="sinLatSquared">
    <xsl:value-of select="$sinLat * $sinLat"/>
  </xsl:variable>

  <xsl:variable name="tempVal">
    <xsl:call-template name="Sqrt">
      <xsl:with-param name="num" select="1.0 - $WGS84EccentricitySquared * $sinLatSquared"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:value-of select="$WGS84SemiMajorAxis div $tempVal"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ********************** Angle in Radians ************************ -->
<!-- **************************************************************** -->
<xsl:template name="AngleInRadians">
  <xsl:param name="theAngle"/>
  <xsl:param name="normalise" select="'false'"/>
  <xsl:choose>
    <!-- Null angle value -->
    <xsl:when test="string(number($theAngle)) = 'NaN'">
      <xsl:value-of select="''"/>
    </xsl:when>
    <!-- There is an angle value -->
    <xsl:otherwise>
      <xsl:variable name="radiansAngle">
        <xsl:value-of select="$theAngle * $Pi div 180.0"/>
      </xsl:variable>

      <xsl:variable name="outAngle">
        <xsl:choose>
          <xsl:when test="$normalise = 'false'">
            <xsl:value-of select="$radiansAngle"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:call-template name="RadianAngleBetweenLimits">
              <xsl:with-param name="anAngle" select="$radiansAngle"/>
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
      <xsl:value-of select="$outAngle"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ********* Return radians angle between Specified Limits ******** -->
<!-- **************************************************************** -->
<xsl:template name="RadianAngleBetweenLimits">
  <xsl:param name="anAngle"/>
  <xsl:param name="minVal" select="0.0"/>
  <xsl:param name="maxVal" select="$Pi * 2.0"/>
  <xsl:param name="incVal" select="$Pi * 2.0"/>

  <xsl:variable name="angle1">
    <xsl:call-template name="AngleValueLessThanMax">
      <xsl:with-param name="inAngle" select="$anAngle"/>
      <xsl:with-param name="maxVal" select="$maxVal"/>
      <xsl:with-param name="incVal" select="$incVal"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="angle2">
    <xsl:call-template name="AngleValueGreaterThanMin">
      <xsl:with-param name="inAngle" select="$angle1"/>
      <xsl:with-param name="minVal" select="$minVal"/>
      <xsl:with-param name="incVal" select="$incVal"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:value-of select="$angle2"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- *********** Return the Cosine of an angle in radians *********** -->
<!-- **************************************************************** -->
<xsl:template name="Cosine">
  <xsl:param name="theAngle"/>

  <!-- Use the sine function after subtracting the angle from halfPi -->
  <xsl:call-template name="Sine">
    <xsl:with-param name="theAngle" select="$halfPi - $theAngle"/>
  </xsl:call-template>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******* Return the arcTan value using a series expansion ******* -->
<!-- **************************************************************** -->
<xsl:template name="ArcTanSeries">
  <xsl:param name="tanVal"/>

  <!-- If the absolute value of tanVal is greater than 1 the work with the -->
  <!-- reciprocal value and return the resultant angle subtracted from Pi. -->
  <xsl:variable name="absTanVal" select="concat(substring('-',2 - ($tanVal &lt; 0)), '1') * $tanVal"/>
  <xsl:variable name="tanVal2">
    <xsl:choose>
      <xsl:when test="$absTanVal &gt; 1.0">
        <xsl:value-of select="1.0 div $tanVal"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$tanVal"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="valSq" select="$tanVal2 * $tanVal2"/>

  <xsl:variable name="angVal">
    <xsl:value-of select="$tanVal2 div (1 + ($valSq
                                   div (3 + (4 * $valSq
                                   div (5 + (9 * $valSq
                                   div (7 + (16 * $valSq
                                   div (9 + (25 * $valSq
                                   div (11 + (36 * $valSq
                                   div (13 + (49 * $valSq
                                   div (15 + (64 * $valSq
                                   div (17 + (81 * $valSq
                                   div (19 + (100 * $valSq
                                   div (21 + (121 * $valSq
                                   div (23 + (144 * $valSq
                                   div (25 + (169 * $valSq
                                   div (27 + (196 * $valSq
                                   div (29 + (225 * $valSq))))))))))))))))))))))))))))))"/>
  </xsl:variable>

  <xsl:choose>
    <xsl:when test="$absTanVal &gt; 1.0">
      <xsl:choose>
        <xsl:when test="$tanVal &lt; 0">
          <xsl:value-of select="-$halfPi - $angVal"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$halfPi - $angVal"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$angVal"/>
    </xsl:otherwise>
  </xsl:choose>

</xsl:template>


<!-- **************************************************************** -->
<!-- ********************** Format a DMS Angle ********************** -->
<!-- **************************************************************** -->
<xsl:template name="FormatDMSAngle">
  <xsl:param name="decimalAngle"/>
  <xsl:param name="secDecPlaces" select="0"/>
  <xsl:param name="useSymbols" select="'true'"/>
  <xsl:param name="impliedDecimalPt" select="'false'"/>
  <xsl:param name="dmsSymbols">&#0176;'"</xsl:param>

  <xsl:variable name="degreesSymbol">
    <xsl:choose>
      <xsl:when test="$useSymbols = 'true'"><xsl:value-of select="substring($dmsSymbols, 1, 1)"/></xsl:when>  <!-- Degrees symbol ° -->
      <xsl:otherwise>
        <xsl:if test="$impliedDecimalPt != 'true'">.</xsl:if>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="minutesSymbol">
    <xsl:choose>
      <xsl:when test="$useSymbols = 'true'"><xsl:value-of select="substring($dmsSymbols, 2, 1)"/></xsl:when>
      <xsl:otherwise></xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="secondsSymbol">
    <xsl:choose>
      <xsl:when test="$useSymbols = 'true'"><xsl:value-of select="substring($dmsSymbols, 3, 1)"/></xsl:when>
      <xsl:otherwise></xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="sign">
    <xsl:if test="$decimalAngle &lt; '0.0'">-1</xsl:if>
    <xsl:if test="$decimalAngle &gt;= '0.0'">1</xsl:if>
  </xsl:variable>

  <xsl:variable name="posDecimalDegrees" select="number($decimalAngle * $sign)"/>

  <xsl:variable name="positiveDecimalDegrees">  <!-- Ensure an angle very close to 360° is treated as 0° -->
    <xsl:choose>
      <xsl:when test="(360.0 - $posDecimalDegrees) &lt; 0.00001">
        <xsl:value-of select="0"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$posDecimalDegrees"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="decPlFmt">
    <xsl:choose>
      <xsl:when test="$secDecPlaces = 0"><xsl:value-of select="''"/></xsl:when>
      <xsl:when test="$secDecPlaces = 1"><xsl:value-of select="'.0'"/></xsl:when>
      <xsl:when test="$secDecPlaces = 2"><xsl:value-of select="'.00'"/></xsl:when>
      <xsl:when test="$secDecPlaces = 3"><xsl:value-of select="'.000'"/></xsl:when>
      <xsl:when test="$secDecPlaces = 4"><xsl:value-of select="'.0000'"/></xsl:when>
      <xsl:when test="$secDecPlaces = 5"><xsl:value-of select="'.00000'"/></xsl:when>
      <xsl:when test="$secDecPlaces = 6"><xsl:value-of select="'.000000'"/></xsl:when>
      <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="degrees" select="floor($positiveDecimalDegrees)"/>
  <xsl:variable name="decimalMinutes" select="number(number($positiveDecimalDegrees - $degrees) * 60 )"/>
  <xsl:variable name="minutes" select="floor($decimalMinutes)"/>
  <xsl:variable name="seconds" select="number(number($decimalMinutes - $minutes)*60)"/>

  <xsl:variable name="partiallyNormalisedMinutes">
    <xsl:if test="number(format-number($seconds, concat('00', $decPlFmt))) = 60"><xsl:value-of select="number($minutes + 1)"/></xsl:if>
    <xsl:if test="not(number(format-number($seconds, concat('00', $decPlFmt))) = 60)"><xsl:value-of select="$minutes"/></xsl:if>
  </xsl:variable>

  <xsl:variable name="normalisedSeconds">
    <xsl:if test="number(format-number($seconds, concat('00', $decPlFmt))) = 60"><xsl:value-of select="0"/></xsl:if>
    <xsl:if test="not(number(format-number($seconds, concat('00', $decPlFmt))) = 60)"><xsl:value-of select="$seconds"/></xsl:if>
  </xsl:variable>

  <xsl:variable name="partiallyNormalisedDegrees">
    <xsl:if test="format-number($partiallyNormalisedMinutes, '0') = '60'"><xsl:value-of select="number($degrees + 1)"/></xsl:if>
    <xsl:if test="not(format-number($partiallyNormalisedMinutes, '0') = '60')"><xsl:value-of select="$degrees"/></xsl:if>
  </xsl:variable>

  <xsl:variable name="normalisedDegrees">
    <xsl:if test="format-number($partiallyNormalisedDegrees, '0') = '360'"><xsl:value-of select="0"/></xsl:if>
    <xsl:if test="not(format-number($partiallyNormalisedDegrees, '0') = '360')"><xsl:value-of select="$partiallyNormalisedDegrees"/></xsl:if>
  </xsl:variable>

  <xsl:variable name="normalisedMinutes">
    <xsl:if test="format-number($partiallyNormalisedMinutes, '00') = '60'"><xsl:value-of select="0"/></xsl:if>
    <xsl:if test="not(format-number($partiallyNormalisedMinutes, '00') = '60')"><xsl:value-of select="$partiallyNormalisedMinutes"/></xsl:if>
  </xsl:variable>

  <xsl:if test="$sign = -1">-</xsl:if>
  <xsl:value-of select="format-number($normalisedDegrees, '0')"/>
  <xsl:value-of select="$degreesSymbol"/>
  <xsl:value-of select="format-number($normalisedMinutes, '00')"/>
  <xsl:value-of select="$minutesSymbol"/>
  <xsl:choose>
    <xsl:when test="$useSymbols = 'true'">
      <xsl:value-of select="format-number($normalisedSeconds, concat('00', $decPlFmt))"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="translate(format-number($normalisedSeconds, concat('00', $decPlFmt)), '.', '')"/>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:value-of select="$secondsSymbol"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* Format a Quadrant Bearing ****************** -->
<!-- **************************************************************** -->
<xsl:template name="FormatQuadrantBearing">
  <xsl:param name="decimalAngle"/>
  <xsl:param name="secDecPlaces" select="0"/>
  <xsl:param name="impliedDecimalPt" select="'false'"/>
  <xsl:param name="northLbl" select="'N'"/>
  <xsl:param name="eastLbl" select="'E'"/>
  <xsl:param name="southLbl" select="'S'"/>
  <xsl:param name="westLbl" select="'W'"/>
  <xsl:param name="dmsSymbols">&#0176;'"</xsl:param>

  <xsl:choose>
    <!-- Null azimuth value -->
    <xsl:when test="string(number($decimalAngle)) = 'NaN'">
      <xsl:value-of select="format-number($decimalAngle, $DecPl3, 'Standard')"/>  <!-- Use the defined null format output -->
    </xsl:when>
    <!-- There is an azimuth value -->
    <xsl:otherwise>
      <xsl:variable name="quadrantAngle">
        <xsl:if test="($decimalAngle &lt;= 90.0)">
          <xsl:value-of select="number ( $decimalAngle )"/>
        </xsl:if>
        <xsl:if test="($decimalAngle &gt; 90.0) and ($decimalAngle &lt;= 180.0)">
          <xsl:value-of select="number( 180.0 - $decimalAngle )"/>
        </xsl:if>
        <xsl:if test="($decimalAngle &gt; 180.0) and ($decimalAngle &lt; 270.0)">
          <xsl:value-of select="number( $decimalAngle - 180.0 )"/>
        </xsl:if>
        <xsl:if test="($decimalAngle &gt;= 270.0) and ($decimalAngle &lt;= 360.0)">
          <xsl:value-of select="number( 360.0 - $decimalAngle )"/>
        </xsl:if>
      </xsl:variable>

      <xsl:variable name="quadrantPrefix">
        <xsl:if test="($decimalAngle &lt;= 90.0) or ($decimalAngle &gt;= 270.0)"><xsl:value-of select="$northLbl"/></xsl:if>
        <xsl:if test="($decimalAngle &gt; 90.0) and ($decimalAngle &lt; 270.0)"><xsl:value-of select="$southLbl"/></xsl:if>
      </xsl:variable>

      <xsl:variable name="quadrantSuffix">
        <xsl:if test="($decimalAngle &lt;= 180.0)"><xsl:value-of select="$eastLbl"/></xsl:if>
        <xsl:if test="($decimalAngle &gt; 180.0)"><xsl:value-of select="$westLbl"/></xsl:if>
      </xsl:variable>

      <xsl:value-of select="$quadrantPrefix"/>
      <xsl:choose>
        <xsl:when test="$AngleUnit = 'DMSDegrees'">
          <xsl:call-template name="FormatDMSAngle">
            <xsl:with-param name="decimalAngle" select="$quadrantAngle"/>
            <xsl:with-param name="secDecPlaces" select="$secDecPlaces"/>
            <xsl:with-param name="impliedDecimalPt" select="$impliedDecimalPt"/>
            <xsl:with-param name="dmsSymbols" select="$dmsSymbols"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="FormatAngle">
            <xsl:with-param name="theAngle" select="$quadrantAngle"/>
            <xsl:with-param name="secDecPlaces" select="$secDecPlaces"/>
            <xsl:with-param name="impliedDecimalPt" select="$impliedDecimalPt"/>
            <xsl:with-param name="dmsSymbols" select="$dmsSymbols"/>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:value-of select="$quadrantSuffix"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******* Return radians angle less than Specificed Maximum ****** -->
<!-- **************************************************************** -->
<xsl:template name="AngleValueLessThanMax">
  <xsl:param name="inAngle"/>
  <xsl:param name="maxVal"/>
  <xsl:param name="incVal"/>

  <xsl:choose>
    <xsl:when test="$inAngle &gt; $maxVal">
      <xsl:variable name="newAngle">
        <xsl:value-of select="$inAngle - $incVal"/>
      </xsl:variable>
      <xsl:call-template name="AngleValueLessThanMax">
        <xsl:with-param name="inAngle" select="$newAngle"/>
      </xsl:call-template>
    </xsl:when>

    <xsl:otherwise>
      <xsl:value-of select="$inAngle"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************* Return radians angle greater than Zero *********** -->
<!-- **************************************************************** -->
<xsl:template name="AngleValueGreaterThanMin">
  <xsl:param name="inAngle"/>
  <xsl:param name="minVal"/>
  <xsl:param name="incVal"/>

  <xsl:choose>
    <xsl:when test="$inAngle &lt; $minVal">
      <xsl:variable name="newAngle">
        <xsl:value-of select="$inAngle + $incVal"/>
      </xsl:variable>
      <xsl:call-template name="AngleValueGreaterThanMin">
        <xsl:with-param name="inAngle" select="$newAngle"/>
      </xsl:call-template>
    </xsl:when>

    <xsl:otherwise>
      <xsl:value-of select="$inAngle"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


</xsl:stylesheet>
