Skip to content

Instantly share code, notes, and snippets.

@mlc
Created October 9, 2017 05:25
Show Gist options
  • Save mlc/5a587b0502138ae11f63075cfa84c11c to your computer and use it in GitHub Desktop.
Save mlc/5a587b0502138ae11f63075cfa84c11c to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns="http://www.topografix.com/GPX/1/1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
extension-element-prefixes="date">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<xsl:template match="/index">
<gpx version="1.1" creator="flickrdownload-to-gpx" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3">
<metadata>
<name><xsl:value-of select="user/username"/></name>
<desc>Flickr Photos</desc>
<link>
<xsl:attribute name="href"><xsl:value-of select="user/flickrUrls/@photos"/></xsl:attribute>
<text>Photos</text>
</link>
<time><xsl:value-of select="date:date-time()"/></time>
</metadata>
<xsl:for-each select="all_media/media[geodata/@latitude and string-length(geodata/@latitude)!=0 and privacy/@public='1']">
<xsl:variable name="rawdate" select="dates/taken/@raw"/>
<wpt>
<xsl:attribute name="lat"><xsl:value-of select="geodata/@latitude"/></xsl:attribute>
<xsl:attribute name="lon"><xsl:value-of select="geodata/@longitude"/></xsl:attribute>
<time><xsl:value-of select="substring($rawdate,1,10)"/>T<xsl:value-of select="substring($rawdate,12,8)"/>Z</time>
<name><xsl:value-of select="title"/></name>
<desc><xsl:value-of select="description"/></desc>
<link><xsl:attribute name="href"><xsl:value-of select="publicUrl"/></xsl:attribute></link>
</wpt>
</xsl:for-each>
</gpx>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment