summaryrefslogtreecommitdiffstats
path: root/xslt/xml2manualcsv.xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2020-05-31 14:45:11 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-31 08:59:47 -0700
commit108b30e8b5c279c49a73da6b5058e49d4e219598 (patch)
tree6493ddb4dc70e6f37f06340ab3fb33f845111143 /xslt/xml2manualcsv.xslt
parent8f7c9bc7d1eb979eccae8803a386ae793ac23d14 (diff)
downloadsubsurface-108b30e8b5c279c49a73da6b5058e49d4e219598.tar.gz
Print at most as many cylinders as the header has
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Diffstat (limited to 'xslt/xml2manualcsv.xslt')
-rw-r--r--xslt/xml2manualcsv.xslt14
1 files changed, 13 insertions, 1 deletions
diff --git a/xslt/xml2manualcsv.xslt b/xslt/xml2manualcsv.xslt
index af5d65220..9b09dd03d 100644
--- a/xslt/xml2manualcsv.xslt
+++ b/xslt/xml2manualcsv.xslt
@@ -11,6 +11,9 @@
</xsl:text></xsl:variable>
<xsl:template match="/divelog/dives">
+ <xsl:variable name="cylinders">
+ <xsl:value-of select="count(dive[position()=last()]/cylinder|trip[position()=last()]/dive[position()=last()]/cylinder)"/>
+ </xsl:variable>
<xsl:choose>
<xsl:when test="$units = 1">
@@ -139,12 +142,16 @@
</xsl:choose>
<xsl:text>
</xsl:text>
- <xsl:apply-templates select="dive|trip/dive"/>
+ <xsl:apply-templates select="dive|trip/dive">
+ <xsl:with-param name="cylinders" select="$cylinders"/>
+ </xsl:apply-templates>
</xsl:template>
<xsl:template match="divesites/site/notes"/>
<xsl:template match="dive">
+ <xsl:param name="cylinders"/>
+
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="@number"/>
<xsl:text>&quot;</xsl:text>
@@ -231,6 +238,9 @@
<xsl:for-each select="cylinder">
<xsl:choose>
+ <xsl:when test="$cylinders &lt; position()"/>
+ <xsl:otherwise>
+ <xsl:choose>
<xsl:when test="@start|@end != ''">
<xsl:apply-templates select="."/>
</xsl:when>
@@ -292,6 +302,8 @@
<xsl:text>&quot;</xsl:text>
</xsl:otherwise>
</xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:for-each>
<xsl:choose>