<?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"
    xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:x="urn:schemas-microsoft-com:office:excel"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">

<!-- (c) 2009, 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="xml" omit-xml-declaration="no" encoding="utf-8"/>

<!-- Set the numeric display details i.e. decimal point, thousands separator etc -->
<xsl:variable name="DecPt" select="'.'"/>    <!-- Change as appropriate for US/European -->
<xsl:variable name="GroupSep" select="','"/> <!-- 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="'#0'"/>
<xsl:variable name="DecPl1" select="concat('#0', $DecPt, '0')"/>
<xsl:variable name="DecPl2" select="concat('#0', $DecPt, '00')"/>
<xsl:variable name="DecPl3" select="concat('#0', $DecPt, '000')"/>
<xsl:variable name="DecPl4" select="concat('#0', $DecPt, '0000')"/>
<xsl:variable name="DecPl5" select="concat('#0', $DecPt, '00000')"/>
<xsl:variable name="DecPl8" select="concat('#0', $DecPt, '00000000')"/>

<xsl:variable name="DegreesSymbol" select="'&#0176;'"/>
<xsl:variable name="MinutesSymbol"><xsl:text>'</xsl:text></xsl:variable>
<xsl:variable name="SecondsSymbol" select="'&quot;'"/>
<xsl:variable name="secondsInDay" select="86400"/>

<xsl:variable name="fileExt" select="'xls'"/>

<!-- 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.                  -->
<xsl:variable name="showInitTimes" select="'Yes'"/>

<xsl:key name="reducedPtName-search" match="//JOBFile/Reductions/Point" use="Name"/>
  
<!-- **************************************************************** -->
<!-- Set global variables from the Environment section of JobXML file -->
<!-- **************************************************************** -->
<xsl:variable name="DistUnit"   select="/JOBFile/Environment/DisplaySettings/DistanceUnits" />
<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="MountPoint" select="JOBFile/FieldBook/NTRIPDataSourceRecord/MountPoint"/>
<xsl:variable name="ZoneName" select="JOBFile/Environment/CoordinateSystem/ZoneName"/>
<xsl:variable name="DatumName" select="JOBFile/Environment/CoordinateSystem/DatumName"/>


<!-- Setup conversion factor for coordinate and distance values -->
<!-- Dist/coord values in JobXML file are always in metres -->
<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 angular values -->
<!-- Angular values in JobXML file are always in decimal degrees -->
<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 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>

<!-- 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="SCVersion">
  <xsl:choose>
    <xsl:when test="/JOBFile/@productVersion">
      <xsl:value-of select="/JOBFile/@productVersion"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="/JOBFile/@version div 100"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>
  
  
<!-- **************************************************************** -->
<!-- ************************** Main Loop *************************** -->
<!-- **************************************************************** -->
<xsl:template match="/" >

  <!-- Output all the spreadsheet initialisation details -->
  <xsl:call-template name="NewLine"/>
  <xsl:value-of disable-output-escaping="yes" select="'&lt;?mso-application progid=&quot;Excel.Sheet&quot;?&gt;'"/>

  <xsl:call-template name="NewLine"/>
  <Workbook>  <!-- This is the root element for the output XML file -->
    <DocumentProperties>
      <Company>Trimble</Company>
      <Version>11.9999</Version>
    </DocumentProperties>
    <xsl:call-template name="NewLine"/>

    <ExcelWorkbook>
      <WindowHeight>10005</WindowHeight>
      <WindowWidth>17640</WindowWidth>
      <WindowTopX>120</WindowTopX>
      <WindowTopY>135</WindowTopY>
      <ProtectStructure>False</ProtectStructure>
      <ProtectWindows>False</ProtectWindows>
    </ExcelWorkbook>
    <xsl:call-template name="NewLine"/>

    <xsl:call-template name="OutputStyles"/>

    <Worksheet ss:Name="DETAY">
      <xsl:call-template name="NewLine"/>
      <Table ssExpandedColumnCount="14" ssExpandedRowCount="20" x:FullColumns="1" x:FullRows="1"  ss:StyleID="s21" ss:DefaultRowHeight="15.75">
        <xsl:call-template name="NewLine"/>

        <xsl:call-template name="DefineColumns"/>

        <xsl:call-template name="ProjectDetails"/>

        <xsl:call-template name="ColumnHeadings"/>

        <!-- Select the FieldBook node to process -->
<!--
        <xsl:apply-templates select="JOBFile/FieldBook/PointRecord[(Deleted = 'false') and ((Method = 'GpsStaticObservation') or (Method = 'GpsRTKQuickMark')or (Method = 'GpsRTKControlPoint'))]"/       12/4/2010            -->
