2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3 <xsl:strip-space elements="*"/>
4 <xsl:output method="xml" indent="yes"/>
6 <xsl:template match="/">
8 <program name="subsurface" version="1"/>
9 <xsl:apply-templates select="/SUUNTO/MSG"/>
13 <xsl:template match="MSG">
14 <xsl:variable name="units" select="'si'"/>
16 <dive number="{DIVENUMBER}">
17 <xsl:attribute name="date">
18 <xsl:call-template name="dateConvert">
19 <xsl:with-param name="date" select="DATE"/>
23 <xsl:attribute name="time">
24 <xsl:value-of select="TIME"/>
27 <xsl:attribute name="duration">
28 <xsl:call-template name="timeConvert">
29 <xsl:with-param name="timeSec" select="DIVETIMESEC"/>
30 <xsl:with-param name="units" select="$units"/>
35 <xsl:when test="MEANDEPTH != ''">
36 <depth max="{concat(MAXDEPTH,' m')}" mean="{concat(MEANDEPTH, ' m')}"/>
39 <depth max="{concat(MAXDEPTH,' m')}"/>
43 <temperature air="{concat(AIRTEMP, ' C')}" water="{concat(WATERTEMPATEND, ' C')}"/>
44 <xsl:if test="SURFACETIME != '0'">
46 <xsl:call-template name="timeConvert">
47 <xsl:with-param name="timeSec" select="SURFACETIME" />
48 <xsl:with-param name="units" select="$units" />
52 <divemaster><xsl:value-of select="DIVEMASTER" /></divemaster>
53 <buddy><xsl:value-of select="PARTNER" /></buddy>
55 <xsl:when test="LOCATION != ''">
56 <location><xsl:value-of select="normalize-space(concat(LOCATION, ' ' , SITE))" /></location>
59 <xsl:if test="SITE != ''">
60 <location><xsl:value-of select="SITE" /></location>
65 <xsl:if test="WEIGTH != ''">
67 <xsl:attribute name="weight">
68 <xsl:value-of select="concat(WEIGTH, ' kg')"/>
74 <xsl:if test="LOGNOTES != ''">
75 <xsl:value-of select="LOGNOTES" />
77 <xsl:if test="WEATHER != ''">
78 Weather: <xsl:value-of select="WEATHER" />
80 <xsl:if test="WATERVISIBILITYDESC != ''">
81 Visibility: <xsl:value-of select="WATERVISIBILITYDESC" />
85 <!-- FIXME: add support for multiple cylinders, need sample data -->
87 <xsl:attribute name="o2">
89 <xsl:when test="O2PCT != ''">
90 <xsl:value-of select="concat(O2PCT, '%')"/>
92 <xsl:otherwise>21.0%</xsl:otherwise>
95 <xsl:if test="HEPCT != ''">
96 <xsl:attribute name="he">
97 <xsl:value-of select="concat(HEPCT, '%')"/>
100 <xsl:if test="CYLINDERDESCRIPTION != ''">
101 <xsl:attribute name="description">
102 <xsl:value-of select="CYLINDERDESCRIPTION"/>
105 <xsl:if test="CYLINDERSIZE != ''">
106 <xsl:attribute name="size">
108 <xsl:when test="CYLINDERUNITS = '0'">
109 <xsl:value-of select="concat(CYLINDERSIZE, ' l')"/>
112 <xsl:call-template name="cuft2l">
113 <xsl:with-param name="size" select="CYLINDERSIZE"/>
114 <xsl:with-param name="pressure" select="CYLINDERWORKPRESSURE"/>
120 <xsl:attribute name="start">
121 <xsl:variable name="number" select="CYLINDERSTARTPRESSURE"/>
122 <xsl:call-template name="pressure">
123 <xsl:with-param name="number" select="$number"/>
124 <xsl:with-param name="units" select="$units"/>
127 <xsl:attribute name="end">
128 <xsl:variable name="number" select="CYLINDERENDPRESSURE"/>
129 <xsl:call-template name="pressure">
130 <xsl:with-param name="number" select="$number"/>
131 <xsl:with-param name="units" select="$units"/>
134 <xsl:if test="CYLINDERWORKPRESSURE != '0'">
135 <xsl:attribute name="workpressure">
136 <xsl:variable name="number" select="CYLINDERWORKPRESSURE"/>
137 <xsl:call-template name="pressure">
138 <xsl:with-param name="number" select="$number"/>
139 <xsl:with-param name="units" select="$units"/>
145 <!-- DELTA is the sample interval -->
146 <xsl:variable name="delta">
148 <xsl:when test="SAMPLEINTERVAL != ''">
149 <xsl:value-of select="SAMPLEINTERVAL"/>
151 <xsl:otherwise>0</xsl:otherwise>
157 <!-- FIXME: test this with proper data -->
158 <xsl:for-each select="GASCHANGE">
159 <xsl:if test="MIXTIME != '0'">
160 <event name="gaschange">
161 <xsl:attribute name="value">
162 <xsl:value-of select="MIXVALUE" />
164 <xsl:attribute name="time">
165 <xsl:call-template name="timeConvert">
166 <xsl:with-param name="timeSec" select="MIXTIME"/>
167 <xsl:with-param name="units" select="'si'"/>
173 <!-- end gas change-->
175 <!-- dive sample - all the depth and temp readings -->
176 <xsl:for-each select="SAMPLE">
178 <xsl:when test="BOOKMARK = ''">
180 <xsl:attribute name="time">
181 <xsl:call-template name="timeConvert">
182 <xsl:with-param name="timeSec" select="SAMPLETIME"/>
183 <xsl:with-param name="units" select="'si'"/>
186 <xsl:attribute name="depth">
187 <xsl:value-of select="concat(DEPTH, ' m')"/>
189 <xsl:attribute name="temp">
190 <xsl:value-of select="TEMPERATURE"/>
192 <xsl:attribute name="pressure">
193 <xsl:call-template name="pressure">
194 <xsl:with-param name="number" select="PRESSURE"/>
195 <xsl:with-param name="units" select="$units"/>
201 <xsl:if test="BOOKMARK != 'Surface'">
202 <event name="{BOOKMARK}">
203 <xsl:attribute name="time">
204 <xsl:call-template name="timeConvert">
205 <xsl:with-param name="timeSec" select="SAMPLETIME"/>
206 <xsl:with-param name="units" select="'si'"/>
220 <!-- convert pressure to bars -->
221 <xsl:template name="pressure">
222 <xsl:param name="number"/>
223 <xsl:param name="units"/>
226 <xsl:when test="$number != ''">
227 <xsl:value-of select="concat(($number div 1000), ' bar')"/>
229 <xsl:otherwise>0</xsl:otherwise>
232 <!-- end convert pressure -->
234 <!-- convert cuft to liters-->
235 <xsl:template name="cuft2l">
236 <xsl:param name="size"/>
237 <xsl:param name="pressure"/>
239 <xsl:when test="$pressure != '0'">
240 <xsl:value-of select="concat(format-number((($size*28.3168466) div ($pressure div 1013.25)), '0.000'), ' l')" />
242 <xsl:otherwise>0</xsl:otherwise>
247 <!-- convert time in seconds to minutes:seconds -->
248 <xsl:template name="timeConvert">
249 <xsl:param name="timeSec"/>
250 <xsl:param name="units"/>
253 <xsl:when test="$timeSec = '0'">
254 <xsl:value-of select="'0:00 min'" />
256 <xsl:when test="$units = 'si'">
257 <xsl:value-of select="concat(floor(number($timeSec) div 60), ':', format-number(floor(number($timeSec) mod 60), '00'), ' min')"/>
260 <xsl:value-of select="concat(substring-before($timeSec, '.'), ':', format-number(substring-after($timeSec, '.'), '00'), ' min')"/>
264 <!-- end convert time -->
266 <!-- convert date from dotted notation to dash notation -->
267 <xsl:template name="dateConvert">
268 <xsl:param name="date" />
269 <xsl:value-of select="concat(substring($date,7,4), '-', substring($date,4,2), '-', substring($date,1,2))" />