diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2019-07-13 10:19:39 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-07-13 08:48:26 -0700 |
commit | 96ee6898e8124e36dd810c449b8e05a43949663b (patch) | |
tree | ad623a4cf3aa623183af006e272422ffc168a26c /xslt/xml2manualcsv.xslt | |
parent | db550fab571fa8c3e6db38230db37951e9903401 (diff) | |
download | subsurface-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.xslt | 57 |
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>""</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>""</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>""</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>"</xsl:text> </xsl:template> - <xsl:template match="divetemperature|temperature"> - <xsl:value-of select="$fs"/> - <xsl:text>"</xsl:text> - <xsl:choose> - <xsl:when test="$units = 1"> - <xsl:if test="substring-before(@air, ' ') > 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>"</xsl:text> + + <!-- Temperature template --> + <xsl:template name="temperature"> + <xsl:param name="temp"/> + <xsl:value-of select="$fs"/> <xsl:text>"</xsl:text> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:if test="substring-before(@water, ' ') > 0"> - <xsl:value-of select="concat(format-number((substring-before(@water, ' ') * 1.8) + 32, '0.0'), '')"/> + <xsl:if test="substring-before($temp, ' ') > 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>"</xsl:text> </xsl:template> + <xsl:template match="cylinder"> <xsl:value-of select="$fs"/> <xsl:text>"</xsl:text> |