-->
        <xsl:apply-templates select="JOBFile/FieldBook/PointRecord[(Deleted = 'false')]"/>

      </Table>
    </Worksheet>
  </Workbook>
</xsl:template>

<!--   Her noktaya ait MountPoint in seçilmesi  Noktanın Time ı MountPoint i time ından büyük olacak şekilde seçiliyor.-->
<!--2009-10-05T08:43:10-->	
	<xsl:template name="MountPointSec">
            <xsl:variable name="pots" select="concat(substring(@TimeStamp,9,2),substring-after(@TimeStamp,'T'))" />
            <xsl:variable name="zmopo" >
				<xsl:for-each select="/JOBFile/FieldBook/NTRIPDataSourceRecord">
					<xsl:variable name="i" select="position()-1"/>
					<xsl:variable name="ison" select="count(/JOBFile/FieldBook/NTRIPDataSourceRecord)"/>
					<xsl:if test="$ison = 1">
					   <xsl:value-of select="MountPoint"/>
					 </xsl:if> 
					<xsl:if test="position() &gt; 1">
						<xsl:variable name="mots" select="concat(substring(@TimeStamp,9,2),substring-after(@TimeStamp,'T'))" />
						<xsl:variable name="motse1" select="concat(substring(/JOBFile/FieldBook/NTRIPDataSourceRecord[$i]/@TimeStamp,9,2),substring-after(/JOBFile/FieldBook/NTRIPDataSourceRecord[$i]/@TimeStamp,'T'))" />
						<xsl:variable name="motsson" select="concat(substring(/JOBFile/FieldBook/NTRIPDataSourceRecord[$ison]/@TimeStamp,9,2),substring-after(/JOBFile/FieldBook/NTRIPDataSourceRecord[$ison]/@TimeStamp,'T'))" />
						<xsl:choose>
							<xsl:when test="(translate($pots,':','')   &gt;  translate($motse1,':',''))  and (translate($pots,':','')   &lt;  translate($mots,':',''))  ">
								   <xsl:value-of select="/JOBFile/FieldBook/NTRIPDataSourceRecord[$i]/MountPoint"/>
						   </xsl:when>
						   <xsl:otherwise>
								  <xsl:if test="(position()=$ison) and ( (translate($pots,':','')   &gt;  translate($motsson,':','')))  ">
              						 <xsl:value-of select="MountPoint"/>
								  </xsl:if> 
							</xsl:otherwise>
					    </xsl:choose>
				    </xsl:if> 
				</xsl:for-each>
            </xsl:variable>
            <xsl:value-of select="$zmopo"/>
		</xsl:template>



<!-- **************************************************************** -->
<!-- ******************** PointRecord Output ************************ -->
<!-- **************************************************************** -->
<xsl:template match="PointRecord">
   <xsl:variable name="ptName" select="Name"/>
   <xsl:variable name="countNo" select="count(/JOBFile/FieldBook/PointRecord[(Name = $ptName) and (Deleted = 'false')]/ComputedGrid/East)"/>
    <xsl:variable name="heightVal">
        <xsl:for-each select="key('reducedPtName-search', Name)">
            <xsl:value-of select="WGS84/Height"/>
         </xsl:for-each>
     </xsl:variable>

     <xsl:variable name="firstElevation" >
           <xsl:choose>
                <xsl:when test="count(preceding-sibling::PointRecord[(Name = $ptName) and (Deleted = 'false')])  = 1">
                    <xsl:value-of select="preceding-sibling::PointRecord[(Name = $ptName) and (Deleted = 'false')]/ComputedGrid/Elevation"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="ComputedGrid/Elevation "/>
               </xsl:otherwise>
         </xsl:choose>
     </xsl:variable>
     

  <xsl:call-template name="StartRow"/>
    <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s29</xsl:with-param>
      <xsl:with-param name="cellType">String</xsl:with-param>
      <xsl:with-param name="cellText" select="Name"/>
    </xsl:call-template>

    <!-- H.Altan TimeStamp -->

    <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s29</xsl:with-param>
      <xsl:with-param name="cellType">String</xsl:with-param>
      <xsl:with-param name="cellText" select="@TimeStamp"/>
    </xsl:call-template>


    <!-- H.Altan Epok  sayısı -->
    <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s29</xsl:with-param>
      <xsl:with-param name="cellType">String</xsl:with-param>
      <xsl:with-param name="cellText">
        <xsl:variable name="stime" select="QualityControl1/NumberOfPositionsUsed"/>
        <xsl:value-of select="$stime"/>
      </xsl:with-param>
    </xsl:call-template>

    <!-- H.Altan Veri toplama aralığı -->

    <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s29</xsl:with-param>
      <xsl:with-param name="cellType">String</xsl:with-param>
      <xsl:with-param name="cellText" select="1"/>
    </xsl:call-template>


    <!-- H.Altan Uydu  sayısı -->
    <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s29</xsl:with-param>
      <xsl:with-param name="cellType">String</xsl:with-param>
      <xsl:with-param name="cellText">
        <xsl:variable name="stime" select="QualityControl1/NumberOfSatellites"/>
        <xsl:value-of select="$stime"/>
      </xsl:with-param>
    </xsl:call-template>



    <!-- H.Altan RMS 
    <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s31</xsl:with-param>
      <xsl:with-param name="cellType">Number</xsl:with-param>
      <xsl:with-param name="cellText">
         <xsl:choose>
           <xsl:when test="QualityControl1/RMS > 0">
              <xsl:value-of select="QualityControl1/RMS * 0.00019"/>
           </xsl:when>
           <xsl:otherwise>
               <xsl:value-of select="QualityControl1/RMS "/>
           </xsl:otherwise>
         </xsl:choose>
       </xsl:with-param>
    </xsl:call-template>
