Print at most as many cylinders as the header has

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
This commit is contained in:
Miika Turkia 2020-05-31 14:45:11 +03:00 committed by Dirk Hohndel
parent 8f7c9bc7d1
commit 108b30e8b5

View file

@ -11,6 +11,9 @@
</xsl:text></xsl:variable> </xsl:text></xsl:variable>
<xsl:template match="/divelog/dives"> <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:choose>
<xsl:when test="$units = 1"> <xsl:when test="$units = 1">
@ -139,12 +142,16 @@
</xsl:choose> </xsl:choose>
<xsl:text> <xsl:text>
</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>
<xsl:template match="divesites/site/notes"/> <xsl:template match="divesites/site/notes"/>
<xsl:template match="dive"> <xsl:template match="dive">
<xsl:param name="cylinders"/>
<xsl:text>&quot;</xsl:text> <xsl:text>&quot;</xsl:text>
<xsl:value-of select="@number"/> <xsl:value-of select="@number"/>
<xsl:text>&quot;</xsl:text> <xsl:text>&quot;</xsl:text>
@ -230,6 +237,9 @@
</xsl:choose> </xsl:choose>
<xsl:for-each select="cylinder"> <xsl:for-each select="cylinder">
<xsl:choose>
<xsl:when test="$cylinders &lt; position()"/>
<xsl:otherwise>
<xsl:choose> <xsl:choose>
<xsl:when test="@start|@end != ''"> <xsl:when test="@start|@end != ''">
<xsl:apply-templates select="."/> <xsl:apply-templates select="."/>
@ -292,6 +302,8 @@
<xsl:text>&quot;</xsl:text> <xsl:text>&quot;</xsl:text>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each> </xsl:for-each>
<xsl:choose> <xsl:choose>