summaryrefslogtreecommitdiffstats
path: root/xslt/xml2csv.xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2017-07-09 11:16:28 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-07-15 14:44:07 +0900
commit9b7d321c8786bae7e1d4d8673ba541d7884c558b (patch)
tree72091de08ec508666f41a82e6fe42d8ccc9bfd22 /xslt/xml2csv.xslt
parent9397dbb432b3ce6d6e507370a32fd7c83b563466 (diff)
downloadsubsurface-9b7d321c8786bae7e1d4d8673ba541d7884c558b.tar.gz
CSV export: show units on header
Let's show the units in CSV header so the actual fields have only the values. This should be easier to parse with some other programs. Fixes #472 Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Diffstat (limited to 'xslt/xml2csv.xslt')
-rw-r--r--xslt/xml2csv.xslt15
1 files changed, 11 insertions, 4 deletions
diff --git a/xslt/xml2csv.xslt b/xslt/xml2csv.xslt
index 211597325..25f5d8b7c 100644
--- a/xslt/xml2csv.xslt
+++ b/xslt/xml2csv.xslt
@@ -7,7 +7,14 @@
<xsl:variable name="fs">,</xsl:variable>
<xsl:template match="/divelog/dives">
- <xsl:value-of select="concat('&quot;dive number&quot;', $fs, '&quot;date&quot;', $fs, '&quot;time&quot;', $fs, '&quot;sample time&quot;', $fs, '&quot;sample depth&quot;', $fs, '&quot;sample temperature&quot;', $fs, '&quot;sample pressure&quot;')"/>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:value-of select="concat('&quot;dive number&quot;', $fs, '&quot;date&quot;', $fs, '&quot;time&quot;', $fs, '&quot;sample time&quot;', $fs, '&quot;sample depth (ft)&quot;', $fs, '&quot;sample temperature (F)&quot;', $fs, '&quot;sample pressure (psi)&quot;')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat('&quot;dive number&quot;', $fs, '&quot;date&quot;', $fs, '&quot;time&quot;', $fs, '&quot;sample time&quot;', $fs, '&quot;sample depth (m)&quot;', $fs, '&quot;sample temperature (C)&quot;', $fs, '&quot;sample pressure (bar)&quot;')"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="dive|trip/dive"/>
@@ -34,7 +41,7 @@
<xsl:value-of select="$fs"/>
<xsl:choose>
<xsl:when test="$units = 1">
- <xsl:value-of select="concat('&quot;', round((substring-before(@depth, ' ') div 0.3048) * 1000) div 1000, ' ft&quot;')"/>
+ <xsl:value-of select="concat('&quot;', round((substring-before(@depth, ' ') div 0.3048) * 1000) div 1000, '&quot;')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('&quot;', round(substring-before(@depth, ' ') * 1000) div 1000, '&quot;')"/>
@@ -45,7 +52,7 @@
<xsl:if test="@temp != ''">
<xsl:choose>
<xsl:when test="$units = 1">
- <xsl:value-of select="concat('&quot;', format-number((substring-before(@temp, ' ') * 1.8) + 32, '#.#'), ' F&quot;')"/>
+ <xsl:value-of select="concat('&quot;', format-number((substring-before(@temp, ' ') * 1.8) + 32, '#.#'), '&quot;')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('&quot;', substring-before(@temp, ' '), '&quot;')"/>
@@ -57,7 +64,7 @@
<xsl:if test="@pressure != ''">
<xsl:choose>
<xsl:when test="$units = 1">
- <xsl:value-of select="concat('&quot;', format-number((substring-before(@pressure, ' ') * 14.5037738007), '#'), ' psi&quot;')"/>
+ <xsl:value-of select="concat('&quot;', format-number((substring-before(@pressure, ' ') * 14.5037738007), '#'), '&quot;')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('&quot;', substring-before(@pressure, ' '), '&quot;')"/>