-->

    <!-- H.Altan RMS -->
    <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s31</xsl:with-param>
      <xsl:with-param name="cellType">Number</xsl:with-param>
      <xsl:with-param name="formula">
               <xsl:value-of select=" '=SQRT((RC[4]*RC[4]+RC[5]*RC[5])/2)'  "/>
      </xsl:with-param>
    </xsl:call-template>

    
    
    

    <!-- H.Altan PDOP -->
    <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s27</xsl:with-param>
      <xsl:with-param name="cellType">Number</xsl:with-param>
      <xsl:with-param name="cellText">
      <xsl:value-of select="QualityControl1/PDOP"/>
      </xsl:with-param>
    </xsl:call-template>

    <!-- H.Altan TAM SAYI belirsizlik -->
    <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s29</xsl:with-param>
      <xsl:with-param name="cellType">String</xsl:with-param>
      <xsl:with-param name="cellText" select="SurveyMethod"/>
    </xsl:call-template>

    <!-- H.Altan MountPoint -->

       <xsl:variable name="mopo" >
           <xsl:call-template name="MountPointSec"/>
      </xsl:variable>


  <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s29</xsl:with-param>
      <xsl:with-param name="cellType">String</xsl:with-param>
<!--      <xsl:with-param name="cellText" select="$mopo"/>   13/2/2013 mountpointler ardışık çıkıyordu.
--> 
     <xsl:with-param name="cellText" select="substring($mopo,1,7)"/>
    </xsl:call-template>
<!--  
  <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s29</xsl:with-param>
      <xsl:with-param name="cellType">String</xsl:with-param>
      <xsl:with-param name="cellText" select="$MountPoint"/>
    </xsl:call-template>

-->


    <!-- graftek yatay precision -->
    <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s31_5</xsl:with-param>
      <xsl:with-param name="cellType">Number</xsl:with-param>
      <xsl:with-param name="cellText" select="Precision/Horizontal"/>
    </xsl:call-template>

    <!-- graftek  DÜŞEY HASSASİYET -->
    <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s31_5</xsl:with-param>
      <xsl:with-param name="cellType">Number</xsl:with-param>
      <xsl:with-param name="cellText" select="Precision/Vertical"/>
    </xsl:call-template>



    <!-- H.Altan Sağa değer y -->
    <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s26</xsl:with-param>
      <xsl:with-param name="cellType">Number</xsl:with-param>
      <xsl:with-param name="cellText">
      <xsl:value-of select="ComputedGrid/East"/>
      </xsl:with-param>
    </xsl:call-template>


    <!-- H.Altan Yukari değer x -->
    <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s26</xsl:with-param>
      <xsl:with-param name="cellType">Number</xsl:with-param>
      <xsl:with-param name="cellText">
      <xsl:value-of select="ComputedGrid/North"/>
      </xsl:with-param>
    </xsl:call-template>

    <!-- H.Altan Elevation z -->



         <xsl:choose>
           <xsl:when test="$countNo >=2">
				<xsl:call-template name="OutputCell">
				  <xsl:with-param name="styleID">s26</xsl:with-param>
				  <xsl:with-param name="cellType">Number</xsl:with-param>
				  <xsl:with-param name="cellText">
				  <xsl:value-of select="$heightVal - $firstElevation +ComputedGrid/Elevation "/>
				  </xsl:with-param>
				</xsl:call-template>
           </xsl:when>
           <xsl:otherwise>
				<xsl:call-template name="OutputCell">
				  <xsl:with-param name="styleID">s26</xsl:with-param>
				  <xsl:with-param name="cellType">Number</xsl:with-param>
				  <xsl:with-param name="cellText">
				  <xsl:value-of select="$heightVal"/>
				  </xsl:with-param>
				</xsl:call-template>
           </xsl:otherwise>
         </xsl:choose>



