aboutsummaryrefslogtreecommitdiffstats
path: root/xslt/xml2manualcsv.xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2019-07-13 10:19:39 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-07-13 08:48:26 -0700
commit96ee6898e8124e36dd810c449b8e05a43949663b (patch)
treead623a4cf3aa623183af006e272422ffc168a26c /xslt/xml2manualcsv.xslt
parentdb550fab571fa8c3e6db38230db37951e9903401 (diff)
downloadsubsurface-96ee6898e8124e36dd810c449b8e05a43949663b.tar.gz
Fix special case for temperature in CSV export
The old code took air and water temperatures primarily from dive/divetemperature or secondarily if the previous one didn't have either one of them from divecomputer/temperature. The new code attempts to take first air temperature from dive/divetemperature or diveomputer/temperature and then on a separate run the water temperature from these both. Thus we should be fine if one temperature is in dive/divetemperature and the other in divecomputer/temperature. Fixes #2169 Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Diffstat (limited to 'xslt/xml2manualcsv.xslt')
-rw-r--r--xslt/xml2manualcsv.xslt57
1 files changed, 36 insertions, 21 deletions
diff --git a/xslt/xml2manualcsv.xslt b/xslt/xml2manualcsv.xslt
index b2de440f9..e4e26746b 100644
--- a/xslt/xml2manualcsv.xslt
+++ b/xslt/xml2manualcsv.xslt
@@ -53,22 +53,45 @@
<xsl:text>&quot;&quot;</xsl:text>
</xsl:otherwise>
</xsl:choose>
+
+ <!-- Air temperature -->
<xsl:choose>
- <xsl:when test="divetemperature/@air|divetemperature/@water != ''">
- <xsl:apply-templates select="divetemperature"/>
+ <xsl:when test="divetemperature/@air != ''">
+ <xsl:call-template name="temperature">
+ <xsl:with-param name="temp" select="divetemperature/@air"/>
+ </xsl:call-template>
</xsl:when>
- <xsl:when test="divecomputer[1]/temperature/@air|divecomputer[1]/temperature/@water != ''">
- <xsl:apply-templates select="divecomputer[1]/temperature"/>
+ <xsl:when test="divecomputer[1]/temperature/@air != ''">
+ <xsl:call-template name="temperature">
+ <xsl:with-param name="temp" select="divecomputer[1]/temperature/@air"/>
+ </xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- empty air temperature -->
<xsl:value-of select="$fs"/>
<xsl:text>&quot;&quot;</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <!-- Water temperature -->
+ <xsl:choose>
+ <xsl:when test="divetemperature/@water != ''">
+ <xsl:call-template name="temperature">
+ <xsl:with-param name="temp" select="divetemperature/@water"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="divecomputer[1]/temperature/@water != ''">
+ <xsl:call-template name="temperature">
+ <xsl:with-param name="temp" select="divecomputer[1]/temperature/@water"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
<!-- water temperature -->
<xsl:value-of select="$fs"/>
<xsl:text>&quot;&quot;</xsl:text>
</xsl:otherwise>
</xsl:choose>
+
<xsl:choose>
<xsl:when test="cylinder[1]/@start|cylinder[1]/@end != ''">
<xsl:apply-templates select="cylinder[1]"/>
@@ -250,34 +273,26 @@
</xsl:choose>
<xsl:text>&quot;</xsl:text>
</xsl:template>
- <xsl:template match="divetemperature|temperature">
- <xsl:value-of select="$fs"/>
- <xsl:text>&quot;</xsl:text>
- <xsl:choose>
- <xsl:when test="$units = 1">
- <xsl:if test="substring-before(@air, ' ') &gt; 0">
- <xsl:value-of select="concat(format-number((substring-before(@air, ' ') * 1.8) + 32, '0.0'), '')"/>
- </xsl:if>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="substring-before(@air, ' ')"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text>&quot;</xsl:text>
+
+ <!-- Temperature template -->
+ <xsl:template name="temperature">
+ <xsl:param name="temp"/>
+
<xsl:value-of select="$fs"/>
<xsl:text>&quot;</xsl:text>
<xsl:choose>
<xsl:when test="$units = 1">
- <xsl:if test="substring-before(@water, ' ') &gt; 0">
- <xsl:value-of select="concat(format-number((substring-before(@water, ' ') * 1.8) + 32, '0.0'), '')"/>
+ <xsl:if test="substring-before($temp, ' ') &gt; 0">
+ <xsl:value-of select="concat(format-number((substring-before($temp, ' ') * 1.8) + 32, '0.0'), '')"/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="substring-before(@water, ' ')"/>
+ <xsl:value-of select="substring-before($temp, ' ')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&quot;</xsl:text>
</xsl:template>
+
<xsl:template match="cylinder">
<xsl:value-of select="$fs"/>
<xsl:text>&quot;</xsl:text>