summaryrefslogtreecommitdiffstats
path: root/xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2011-12-18 14:36:28 +0200
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-12-18 11:56:26 -0800
commitd1d17c543c450931b1fa3402496cbd2d47ffea1b (patch)
treef163cea067cdd296f1324a92da19dbced74729a4 /xslt
parent84f172dccbee661ce693fdc3055567ab5ae24d22 (diff)
downloadsubsurface-d1d17c543c450931b1fa3402496cbd2d47ffea1b.tar.gz
Multiple cylinder support for JDiveLog import
Support for multiple cylinders and gas change events when Importing JDiveLog logs to Subsurface. This is tested with manually crafted data and not real data (originating from dive computer). NOTE: Subsurface does not handle importing multiple cylinders correctly but imports only the first cylinder. However, manually converting data to a file and opening that in Subsurface works correctly. (xsltproc jdivelog2subsurface.xslt jdivelog-gas.jlb > gas.xml) Some minor tweaking on importing JDiveLog specific fields to notes fields in Subsurface is also included. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'xslt')
-rw-r--r--xslt/jdivelog2subsurface.xslt99
1 files changed, 61 insertions, 38 deletions
diff --git a/xslt/jdivelog2subsurface.xslt b/xslt/jdivelog2subsurface.xslt
index 73b4590fb..e2f40c560 100644
--- a/xslt/jdivelog2subsurface.xslt
+++ b/xslt/jdivelog2subsurface.xslt
@@ -66,13 +66,10 @@
<notes>
<xsl:if test="DiveActivity != ''">
- <xsl:value-of select="DiveActivity"/>
+Diveactivity: <xsl:value-of select="DiveActivity"/>
</xsl:if>
- <xsl:if test="Comment != ''">
- <xsl:if test="DiveActivity != ''">
- <xsl:value-of select="': '"/>
- </xsl:if>
- <xsl:value-of select="Comment"/>
+ <xsl:if test="DiveType != ''">
+Divetype: <xsl:value-of select="DiveType"/>
</xsl:if>
<xsl:if test="Equipment/Visibility != ''">
Visibility: <xsl:value-of select="Equipment/Visibility"/>
@@ -86,41 +83,51 @@ Gloves: <xsl:value-of select="Equipment/Gloves"/>
<xsl:if test="Equipment/Weight != ''">
Weight: <xsl:value-of select="Equipment/Weight"/>
</xsl:if>
+ <xsl:if test="Comment != ''">
+Comment: <xsl:value-of select="Comment"/>
+ </xsl:if>
</notes>
<!-- cylinder -->
- <xsl:variable name="o2">
- <xsl:choose>
- <xsl:when test="DIVE/GASES/MIX/O2 != ''">
- <xsl:value-of select="concat(DIVE/GASES/MIX/O2*100, '%')"/>
- </xsl:when>
- <xsl:otherwise>21.0%</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="size">
- <xsl:choose>
- <xsl:when test="Equipment/Tanks/Tank/MIX/TANK/TANKVOLUME != ''">
- <xsl:value-of select="concat(Equipment/Tanks/Tank/MIX/TANK/TANKVOLUME * 1000, ' l')"/>
- </xsl:when>
- <xsl:otherwise>0 l</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="start">
- <xsl:variable name="number" select="Equipment/Tanks/Tank/MIX/TANK/PSTART"/>
- <xsl:call-template name="pressure">
- <xsl:with-param name="number" select="$number"/>
- <xsl:with-param name="units" select="$units"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="end">
- <xsl:variable name="number" select="Equipment/Tanks/Tank/MIX/TANK/PEND"/>
- <xsl:call-template name="pressure">
- <xsl:with-param name="number" select="$number"/>
- <xsl:with-param name="units" select="$units"/>
- </xsl:call-template>
- </xsl:variable>
-
- <cylinder o2="{$o2}" size="{$size}" start="{$start}" end="{$end}"/>
+ <xsl:for-each select="Equipment/Tanks/Tank">
+ <cylinder>
+ <xsl:attribute name="o2">
+ <xsl:choose>
+ <xsl:when test="MIX/O2 != ''">
+ <xsl:value-of select="concat(MIX/O2*100, '%')"/>
+ </xsl:when>
+ <xsl:otherwise>21.0%</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:if test="MIX/HE != '0.0'">
+ <xsl:attribute name="he">
+ <xsl:value-of select="concat(MIX/HE*100, '%')"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:attribute name="size">
+ <xsl:choose>
+ <xsl:when test="MIX/TANK/TANKVOLUME != ''">
+ <xsl:value-of select="concat(MIX/TANK/TANKVOLUME * 1000, ' l')"/>
+ </xsl:when>
+ <xsl:otherwise>0 l</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:attribute name="start">
+ <xsl:variable name="number" select="MIX/TANK/PSTART"/>
+ <xsl:call-template name="pressure">
+ <xsl:with-param name="number" select="$number"/>
+ <xsl:with-param name="units" select="$units"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <xsl:attribute name="end">
+ <xsl:variable name="number" select="MIX/TANK/PEND"/>
+ <xsl:call-template name="pressure">
+ <xsl:with-param name="number" select="$number"/>
+ <xsl:with-param name="units" select="$units"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ </cylinder>
+ </xsl:for-each>
<!-- end cylinder -->
<!-- DELTA is the sample interval -->
@@ -156,6 +163,22 @@ Weight: <xsl:value-of select="Equipment/Weight"/>
</xsl:for-each>
<!-- end events -->
+ <!-- gas change -->
+ <xsl:for-each select="DIVE/SAMPLES/SWITCH">
+ <event name="gaschange">
+ <xsl:attribute name="time">
+ <xsl:call-template name="timeConvert">
+ <xsl:with-param name="timeSec" select="count(preceding-sibling::D) * $delta"/>
+ <xsl:with-param name="units" select="'si'"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <xsl:attribute name="value">
+ <xsl:value-of select="ancestor::DIVE/GASES/MIX[MIXNAME=current()]/O2 * 100" />
+ </xsl:attribute>
+ </event>
+ </xsl:for-each>
+ <!-- end gas change -->
+
<!-- dive sample - all the depth and temp readings -->
<xsl:for-each select="DIVE/SAMPLES/D">
<xsl:variable name="timeSec" select="(position() - 1) * $delta"/>