-
    <!-- H.Altan Elevation z 
  <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s27</xsl:with-param>
      <xsl:with-param name="cellType">Number</xsl:with-param>
      <xsl:with-param name="cellText">
        <xsl:variable name="heightVal">
          <xsl:for-each select="key('reducedPtName-search', Name)">
            <xsl:value-of select="WGS84/Height"/>
          </xsl:for-each>
        </xsl:variable>
        <xsl:value-of select="$heightVal * $DistConvFactor"/>
      </xsl:with-param>
    </xsl:call-template>
-->



  <xsl:call-template name="EndRow"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ********************** Format a DMS Angle ********************** -->
<!-- **************************************************************** -->
<xsl:template name="FormatDMSAngle">
  <xsl:param name="DecimalAngle"/>
  <xsl:param name="SecDecPlaces" select="0"/>

  <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: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:value-of select="format-number($NormalisedSeconds, concat('00', $decPlFmt))"/>
  <xsl:value-of select="$SecondsSymbol"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ********* Output latitude or Longitude in DMS Format *********** -->
<!-- **************************************************************** -->
<xsl:template name="LatLongValue">
  <xsl:param name="TheAngle"/>
  <xsl:param name="IsLat" select="'True'"/>
  <xsl:choose>
    <!-- Null angle value -->
    <xsl:when test="string(number($TheAngle))='NaN'">?</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'">S</xsl:when>
              <xsl:otherwise>W</xsl:otherwise>
            </xsl:choose>
          </xsl:when>
          <xsl:otherwise> <!-- Positive value -->
            <xsl:choose>
              <xsl:when test="$IsLat = 'True'">N</xsl:when>
              <xsl:otherwise>E</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:call-template name="FormatDMSAngle">
          <xsl:with-param name="DecimalAngle" select="$PosAngle"/>
          <xsl:with-param name="SecDecPlaces" select="5"/>
        </xsl:call-template>
      </xsl:variable>

      <xsl:value-of select="concat($latLongAngle, $Sign)"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************ Return duration time in hours:min:sec ************* -->
<!-- **************************************************************** -->
<xsl:template name="DurationTime">
  <xsl:param name="seconds"/>

  <xsl:variable name="minutes" select="floor($seconds div 60)"/>
  <xsl:variable name="tempSecs" select="$seconds - $minutes * 60"/>
  <xsl:variable name="hoursMins">
    <xsl:choose>
      <xsl:when test="$minutes &gt;= 60">
        <xsl:variable name="tempHours">
          <xsl:value-of select="format-number(floor($minutes div 60), '00')"/>
        </xsl:variable>
        <xsl:variable name="tempMins">
          <xsl:value-of select="$minutes - $tempHours * 60"/>
        </xsl:variable>
        <xsl:value-of select="concat($tempHours, ':', format-number($tempMins, '00'))"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="concat('00:', format-number($minutes, '00'))"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:value-of select="concat($hoursMins, ':', format-number($tempSecs, '00'))"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******** Return nbr of seconds between given TimeStamps ******** -->
<!-- **************************************************************** -->
<xsl:template name="ElapsedSeconds">
  <xsl:param name="firstTimeStamp"/>
  <xsl:param name="secondTimeStamp"/>

  <xsl:variable name="firstJulianDay">
    <xsl:call-template name="JulianDay">
      <xsl:with-param name="timeStamp" select="$firstTimeStamp"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="secondJulianDay">
    <xsl:call-template name="JulianDay">
      <xsl:with-param name="timeStamp" select="$secondTimeStamp"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="elapsedDays">
    <xsl:choose>
      <xsl:when test="$secondJulianDay &lt; $firstJulianDay">  <!-- Must have gone into the next year -->
        <xsl:variable name="endOfYearJulianDay">
          <xsl:call-template name="JulianDay">
            <xsl:with-param name="timeStamp" select="concat(substring($firstJulianDay, 1, 4), '-12-31T24:00:00')"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:value-of select="$secondJulianDay + $endOfYearJulianDay - $firstJulianDay"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$secondJulianDay - $firstJulianDay"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:value-of select="round($elapsedDays * $secondsInDay)"/>

