<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:kml="http://earth.google.com/kml/2.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="xml" encoding="UTF-8" />
	<xsl:template match="/kml:kml/kml:Document">
		<xsl:call-template name="KML_to_LMX"/>
	</xsl:template>
	<xsl:template name="KML_to_LMX">
		<lm:lmx xmlns:lm="http://www.nokia.com/schemas/location/landmarks/1/0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nokia.com/schemas/location/landmarks/1/0/ lmx.xsd">
			<lm:landmarkCollection>
				<xsl:for-each select="kml:Placemark">
					<lm:landmark>
						<lm:name>
							<xsl:value-of select="kml:name"/>
						</lm:name>
						<lm:description>
							<xsl:value-of select="kml:description"/>
						</lm:description>
						<lm:coordinates>
							<xsl:variable name="coord" select="kml:Point/kml:coordinates"/>
							<xsl:variable name="long" select="substring-before($coord, ',')"/>
							<xsl:variable name="lat" select="substring-before(substring-after($coord, ','), ',')"/>
							<lm:latitude>
								<xsl:value-of select="$lat"/>
							</lm:latitude>
							<lm:longitude>
								<xsl:value-of select="$long"/>
							</lm:longitude>
						</lm:coordinates>
					</lm:landmark>
				</xsl:for-each>
			</lm:landmarkCollection>
		</lm:lmx>
	</xsl:template>
</xsl:stylesheet>
