1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<divelog program='subsurface-import' version='2'>
<dives>
<xsl:apply-templates select="DIVELOGSDATA"/>
</dives>
</divelog>
</xsl:template>
<xsl:template match="*">
<xsl:variable name="delta">
<xsl:value-of select="SAMPLEINTERVAL"/>
</xsl:variable>
<dive>
<xsl:attribute name="number">
<xsl:value-of select="DIVELOGSDIVENUMBER"/>
</xsl:attribute>
<xsl:attribute name="date">
<xsl:value-of select="DATE"/>
</xsl:attribute>
<xsl:attribute name="time">
<xsl:value-of select="TIME"/>
</xsl:attribute>
<xsl:if test="DIVETIMESEC != ''">
<xsl:attribute name="duration">
<xsl:value-of select="concat(floor(number(DIVETIMESEC) div 60), ':', format-number(floor(number(DIVETIMESEC) mod 60), '00'), ' min')"/>
</xsl:attribute>
</xsl:if>
<depth>
<xsl:if test="MAXDEPTH != ''">
<xsl:attribute name="max">
<xsl:value-of select="concat(MAXDEPTH, ' m')"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="MEANDEPTH != ''">
<xsl:attribute name="mean">
<xsl:value-of select="concat(MEANDEPTH, ' m')"/>
</xsl:attribute>
</xsl:if>
</depth>
<location>
<xsl:for-each select="LOCATION|SITE">
<xsl:choose>
<xsl:when test="following-sibling::SITE[1] != ''">
<xsl:value-of select="concat(., ' / ')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</location>
<!-- WEATHER, WATERVIZIBILITY, BOATNAME -->
<xsl:if test="LAT != ''">
<gps>
<xsl:value-of select="concat(LAT, ' ', LNG)"/>
</gps>
</xsl:if>
<temperature>
<xsl:if test="AIRTEMP != ''">
<xsl:attribute name="air">
<xsl:value-of select="AIRTEMP"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="WATERTEMPMAXDEPTH != ''">
<xsl:attribute name="water">
<xsl:value-of select="WATERTEMPMAXDEPTH"/>
</xsl:attribute>
</xsl:if>
</temperature>
<buddy>
<xsl:value-of select="PARTNER"/>
</buddy>
<!-- Helium? -->
<cylinder>
<xsl:attribute name="o2">
<xsl:value-of select="O2PCT"/>
</xsl:attribute>
<xsl:attribute name="start">
<xsl:value-of select="CYLINDERSTARTPRESSURE"/>
</xsl:attribute>
<xsl:attribute name="end">
<xsl:value-of select="CYLINDERENDPRESSURE"/>
</xsl:attribute>
<xsl:if test="CYLINDERSIZE != ''">
<xsl:attribute name="size">
<xsl:value-of select="format-number(CYLINDERSIZE + CYLINDERSIZE * DBLTANK, '#.##')"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="WORKINGPRESSURE > 0">
<xsl:attribute name="workpressure">
<xsl:value-of select="WORKINGPRESSURE"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="description">
<xsl:value-of select="CYLINDERDESCRIPTION"/>
</xsl:attribute>
</cylinder>
<xsl:if test="WEIGHT != ''">
<weightsystem>
<xsl:attribute name="description">
<xsl:value-of select="'unknown'"/>
</xsl:attribute>
<xsl:attribute name="weight">
<xsl:value-of select="concat(WEIGHT, ' kg')"/>
</xsl:attribute>
</weightsystem>
</xsl:if>
<notes>
<xsl:value-of select="LOGNOTES"/>
</notes>
<xsl:for-each select="SAMPLE/DEPTH">
<sample>
<xsl:variable name="timeSec" select="(position() - 1) * $delta"/>
<xsl:attribute name="time">
<xsl:value-of select="concat(floor($timeSec div 60), ':',
format-number(floor($timeSec mod 60), '00'), ' min')"/>
</xsl:attribute>
<xsl:attribute name="depth">
<xsl:value-of select="concat(., ' m')"/>
</xsl:attribute>
</sample>
</xsl:for-each>
</dive>
</xsl:template>
</xsl:stylesheet>
|