</xsl:template>


<!-- **************************************************************** -->
<!-- ********* Return the Julian Day for a given TimeStamp ********** -->
<!-- **************************************************************** -->
<xsl:template name="JulianDay">
  <!-- The formula used in this function is valid for the years 1901 - 2099 -->
  <xsl:param name="timeStamp"/>

  <xsl:variable name="Y" select="substring($timeStamp, 1, 4)"/>
  <xsl:variable name="M" select="substring($timeStamp, 6, 2)"/>
  <xsl:variable name="D" select="substring($timeStamp, 9, 2)"/>
  <xsl:variable name="h" select="substring($timeStamp, 12, 2)"/>
  <xsl:variable name="m" select="substring($timeStamp, 15, 2)"/>
  <xsl:variable name="s" select="substring($timeStamp, 18, 2)"/>

  <xsl:value-of select="format-number(367 * $Y - floor(7 * ($Y + floor(($M + 9) div 12)) div 4) +
                                      floor(275 * $M div 9) + $D + 1721013.5 +
                                      ($h + $m div 60 + $s div 3600) div 24, '0.000000000')"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- *************** Return Initialisation Event Text *************** -->
<!-- **************************************************************** -->
<xsl:template name="initEventText">
  <xsl:param name="event"/>
  
  <xsl:choose>
    <xsl:when test="$event = 'GainedInitialisation'">Gained Init</xsl:when>
    <xsl:when test="$event = 'LostInitialisation'">Lost Init</xsl:when>
    <xsl:when test="$event = 'FailedInitialisation'">Failed Init</xsl:when>
    <xsl:when test="$event = 'BadInitialisation'">Bad Init</xsl:when>
    <xsl:when test="$event = 'HighRMS'">High RMS</xsl:when>
    <xsl:when test="$event = 'GoodRMS'">Good RMS</xsl:when>
    <xsl:when test="$event = 'UserCancelled'">User Cancelled</xsl:when>
  </xsl:choose>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Output Column Headings ********************** -->
<!-- **************************************************************** -->
<xsl:template name="ColumnHeadings">
   <Row ss:AutoFitHeight="0">
    <Cell ss:MergeDown="1" ss:StyleID="m33657300"><Data ss:Type="String">NOKTA&#10;NO</Data><NamedCell
      ss:Name="Print_Titles"/></Cell>
    <Cell ss:MergeDown="1" ss:StyleID="m33657320"><Data ss:Type="String">OKUMA ZAMANI&#10;(UTC)</Data><NamedCell
      ss:Name="Print_Titles"/></Cell>
    <Cell ss:MergeDown="1" ss:StyleID="m33657340"><Data ss:Type="String">EPOK&#10;SAYISI</Data><NamedCell
      ss:Name="Print_Titles"/></Cell>
    <Cell ss:MergeDown="1" ss:StyleID="m33657360"><Data ss:Type="String">VERİ TOPLAMA ARALIĞI</Data><NamedCell
      ss:Name="Print_Titles"/></Cell>
    <Cell ss:MergeDown="1" ss:StyleID="m33657380"><ss:Data ss:Type="String"
      xmlns="http://www.w3.org/TR/REC-html40">UYDU &#10;SAYISI&#10;<Font
       Size="8">(GPS/GLONASS)</Font></ss:Data><NamedCell
      ss:Name="Print_Titles"/></Cell>
    <Cell ss:MergeDown="1" ss:StyleID="m33657400"><Data ss:Type="String">RMS&#10;(m)</Data><NamedCell
      ss:Name="Print_Titles"/></Cell>
    <Cell ss:MergeDown="1" ss:StyleID="m33657440"><Data ss:Type="String">PDOP</Data><NamedCell
      ss:Name="Print_Titles"/></Cell>
    <Cell ss:MergeDown="1" ss:StyleID="m33657420"><Data ss:Type="String">TAM SAYI&#10;BELİRSİZLİK&#10;ÇÖZÜM&#10;DURUMU</Data><NamedCell
      ss:Name="Print_Titles"/></Cell>
    <Cell ss:MergeDown="1" ss:StyleID="m33657460"><ss:Data ss:Type="String"
      xmlns="http://www.w3.org/TR/REC-html40">Mountpoint&#10;<Font Size="6">(VRS,FKP,MAC) &#10;&#10;TUSAGA-Aktif&#10;Sistemi Yayın Bağlantı&#10;Noktası</Font></ss:Data><NamedCell

      ss:Name="Print_Titles"/></Cell>

   <Cell ss:MergeDown="1" ss:StyleID="m33657460"><ss:Data ss:Type="String"
      xmlns="http://www.w3.org/TR/REC-html40">YATAY&#10;<Font Size="8">HASSASİYET</Font></ss:Data><NamedCell
      ss:Name="Print_Titles"/></Cell>      
           
           
 <Cell ss:MergeDown="1" ss:StyleID="m33657460"><ss:Data ss:Type="String"
      xmlns="http://www.w3.org/TR/REC-html40">DÜŞEY&#10;<Font Size="8">HASSASİYET</Font></ss:Data><NamedCell
      ss:Name="Print_Titles"/></Cell>           

 <!--
    <xsl:call-template name="OutputCell">
      <xsl:with-param name="styleID">s29"</xsl:with-param>
      <xsl:with-param name="cellType">String</xsl:with-param>
      <xsl:with-param name="cellText" select="$DATUM_DOM_DG"/>
    </xsl:call-template>
    <Cell ss:MergeAcross="2" ss:StyleID="m33657280"><Data ss:Type="String">KESİN KOORDİNAT ($DATUM_DOM_DG)</Data><NamedCell  ss:Name="Print_Titles"/></Cell> 
-->

    <Cell ss:MergeAcross="2" ss:StyleID="m33657280"><Data ss:Type="String">KESİN KOORDİNAT (<xsl:value-of select="$ZoneName"/>-<xsl:value-of select="$DatumName"/>-2005/0)</Data><NamedCell  ss:Name="Print_Titles"/></Cell> 
   </Row>
   <Row ss:AutoFitHeight="0" ss:Height="54.75">
    <Cell ss:Index="12" ss:StyleID="s22"><Data ss:Type="String">SAĞA DEĞER &#10;(y)&#10;(m)</Data><NamedCell
      ss:Name="Print_Titles"/></Cell>
    <Cell ss:StyleID="s22"><Data ss:Type="String">YUKARI DEĞER &#10;(x)&#10;(m)</Data><NamedCell
      ss:Name="Print_Titles"/></Cell>
    <Cell ss:StyleID="s22"><Data ss:Type="String">ELİPSOİT YÜKSEKLİĞİ (h)&#10;(m)</Data><NamedCell
      ss:Name="Print_Titles"/></Cell>
   </Row>



</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Output Project Details ********************** -->
<!-- **************************************************************** -->
<xsl:template name="ProjectDetails">



</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="$month = 1">Jan</xsl:when>
      <xsl:when test="$month = 2">Feb</xsl:when>
      <xsl:when test="$month = 3">Mar</xsl:when>
      <xsl:when test="$month = 4">Apr</xsl:when>
      <xsl:when test="$month = 5">May</xsl:when>
      <xsl:when test="$month = 6">Jun</xsl:when>
      <xsl:when test="$month = 7">Jul</xsl:when>
      <xsl:when test="$month = 8">Aug</xsl:when>
      <xsl:when test="$month = 9">Sep</xsl:when>
      <xsl:when test="$month = 10">Oct</xsl:when>
      <xsl:when test="$month = 11">Nov</xsl:when>
      <xsl:when test="$month = 12">Dec</xsl:when>
    </xsl:choose>
  </xsl:variable>

  <xsl:value-of select="concat(substring($date, 9, 2), ' ', $namedMonth, ' ', substring($date, 1, 4))"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ***************** Output Column Definitions ******************** -->
<!-- **************************************************************** -->
<xsl:template name="DefineColumns">
   <Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="70.5"/>
   <xsl:call-template name="NewLine"/>
   <Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="111.5"/>
   <xsl:call-template name="NewLine"/>
   <Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="58.5"/>
   <xsl:call-template name="NewLine"/>
   <Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="69.75" ss:Span="1"/>
   <xsl:call-template name="NewLine"/>
   <Column ss:Index="6" ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="36"/>
   <xsl:call-template name="NewLine"/>
   <Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="34.5"/>
   <xsl:call-template name="NewLine"/>
   <Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="60.5"/>
   <xsl:call-template name="NewLine"/>
   <Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="60.5"/>
   <xsl:call-template name="NewLine"/>
   <Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="50.75"/>
   <xsl:call-template name="NewLine"/>
   <Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="50"/>
   <xsl:call-template name="NewLine"/>
   <Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="81" ss:Span="2"/>
   <xsl:call-template name="NewLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ******************* Output Default Styles ********************** -->
