~ubuntu-branches/ubuntu/natty/pytrainer/natty-proposed

« back to all changes in this revision

Viewing changes to import/translate_garmintcxv2.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-02-04 06:07:11 UTC
  • mfrom: (4.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100204060711-25n5aw66w5egeiph
Tags: 1.7.1-1ubuntu1
* Merge from debian testing, remaining changes:
  - debian/control:
    + Replace Depends on iceweasel with firefox | abrowser.
    + Bump python-dev,debhelper build-dependencies.
    - Drop dependency on python-glade2 (libglade -> gtkbuilder transition).
  - debian/rules:
    + Append --install-laoyut=deb to setup.py install to prevent a build
      failure with Python 2.6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0"?>
 
2
 
 
3
<!-- note defining a namespace for TrainingCenterDatabase as the translation does not seem to work with a default namespace -->
 
4
<xsl:stylesheet version="1.0"
 
5
xmlns:t="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2"
 
6
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
7
>
 
8
<xsl:output  method="xml" indent="yes" omit-xml-declaration="no"/> 
 
9
 
 
10
<!-- this is a bit of a messy way to get whitespace into the output - but it works -->
 
11
<xsl:variable name="newline"><xsl:text>
 
12
</xsl:text></xsl:variable>
 
13
 
 
14
<xsl:template match="/">
 
15
    <gpx creator="pytrainer http://sourceforge.net/projects/pytrainer" version="1.1" 
 
16
        xmlns="http://www.topografix.com/GPX/1/1"
 
17
    xmlns:gpxdata="http://www.cluetrust.com/XML/GPXDATA/1/0" >
 
18
 
 
19
    <xsl:value-of select="$newline"/>
 
20
    <xsl:variable name="sport"><xsl:value-of select="t:Activity/@Sport"/></xsl:variable>
 
21
    <xsl:variable name="time"><xsl:value-of select="t:Activity/t:Id"/></xsl:variable>
 
22
    <xsl:variable name="name"><xsl:value-of select="$sport"/><xsl:value-of  select="substring($time, 1,10)"/></xsl:variable>
 
23
    <metadata><xsl:value-of select="$newline"/>
 
24
    <name><xsl:value-of select="$name"/></name><xsl:value-of select="$newline"/>
 
25
    <link href="http://sourceforge.net/projects/pytrainer"/><xsl:value-of select="$newline"/>
 
26
    <time><xsl:value-of select="$time"/></time><xsl:value-of select="$newline"/>
 
27
    </metadata><xsl:value-of select="$newline"/>
 
28
    <trk><xsl:value-of select="$newline"/>
 
29
    <xsl:for-each select="t:Activity/t:Lap">
 
30
        <trkseg><xsl:value-of select="$newline"/>
 
31
        <xsl:variable name="calories"><xsl:value-of select="t:Calories"/></xsl:variable>
 
32
        <xsl:for-each select="t:Track/t:Trackpoint">
 
33
            <!-- only output a trkpt if a position exists -->
 
34
            <xsl:if test="t:Position">
 
35
                <xsl:variable name="lat"><xsl:value-of select="t:Position/t:LatitudeDegrees"/></xsl:variable>
 
36
                <xsl:variable name="lon"><xsl:value-of select="t:Position/t:LongitudeDegrees"/></xsl:variable>
 
37
                <trkpt lat="{$lat}" lon="{$lon}"><xsl:value-of select="$newline"/>
 
38
                <ele><xsl:value-of select="t:AltitudeMeters"/></ele><xsl:value-of select="$newline"/>
 
39
                <time><xsl:value-of select="t:Time"/></time><xsl:value-of select="$newline"/>
 
40
                                <xsl:if test="t:HeartRateBpm/t:Value">
 
41
                        <extensions><xsl:value-of select="$newline"/>
 
42
                    <gpxdata:hr><xsl:value-of select="t:HeartRateBpm/t:Value"/></gpxdata:hr><xsl:value-of select="$newline"/>
 
43
                    </extensions><xsl:value-of select="$newline"/>
 
44
                                </xsl:if>
 
45
                                <xsl:if test="t:Cadence">
 
46
                        <extensions><xsl:value-of select="$newline"/>
 
47
                    <gpxdata:cadence><xsl:value-of select="t:Cadence"/></gpxdata:cadence><xsl:value-of select="$newline"/>
 
48
                    </extensions><xsl:value-of select="$newline"/>
 
49
                                </xsl:if>
 
50
                </trkpt><xsl:value-of select="$newline"/>
 
51
            </xsl:if>
 
52
        </xsl:for-each>
 
53
        <xsl:value-of select="$newline"/>        
 
54
        <extensions><xsl:value-of select="$newline"/>
 
55
        <gpxdata:sportType><xsl:value-of select="$sport"/></gpxdata:sportType><xsl:value-of select="$newline"/>
 
56
        <gpxdata:calories><xsl:value-of select="$calories"/></gpxdata:calories><xsl:value-of select="$newline"/>
 
57
        </extensions><xsl:value-of select="$newline"/>
 
58
        </trkseg><xsl:value-of select="$newline"/>
 
59
    </xsl:for-each>
 
60
    </trk><xsl:value-of select="$newline"/>
 
61
<!-- Lap Data -->
 
62
        <xsl:value-of select="$newline"/>
 
63
        <extensions><xsl:value-of select="$newline"/>
 
64
    <xsl:for-each select="t:Activity/t:Lap">
 
65
    <xsl:variable name="vIndex">
 
66
    <xsl:number count="t:Lap"/>
 
67
    </xsl:variable>
 
68
                <gpxdata:lap><xsl:value-of select="$newline"/>
 
69
                        <gpxdata:index><xsl:value-of select="$vIndex"/></gpxdata:index><xsl:value-of select="$newline"/>
 
70
            <xsl:variable name="stlat"><xsl:value-of select="t:Track/t:Trackpoint/t:Position[1]/t:LatitudeDegrees"/></xsl:variable>
 
71
            <xsl:variable name="stlon"><xsl:value-of select="t:Track/t:Trackpoint/t:Position[1]/t:LongitudeDegrees"/></xsl:variable>
 
72
            <gpxdata:startPoint lat="{$stlat}" lon="{$stlon}"/><xsl:value-of select="$newline"/>
 
73
                        <xsl:variable name="cnt"><xsl:value-of select="count(t:Track/t:Trackpoint/t:Position)-1"/></xsl:variable>
 
74
                        <xsl:variable name="endlat"><xsl:value-of select="t:Track/t:Trackpoint[number($cnt)]/t:Position/t:LatitudeDegrees"/></xsl:variable>
 
75
                        <xsl:variable name="endlon"><xsl:value-of select="t:Track/t:Trackpoint[number($cnt)]/t:Position/t:LongitudeDegrees"/></xsl:variable>
 
76
                <gpxdata:endPoint lat="{$endlat}" lon="{$endlon}"/><xsl:value-of select="$newline"/>
 
77
                        <gpxdata:startTime><xsl:value-of select="@StartTime"/></gpxdata:startTime><xsl:value-of select="$newline"/>
 
78
                        <gpxdata:elapsedTime><xsl:value-of select="t:TotalTimeSeconds"/></gpxdata:elapsedTime><xsl:value-of select="$newline"/>
 
79
                        <gpxdata:calories><xsl:value-of select="t:Calories"/></gpxdata:calories><xsl:value-of select="$newline"/>
 
80
                        <gpxdata:distance><xsl:value-of select="t:DistanceMeters"/></gpxdata:distance><xsl:value-of select="$newline"/>
 
81
                        <!-- <gpxdata:trackReference>Reference information for the track which corresponds to this lap type="trackReferenceType"</gpxdata:trackReference><xsl:value-of select="$newline"/> -->
 
82
                        <gpxdata:summary><xsl:value-of select="$newline"/>
 
83
                                <MaximumSpeed kind="max"><xsl:value-of select="t:MaximumSpeed"/></MaximumSpeed><xsl:value-of select="$newline"/>
 
84
                                <AverageHeartRateBpm kind="avg"><xsl:value-of select="t:AverageHeartRateBpm/t:Value"/></AverageHeartRateBpm><xsl:value-of select="$newline"/>
 
85
                                <MaximumHeartRateBpm kind="max"><xsl:value-of select="t:MaximumHeartRateBpm/t:Value"/></MaximumHeartRateBpm><xsl:value-of select="$newline"/>
 
86
                        </gpxdata:summary><xsl:value-of select="$newline"/> 
 
87
                        <gpxdata:trigger><xsl:value-of select="t:TriggerMethod"/></gpxdata:trigger><xsl:value-of select="$newline"/>
 
88
                        <gpxdata:intensity><xsl:value-of select="t:Intensity"/></gpxdata:intensity><xsl:value-of select="$newline"/>
 
89
                </gpxdata:lap><xsl:value-of select="$newline"/>
 
90
    </xsl:for-each>
 
91
    </extensions><xsl:value-of select="$newline"/>
 
92
 
 
93
    </gpx><xsl:value-of select="$newline"/>
 
94
</xsl:template>
 
95
</xsl:stylesheet>