summaryrefslogtreecommitdiffstats
path: root/xslt/udcf.xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2014-11-11 09:40:40 +0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-10 21:12:05 -0800
commit116615857c8903ad84c3ec371d42183a355fca6d (patch)
tree06907c2d847de5001b45da93f52ae263fc4109cc /xslt/udcf.xslt
parent01441ccb457cc8e4f9d09205db8a8840e049823a (diff)
downloadsubsurface-116615857c8903ad84c3ec371d42183a355fca6d.tar.gz
Support timedepth mode on UDCF import
Fixes #756 Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'xslt/udcf.xslt')
-rw-r--r--xslt/udcf.xslt101
1 files changed, 72 insertions, 29 deletions
diff --git a/xslt/udcf.xslt b/xslt/udcf.xslt
index b3c93e8aa..62cee55be 100644
--- a/xslt/udcf.xslt
+++ b/xslt/udcf.xslt
@@ -86,35 +86,78 @@
</cylinder>
</xsl:for-each>
- <xsl:variable name="delta" select="SAMPLES/DELTA|samples/delta"/>
-
- <!-- gas change -->
- <xsl:for-each select="SAMPLES/SWITCH|samples/switch">
- <event name="gaschange">
- <xsl:variable name="timeSec" select="count(preceding-sibling::D|preceding-sibling::d) * $delta"/>
- <xsl:attribute name="time">
- <xsl:value-of select="concat(floor($timeSec div 60), ':',
- format-number(floor($timeSec mod 60), '00'), ' min')"/>
- </xsl:attribute>
- <xsl:attribute name="value">
- <xsl:value-of select="ancestor::DIVE/GASES/MIX[MIXNAME=current()]/O2|ancestor::dive/gases/mix[mixname=current()]/o2 * 100" />
- </xsl:attribute>
- </event>
- </xsl:for-each>
- <!-- end gas change -->
-
- <xsl:for-each select="SAMPLES/D|samples/d">
- <sample>
- <xsl:variable name="timeSec" select="(position() - 1) * $delta"/>
- <xsl:attribute name="time">
- <xsl:value-of select="concat(floor($timeSec div 60), ':',
- format-number(floor($timeSec mod 60), '00'), ' min')"/>
- </xsl:attribute>
- <xsl:attribute name="depth">
- <xsl:value-of select="concat(., ' m')"/>
- </xsl:attribute>
- </sample>
- </xsl:for-each>
+ <xsl:choose>
+
+ <!-- samples recorded at irregular internal, but storing time stamp -->
+ <xsl:when test="timedepthmode">
+ <!-- gas change -->
+ <xsl:for-each select="SAMPLES/SWITCH|samples/switch">
+ <event name="gaschange">
+ <xsl:variable name="timeSec" select="following-sibling::T|following-sibling::t"/>
+ <xsl:attribute name="time">
+ <xsl:value-of select="concat(floor($timeSec div 60), ':',
+ format-number(floor($timeSec mod 60), '00'), ' min')"/>
+ </xsl:attribute>
+ <xsl:attribute name="value">
+ <xsl:value-of select="ancestor::DIVE/GASES/MIX[MIXNAME=current()]/O2|ancestor::dive/gases/mix[mixname=current()]/o2 * 100" />
+ </xsl:attribute>
+ </event>
+ </xsl:for-each>
+ <!-- end gas change -->
+
+ <!-- samples -->
+ <xsl:for-each select="SAMPLES/D|samples/d">
+ <sample>
+ <xsl:variable name="timeSec" select="preceding-sibling::T[position()=1]|preceding-sibling::t[position()=1]"/>
+ <xsl:attribute name="time">
+ <xsl:value-of select="concat(floor($timeSec div 60), ':',
+ format-number(floor($timeSec mod 60), '00'), ' min')"/>
+ </xsl:attribute>
+ <xsl:attribute name="depth">
+ <xsl:value-of select="concat(., ' m')"/>
+ </xsl:attribute>
+ </sample>
+ </xsl:for-each>
+ <!-- end samples -->
+ </xsl:when>
+
+ <!-- sample recorded at even internals -->
+ <xsl:otherwise>
+ <xsl:variable name="delta" select="SAMPLES/DELTA|samples/delta"/>
+
+ <!-- gas change -->
+ <xsl:for-each select="SAMPLES/SWITCH|samples/switch">
+ <event name="gaschange">
+ <xsl:variable name="timeSec" select="count(preceding-sibling::D|preceding-sibling::d) * $delta"/>
+ <xsl:attribute name="time">
+ <xsl:value-of select="concat(floor($timeSec div 60), ':',
+ format-number(floor($timeSec mod 60), '00'), ' min')"/>
+ </xsl:attribute>
+ <xsl:attribute name="value">
+ <xsl:value-of select="ancestor::DIVE/GASES/MIX[MIXNAME=current()]/O2|ancestor::dive/gases/mix[mixname=current()]/o2 * 100" />
+ </xsl:attribute>
+ </event>
+
+ </xsl:for-each>
+ <!-- end gas change -->
+
+ <!-- samples -->
+ <xsl:for-each select="SAMPLES/D|samples/d">
+ <sample>
+ <xsl:variable name="timeSec" select="(position() - 1) * $delta"/>
+ <xsl:attribute name="time">
+ <xsl:value-of select="concat(floor($timeSec div 60), ':',
+ format-number(floor($timeSec mod 60), '00'), ' min')"/>
+ </xsl:attribute>
+ <xsl:attribute name="depth">
+ <xsl:value-of select="concat(., ' m')"/>
+ </xsl:attribute>
+ </sample>
+ </xsl:for-each>
+ <!-- end samples -->
+
+ </xsl:otherwise>
+ </xsl:choose>
</dive>
</xsl:template>
</xsl:stylesheet>