<!-- **************************************************************** -->
<xsl:template name="OutputStyles">
  <Styles>
    <xsl:call-template name="NewLine"/>
    <Style ss:ID="Default" ss:Name="Normal">
      <Alignment ss:Vertical="Bottom"/>
      <Borders/>
      <Font/>
      <Interior/>
      <NumberFormat/>
      <Protection/>
    </Style>
    <xsl:call-template name="NewLine"/>
  <Style ss:ID="m33657280">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
   <Borders>
    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="2"/>
   </Borders>
   <Font ss:FontName="Arial Tur" x:CharSet="162" ss:Bold="1"/>
  </Style>
    <xsl:call-template name="NewLine"/>

  <Style ss:ID="m33657300">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
   <Borders>
    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="2"/>
   </Borders>
  </Style>
    <xsl:call-template name="NewLine"/>
  <Style ss:ID="m33657320">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
   <Borders>
    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="2"/>
   </Borders>
  </Style>
    <xsl:call-template name="NewLine"/>
  <Style ss:ID="m33657340">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
   <Borders>
    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="2"/>
   </Borders>
  </Style>
    <xsl:call-template name="NewLine"/>
  <Style ss:ID="m33657360">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
   <Borders>
    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="2"/>
   </Borders>
  </Style>
    <xsl:call-template name="NewLine"/>
  <Style ss:ID="m33657380">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
   <Borders>
    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="2"/>
   </Borders>
  </Style>
    <xsl:call-template name="NewLine"/>
  <Style ss:ID="m33657400">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
   <Borders>
    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="2"/>
   </Borders>
  </Style>
    <xsl:call-template name="NewLine"/>
  <Style ss:ID="m33657420">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
   <Borders>
    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="2"/>
   </Borders>
   <Font ss:FontName="Arial Tur" x:CharSet="162" ss:Size="8"/>
  </Style>
    <xsl:call-template name="NewLine"/>
  <Style ss:ID="m33657440">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
   <Borders>
    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="2"/>
   </Borders>
   <Font ss:FontName="Arial Tur" x:CharSet="162"/>
  </Style>
    <xsl:call-template name="NewLine"/>
  <Style ss:ID="m33657460">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
   <Borders>
    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="2"/>
   </Borders>
   <Font ss:FontName="Arial Tur" x:CharSet="162" ss:Size="8"/>
  </Style>
    <xsl:call-template name="NewLine"/>
  <Style ss:ID="s21">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
  </Style>
    <xsl:call-template name="NewLine"/>
  <Style ss:ID="s22">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
   <Borders>
    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
   </Borders>
   <Font ss:FontName="Arial Tur" x:CharSet="162" ss:Size="8"/>
  </Style>
    <xsl:call-template name="NewLine"/>

    <Style ss:ID="s23">   <!-- Style for time values - right jusified -->
      <Alignment ss:Horizontal="Right" ss:Vertical="Bottom"/>
      <Font x:Family="Swiss"/>
      <NumberFormat ss:Format="hh:mm:ss;@"/>
    </Style>
    <xsl:call-template name="NewLine"/>

    <Style ss:ID="s24">   <!-- Style for bold text values - left justified -->
      <Alignment ss:Horizontal="Left" ss:Vertical="Bottom"/>
      <Font x:Family="Swiss" ss:Bold="1"/>
    </Style>
    <xsl:call-template name="NewLine"/>

    <Style ss:ID="s25">   <!-- Style for normal text values - left justified -->
      <Alignment ss:Horizontal="Left" ss:Vertical="Bottom"/>
      <Font x:Family="Swiss"/>
    </Style>
    <xsl:call-template name="NewLine"/>

    <Style ss:ID="s26">   <!-- Style for 3 decimal places numeric values - right justified -->
      <Alignment ss:Horizontal="Right" ss:Vertical="Bottom"/>
      <Font x:Family="Swiss"/>
      <NumberFormat ss:Format="0.000"/>
	   <Borders>
	    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
	    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
	    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
	    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
	   </Borders>
    </Style>
    <xsl:call-template name="NewLine"/>

    <Style ss:ID="s27">   <!-- Style for 2 decimal places numeric values - right justified -->
      <Alignment ss:Horizontal="Right" ss:Vertical="Bottom"/>
      <Font x:Family="Swiss"/>
      <NumberFormat ss:Format="0.00"/>
	   <Borders>
	    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
	    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
	    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
	    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
	   </Borders>

    </Style>
    <xsl:call-template name="NewLine"/>

    <Style ss:ID="s28">   <!-- Style for 0 decimal places numeric values - right justified -->
      <Alignment ss:Horizontal="Right" ss:Vertical="Bottom"/>
      <Font x:Family="Swiss"/>
      <NumberFormat ss:Format="0"/>
    </Style>
    <xsl:call-template name="NewLine"/>

    <Style ss:ID="s29">   <!-- Style for normal text values - right justified -->
      <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/>
      <Font x:Family="Swiss"/>
	   <Borders>
	    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
	    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
	    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
	    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
	   </Borders>
    </Style>•
    <xsl:call-template name="NewLine"/>

    <Style ss:ID="s30">   <!-- Style for bold text values - centre justified with grey background -->
      <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/>
      <Font Size="5" x:Family="Swiss"/>
    </Style>
    <xsl:call-template name="NewLine"/>

    <Style ss:ID="s31">   <!-- Style for 3 decimal places numeric values - right justified -->
      <Alignment ss:Horizontal="Right" ss:Vertical="Bottom"/>
      <Font x:Family="Swiss"/>
      <NumberFormat ss:Format="0.000"/>
	   <Borders>
	    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
	    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
	    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
	    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
	   </Borders>
    </Style>
    <xsl:call-template name="NewLine"/>

    <Style ss:ID="s31_5">   <!-- Style for 5 decimal places numeric values - right justified -->
      <Alignment ss:Horizontal="Right" ss:Vertical="Bottom"/>
      <Font x:Family="Swiss"/>
      <NumberFormat ss:Format="0.00000"/>
	   <Borders>
	    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
	    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
	    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
	    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
	   </Borders>

    </Style>
    <xsl:call-template name="NewLine"/>




  <Style ss:ID="s40">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
   <Borders/>
  </Style>
 </Styles>
    <xsl:call-template name="NewLine"/>
  <xsl:call-template name="NewLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- *********************** Output a Cell ************************** -->
