summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2020-05-18 18:29:37 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-26 11:33:10 -0700
commit889f36a57c636be89670852f710f3f349dc45df6 (patch)
treed061054fa3358fac2d31f204fb7b1a0c5cf07b97
parent19cdab52b395fae73ce5cf42bf938eb75041ed62 (diff)
downloadsubsurface-889f36a57c636be89670852f710f3f349dc45df6.tar.gz
Multi cylinder support for CSV export
Fixes #2830 Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
-rw-r--r--xslt/xml2manualcsv.xslt176
1 files changed, 92 insertions, 84 deletions
diff --git a/xslt/xml2manualcsv.xslt b/xslt/xml2manualcsv.xslt
index 3892d8c6e..324964a99 100644
--- a/xslt/xml2manualcsv.xslt
+++ b/xslt/xml2manualcsv.xslt
@@ -38,17 +38,19 @@
$fs)"/>
<!-- Print cylinder info according to the amount of cylinders in dive -->
- <xsl:value-of select="concat(
- '&quot;cylinder size (cuft)&quot;',
- $fs,
- '&quot;startpressure (psi)&quot;',
- $fs,
- '&quot;endpressure (psi)&quot;',
- $fs,
- '&quot;o2 (%)&quot;',
- $fs,
- '&quot;he (%)&quot;',
- $fs)"/>
+ <xsl:for-each select="dive/cylinder">
+ <xsl:value-of select="concat(
+ '&quot;cylinder size (cuft)&quot;',
+ $fs,
+ '&quot;startpressure (psi)&quot;',
+ $fs,
+ '&quot;endpressure (psi)&quot;',
+ $fs,
+ '&quot;o2 (%)&quot;',
+ $fs,
+ '&quot;he (%)&quot;',
+ $fs)"/>
+ </xsl:for-each>
<!-- Print rest of the header -->
<xsl:value-of select="concat(
@@ -98,17 +100,19 @@
$fs)"/>
<!-- Print cylinder info according to the amount of cylinders in dive -->
- <xsl:value-of select="concat(
- '&quot;cylinder size (l)&quot;',
- $fs,
- '&quot;startpressure (bar)&quot;',
- $fs,
- '&quot;endpressure (bar)&quot;',
- $fs,
- '&quot;o2 (%)&quot;',
- $fs,
- '&quot;he (%)&quot;',
- $fs)"/>
+ <xsl:for-each select="dive/cylinder">
+ <xsl:value-of select="concat(
+ '&quot;cylinder size (l)&quot;',
+ $fs,
+ '&quot;startpressure (bar)&quot;',
+ $fs,
+ '&quot;endpressure (bar)&quot;',
+ $fs,
+ '&quot;o2 (%)&quot;',
+ $fs,
+ '&quot;he (%)&quot;',
+ $fs)"/>
+ </xsl:for-each>
<!-- Print rest of the header -->
<xsl:value-of select="concat(
@@ -225,68 +229,71 @@
</xsl:otherwise>
</xsl:choose>
- <xsl:choose>
- <xsl:when test="cylinder[1]/@start|cylinder[1]/@end != ''">
- <xsl:apply-templates select="cylinder[1]"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$fs"/>
- <xsl:text>&quot;</xsl:text>
- <xsl:choose>
- <xsl:when test="$units = 1">
- <xsl:value-of select="concat(format-number((substring-before(cylinder[1]/@size, ' ') div 14.7 * 3000) * 0.035315, '#.#'), '')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="substring-before(cylinder[1]/@size, ' ')"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text>&quot;</xsl:text>
- <xsl:value-of select="$fs"/>
- <xsl:text>&quot;</xsl:text>
- <xsl:choose>
- <xsl:when test="$units = 1">
- <xsl:choose>
- <xsl:when test="substring-before(divecomputer[1]/sample[@pressure]/@pressure, ' ') &gt; 0">
- <xsl:value-of select="concat(format-number((substring-before(divecomputer[1]/sample[@pressure]/@pressure, ' ') * 14.5037738007), '#'), '')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="''"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="substring-before(divecomputer[1]/sample[@pressure]/@pressure, ' ')"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text>&quot;</xsl:text>
- <xsl:value-of select="$fs"/>
- <xsl:text>&quot;</xsl:text>
- <xsl:choose>
- <xsl:when test="$units = 1">
- <xsl:choose>
- <xsl:when test="substring-before(divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') &gt; 0">
- <xsl:value-of select="concat(format-number((substring-before(divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') * 14.5037738007), '#'), '')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="''"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="substring-before(divecomputer[1]/sample[@pressure][last()]/@pressure, ' ')"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text>&quot;</xsl:text>
- <xsl:value-of select="$fs"/>
- <xsl:text>&quot;</xsl:text>
- <xsl:value-of select="substring-before(cylinder[1]/@o2, '%')"/>
- <xsl:text>&quot;</xsl:text>
- <xsl:value-of select="$fs"/>
- <xsl:text>&quot;</xsl:text>
- <xsl:value-of select="substring-before(cylinder[1]/@he, '%')"/>
- <xsl:text>&quot;</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:for-each select="cylinder">
+ <xsl:choose>
+ <xsl:when test="@start|@end != ''">
+ <xsl:apply-templates select="."/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$fs"/>
+ <xsl:text>&quot;</xsl:text>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:value-of select="concat(format-number((substring-before(@size, ' ') div 14.7 * 3000) * 0.035315, '#.#'), '')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="substring-before(@size, ' ')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>&quot;</xsl:text>
+ <xsl:value-of select="$fs"/>
+ <xsl:text>&quot;</xsl:text>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:choose>
+ <xsl:when test="substring-before(../divecomputer[1]/sample[@pressure]/@pressure, ' ') &gt; 0">
+ <xsl:value-of select="concat(format-number((substring-before(../divecomputer[1]/sample[@pressure]/@pressure, ' ') * 14.5037738007), '#'), '')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="''"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="substring-before(../divecomputer[1]/sample[@pressure]/@pressure, ' ')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>&quot;</xsl:text>
+ <xsl:value-of select="$fs"/>
+ <xsl:text>&quot;</xsl:text>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:choose>
+ <xsl:when test="substring-before(../divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') &gt; 0">
+ <xsl:value-of select="concat(format-number((substring-before(../divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') * 14.5037738007), '#'), '')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="''"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="substring-before(../divecomputer[1]/sample[@pressure][last()]/@pressure, ' ')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>&quot;</xsl:text>
+ <xsl:value-of select="$fs"/>
+ <xsl:text>&quot;</xsl:text>
+ <xsl:value-of select="substring-before(@o2, '%')"/>
+ <xsl:text>&quot;</xsl:text>
+ <xsl:value-of select="$fs"/>
+ <xsl:text>&quot;</xsl:text>
+ <xsl:value-of select="substring-before(@he, '%')"/>
+ <xsl:text>&quot;</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+
<xsl:choose>
<!-- Old location format -->
<xsl:when test="location != ''">
@@ -469,6 +476,7 @@
<xsl:value-of select="substring-before(@he, '%')"/>
<xsl:text>&quot;</xsl:text>
</xsl:template>
+
<xsl:template match="location">
<xsl:value-of select="$fs"/>
<xsl:text>&quot;</xsl:text>