I wonder if there has been a change in XSLT library that broke this code. I am pretty sure this worked back in 2011 when I originally wrote it. And it does not work now. Anyway, attached patches should fix the bug reported on thread "iOS beta testing" regarding DM5 import of individual dives. (Suunto has also done some slight changes in their format)
miika
From 4ec0fa2394ef227d432202d195a8419d4b7889ea Mon Sep 17 00:00:00 2001 From: Miika Turkia <[email protected]> Date: Sat, 2 Apr 2016 14:13:17 +0800 Subject: [PATCH 1/2] SDM import: calculate duration if needed Seems that DiveManager does not always return the dive duration in DIVETIMESEC field. In this case we can try to calculate the duration from sample count and interval. Signed-off-by: Miika Turkia <[email protected]> --- xslt/SuuntoSDM.xslt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/xslt/SuuntoSDM.xslt b/xslt/SuuntoSDM.xslt index 3b41b7d..90cc5fd 100644 --- a/xslt/SuuntoSDM.xslt +++ b/xslt/SuuntoSDM.xslt @@ -25,10 +25,20 @@ </xsl:attribute> <xsl:attribute name="duration"> - <xsl:call-template name="timeConvert"> - <xsl:with-param name="timeSec" select="DIVETIMESEC"/> - <xsl:with-param name="units" select="$units"/> - </xsl:call-template> + <xsl:choose> + <xsl:when test="DIVETIMESEC != ''"> + <xsl:call-template name="timeConvert"> + <xsl:with-param name="timeSec" select="DIVETIMESEC"/> + <xsl:with-param name="units" select="$units"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="timeConvert"> + <xsl:with-param name="timeSec" select="SAMPLECNT * SAMPLEINTERVAL"/> + <xsl:with-param name="units" select="$units"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> </xsl:attribute> <xsl:choose> -- 2.5.0
From ad21dda6548dc6fcec99c84d21087606e8ca4bd0 Mon Sep 17 00:00:00 2001 From: Miika Turkia <[email protected]> Date: Sat, 2 Apr 2016 14:27:43 +0800 Subject: [PATCH 2/2] SDM import: fix logic for sample import Seems that testing if BOOKMARK is empty is a bad idea. We end up not getting any samples, but the ones containing a bookmark. So we need to switch the logic to testing if BOOKMARK contains something and do those tasks first and otherwise grab a regular sample. Signed-off-by: Miika Turkia <[email protected]> --- xslt/SuuntoSDM.xslt | 56 ++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/xslt/SuuntoSDM.xslt b/xslt/SuuntoSDM.xslt index 90cc5fd..d8d5666 100644 --- a/xslt/SuuntoSDM.xslt +++ b/xslt/SuuntoSDM.xslt @@ -188,7 +188,36 @@ <!-- dive sample - all the depth and temp readings --> <xsl:for-each select="SAMPLE"> <xsl:choose> - <xsl:when test="BOOKMARK = ''"> + <xsl:when test="BOOKMARK != ''"> + <xsl:choose> + <xsl:when test="substring-before(BOOKMARK, ':') = 'Heading'"> + <event name="heading"> + <xsl:attribute name="value"> + <xsl:value-of select="substring-before(substring-after(BOOKMARK, ': '), '°')"/> + </xsl:attribute> + <xsl:attribute name="time"> + <xsl:call-template name="timeConvert"> + <xsl:with-param name="timeSec" select="SAMPLETIME"/> + <xsl:with-param name="units" select="'si'"/> + </xsl:call-template> + </xsl:attribute> + </event> + </xsl:when> + <xsl:otherwise> + <xsl:if test="BOOKMARK != 'Surface'"> + <event name="{BOOKMARK}"> + <xsl:attribute name="time"> + <xsl:call-template name="timeConvert"> + <xsl:with-param name="timeSec" select="SAMPLETIME"/> + <xsl:with-param name="units" select="'si'"/> + </xsl:call-template> + </xsl:attribute> + </event> + </xsl:if> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> <sample> <xsl:attribute name="time"> <xsl:call-template name="timeConvert"> @@ -211,31 +240,6 @@ </xsl:call-template> </xsl:attribute> </sample> - </xsl:when> - <xsl:when test="substring-before(BOOKMARK, ':') = 'Heading'"> - <event name="heading"> - <xsl:attribute name="value"> - <xsl:value-of select="substring-before(substring-after(BOOKMARK, ': '), '°')"/> - </xsl:attribute> - <xsl:attribute name="time"> - <xsl:call-template name="timeConvert"> - <xsl:with-param name="timeSec" select="SAMPLETIME"/> - <xsl:with-param name="units" select="'si'"/> - </xsl:call-template> - </xsl:attribute> - </event> - </xsl:when> - <xsl:otherwise> - <xsl:if test="BOOKMARK != 'Surface'"> - <event name="{BOOKMARK}"> - <xsl:attribute name="time"> - <xsl:call-template name="timeConvert"> - <xsl:with-param name="timeSec" select="SAMPLETIME"/> - <xsl:with-param name="units" select="'si'"/> - </xsl:call-template> - </xsl:attribute> - </event> - </xsl:if> </xsl:otherwise> </xsl:choose> </xsl:for-each> -- 2.5.0
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