<!-- **************************************************************** -->
<xsl:template name="OutputCell">
  <xsl:param name="index" select="''"/>
  <xsl:param name="styleID" select="''"/>
  <xsl:param name="cellType" select="'String'"/>
  <xsl:param name="cellText" select="''"/>
  <xsl:param name="formula" select="''"/>
  <xsl:param name="merge" select="0"/>

  <Cell>
    <xsl:if test="$index != ''">
      <xsl:attribute name="ss:Index">
        <xsl:value-of select="$index"/>
      </xsl:attribute>
    </xsl:if>
    <xsl:if test="$formula != ''">
      <xsl:attribute name="ss:Formula">
        <xsl:value-of select="$formula"/>
      </xsl:attribute>
    </xsl:if>
    <xsl:if test="$merge &gt; 0">
      <xsl:attribute name="ss:MergeAcross">
        <xsl:value-of select="$merge"/>
      </xsl:attribute>
    </xsl:if>
    <xsl:attribute name="ss:StyleID"><xsl:value-of select="$styleID"/></xsl:attribute>
    <xsl:if test="$cellText != ''">
      <Data>
        <xsl:attribute name="ss:Type"><xsl:value-of select="$cellType"/></xsl:attribute>
        <xsl:value-of select="$cellText"/>
      </Data>
    </xsl:if>
  </Cell>

  <xsl:call-template name="NewLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ********************** Start a new row ************************* -->
<!-- **************************************************************** -->
<xsl:template name="StartRow">
  <xsl:param name="index" select="''"/>
  <xsl:param name="height" select="''"/>

  <xsl:variable name="defnStr">
    <xsl:if test="$index != ''">
      <xsl:text> ss:Index="</xsl:text>
      <xsl:value-of select="$index"/>
      <xsl:text>"</xsl:text>
    </xsl:if>
    <xsl:if test="$height != ''">
      <xsl:text> ss:Height="</xsl:text>
      <xsl:value-of select="$height"/>
      <xsl:text>"</xsl:text>
    </xsl:if>
  </xsl:variable>

  <xsl:text disable-output-escaping="yes">&lt;Row</xsl:text>
  <xsl:value-of select="$defnStr"/>
  <xsl:text disable-output-escaping="yes">&gt;</xsl:text>
  <xsl:call-template name="NewLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ************************** End a row *************************** -->
<!-- **************************************************************** -->
<xsl:template name="EndRow">
  <xsl:text disable-output-escaping="yes">&lt;/Row&gt;</xsl:text>
  <xsl:call-template name="NewLine"/>
</xsl:template>


<!-- **************************************************************** -->
<!-- ****************** Output a New Line CRLF ********************** -->
<!-- **************************************************************** -->
<xsl:template name="NewLine">
  <xsl:text>&#13;&#10;</xsl:text>
</xsl:template>


</xsl:stylesheet>