summaryrefslogtreecommitdiffstats
path: root/xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2014-07-16 06:20:21 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-15 20:46:19 -0700
commit5a34261fece16518e9318548a00db2bd52669732 (patch)
tree74e187c9c398a43ea17e61ec3c22e99431f0672a /xslt
parentc02cc33fc8636c3d754dac34b5f317bae0ed9aee (diff)
downloadsubsurface-5a34261fece16518e9318548a00db2bd52669732.tar.gz
Try to detect first cylinder on divelogs.de export
Most dive computers start always with the first cylinder (and if not, they give a gas switch in the first few seconds). Trying to follow this principle on divelogs.de export. The bug 626 sounds like a bit different case so a sample XML log would be needed to ensure that use case gets fixed. See #626 Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'xslt')
-rw-r--r--xslt/divelogs-export.xslt37
1 files changed, 33 insertions, 4 deletions
diff --git a/xslt/divelogs-export.xslt b/xslt/divelogs-export.xslt
index 614fafd5c..b13006d3b 100644
--- a/xslt/divelogs-export.xslt
+++ b/xslt/divelogs-export.xslt
@@ -38,11 +38,39 @@
<PARTNER>
<xsl:value-of select="buddy"/>
</PARTNER>
+
+ <!-- If there is a gas change event within the first few seconds
+ then we try to detect matching cylinder, otherwise the first
+ cylinder is used.
+ -->
+ <xsl:variable name="time">
+ <xsl:call-template name="time2sec">
+ <xsl:with-param name="time">
+ <xsl:value-of select="event[@name = 'gaschange']/@time"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="mix">
+ <xsl:value-of select="concat(event[@name = 'gaschange']/@value, '.0%')"/>
+ </xsl:variable>
+
+ <xsl:variable name="cylinder">
+ <xsl:choose>
+ <xsl:when test="$time &lt; 60">
+ <xsl:value-of select="count(cylinder[@o2 = $mix]/preceding-sibling::cylinder) + 1"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="1"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
<CYLINDERDESCRIPTION>
- <xsl:value-of select="cylinder/@description"/>
+ <xsl:value-of select="cylinder[position() = $cylinder]/@description"/>
</CYLINDERDESCRIPTION>
<CYLINDERSIZE>
- <xsl:value-of select="substring-before(cylinder/@size, ' ')"/>
+ <xsl:value-of select="substring-before(cylinder[position() = $cylinder]/@size, ' ')"/>
</CYLINDERSIZE>
<CYLINDERSTARTPRESSURE>
<xsl:choose>
@@ -50,7 +78,7 @@
<xsl:value-of select="substring-before(node()/sample/@pressure, ' ')"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="cylinder[1]/@start"/>
+ <xsl:value-of select="cylinder[position() = $cylinder]/@start"/>
</xsl:otherwise>
</xsl:choose>
</CYLINDERSTARTPRESSURE>
@@ -60,10 +88,11 @@
<xsl:value-of select="node()/sample[@pressure][last()]/@pressure"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="cylinder[1]/@end"/>
+ <xsl:value-of select="cylinder[$cylinder]/@end"/>
</xsl:otherwise>
</xsl:choose>
</CYLINDERENDPRESSURE>
+
<WEIGHT>
<xsl:call-template name="sum">
<xsl:with-param name="values" select="weightsystem/@weight"/>