<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns="http://earth.google.com/kml/2.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<!-- An xsl template for displaying data as KML file. 

     Copyright (c) 2006, Valery Hronusov aka Valery35 (xbbster(at)gmail.com) . All rights reserved.
     	
     Revision History: Created 02.09.2006 

-->
	<xsl:output method="xml" />
	<xsl:template match="/">
		<kml>
			<Document>
				<Snippet maxLines="0"></Snippet>
				<name>
					Path calculator
				</name>
				<StyleMap id="default">
					<Pair>
						<key>normal</key>
						<styleUrl>flatfile://kh.google.com:80/styles/#15899:Class 3 - initial (site) (normal)</styleUrl>
					</Pair>
					<Pair>
						<key>highlight</key>
						<styleUrl>flatfile://kh.google.com:80/styles/#15899:Class 3 - initial (site) (highlight)</styleUrl>
					</Pair>
				</StyleMap>
				<Style id="15899:Class 3 - initial (site) (highlight)">
					<IconStyle>
						<Icon>
							<href>http://kh.google.com:80/flatfile?lf-0-icons/airports_new_nh.png</href>
							<y>32</y>
							<w>32</w>
							<h>32</h>
						</Icon>
					</IconStyle>
					<LabelStyle></LabelStyle>
					<LineStyle>
						<antialias>0</antialias>
					</LineStyle>
					<PolyStyle>
						<fill>0</fill>
						<outline>0</outline>
					</PolyStyle>
				</Style>
				<Style id="15899:Class 3 - initial (site) (normal)">
					<IconStyle>
						<scale>0.9</scale>
						<Icon>
							<href>http://kh.google.com:80/flatfile?lf-0-icons/airports_new_nh.png</href>
							<w>32</w>
							<h>32</h>
						</Icon>
					</IconStyle>
					<LabelStyle>
						<scale>0</scale>
					</LabelStyle>
					<LineStyle>
						<antialias>0</antialias>
					</LineStyle>
					<PolyStyle>
						<fill>0</fill>
						<outline>0</outline>
					</PolyStyle>
				</Style>
				<xsl:apply-templates />
			</Document>
		</kml>
	</xsl:template>
	<xsl:template match="sheet">
		<!-- Points -->
		<Folder>
			<Snippet maxLines="0"></Snippet>
			<name>Points</name>
			<xsl:for-each select="row[@row >= 2]">
				<Placemark>
					<Snippet maxLines="0"></Snippet>
					<name>
						<xsl:value-of select="cell[@col=0]" />
					</name>
					<description>
					<![CDATA[to: ]]><xsl:value-of select="cell[@col=0]" /><![CDATA[
						<br>seg: ]]><xsl:value-of select="format-number(cell[@col=3]/@value,'#.000')" /><![CDATA[km ]]>
						<xsl:value-of select="format-number(cell[@col=3]/@value*0.621371192,'#.000')" /><![CDATA[mi
						<br>sum: ]]><xsl:value-of select="format-number(cell[@col=4]/@value,'#.000')" /><![CDATA[km ]]>
						<xsl:value-of select="format-number(cell[@col=4]/@value*0.621371192,'#.000')" /><![CDATA[mi
					]]>
					</description>
					<styleUrl>#default</styleUrl>
					<TimeStamp>
						<when>
							<xsl:value-of select="cell[@col=7]/@value" />
						</when>
					</TimeStamp>
					<Point>
						<coordinates>
						<xsl:value-of select="cell[@col=2]/@value" />,
						<xsl:value-of select="cell[@col=1]/@value" />
					</coordinates>
					</Point>
				</Placemark>
			</xsl:for-each>
		</Folder>
		<!-- /Points -->
		<!-- Segments -->
		<Folder>
			<Snippet maxLines="0"></Snippet>
			<name>Segments</name>
			<xsl:for-each select="row[@row >= 3]">
				<xsl:variable name="row" select="@row - 1" />
				<xsl:variable name="prev" select="../row[@row = $row]" />
				<Placemark>
					<name>
						from: <xsl:value-of select="$prev/cell[@col=0]" /> to: <xsl:value-of select="cell[@col=0]" />
					</name>
					<Snippet maxLines="0"></Snippet>
					<description>
					<![CDATA[
						seg: ]]><xsl:value-of select="format-number(cell[@col=3]/@value,'#.000')" /><![CDATA[km ]]>
						<xsl:value-of select="format-number(cell[@col=3]/@value*0.621371192,'#.000')" /><![CDATA[mi<br>
						sum: ]]><xsl:value-of select="format-number(cell[@col=4]/@value,'#.000')" /><![CDATA[km ]]>
						<xsl:value-of select="format-number(cell[@col=4]/@value*0.621371192,'#.000')" /><![CDATA[mi
					]]>
					</description>
					<Style>
						<LineStyle>
							<color>7fffaaff</color>
							<width>4</width>
						</LineStyle>
					</Style>
					<TimeStamp>
						<when>
							<xsl:value-of select="cell[@col=7]/@value" />
						</when>
					</TimeStamp>
					<LineString>
						<tessellate>1</tessellate>
						<coordinates>
							<xsl:value-of select="$prev/cell[@col=2]/@value" />,<xsl:value-of select="$prev/cell[@col=1]/@value" />,0
							<xsl:value-of select="cell[@col=2]/@value" />,<xsl:value-of select="cell[@col=1]/@value" />,0
						</coordinates>
					</LineString>
				</Placemark>
			</xsl:for-each>
		</Folder>
		<!-- Segments -->
		<!-- Path-->
		<Folder>
			<Snippet maxLines="0"></Snippet>
			<name>Path</name>
			<Placemark>
				<name>
					Path
				</name>
				<Snippet maxLines="0"></Snippet>
				<styleUrl>#default</styleUrl>
				<LineString>
					<tessellate>1</tessellate>
					<coordinates>
						<xsl:for-each select="row[@row >= 3]">
							<xsl:variable name="row" select="@row - 1" />
							<xsl:variable name="prev" select="../row[@row = $row]" />
							<xsl:value-of select="$prev/cell[@col=2]/@value" />,<xsl:value-of select="$prev/cell[@col=1]/@value" />,0
							<xsl:value-of select="cell[@col=2]/@value" />,<xsl:value-of select="cell[@col=1]/@value" />,0
						</xsl:for-each>
					</coordinates>
				</LineString>
			</Placemark>
		</Folder>
		<!-- /Path-->
	</xsl:template>
</xsl:stylesheet>
