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 <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Miika Turkia 2016-04-02 14:27:43 +08:00 committed by Dirk Hohndel
parent 19400b8da1
commit 7e47874adb

View file

@ -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>