diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2015-03-22 17:13:47 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-03-23 05:44:06 -0700 |
commit | 86ac7fdf47142d8ad26a27a36daa64a5ea435bdc (patch) | |
tree | f125a3b3e154e68c869422f48503b1a8fb5abced /xslt | |
parent | cb49c37b31fcebb3a1ba97b0a804d398ae0df22d (diff) | |
download | subsurface-86ac7fdf47142d8ad26a27a36daa64a5ea435bdc.tar.gz |
Import support for new Seabear format
This add support for Seabear's new import format that is used by H3 and
T1. In the future also the Hudc should switch to the new format. The
main difference to the old one is that time stamps are no longer
recorded in the samples, but intervali is specified in the header.
The header contains other useful information as well that we should
build support for. E.g. surface pressure, gas mixes, GF, and mode might
be useful additions later on.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'xslt')
-rw-r--r-- | xslt/csv2xml.xslt | 76 |
1 files changed, 54 insertions, 22 deletions
diff --git a/xslt/csv2xml.xslt b/xslt/csv2xml.xslt index dba207052..05f9e23c6 100644 --- a/xslt/csv2xml.xslt +++ b/xslt/csv2xml.xslt @@ -16,6 +16,7 @@ <xsl:param name="time" select="time"/> <xsl:param name="units" select="units"/> <xsl:param name="separatorIndex" select="separatorIndex"/> + <xsl:param name="delta" select="delta"/> <xsl:output method="xml" indent="yes"/> <xsl:variable name="lf"><xsl:text> @@ -41,6 +42,7 @@ <divecomputerid deviceid="ffffffff" model="csv" /> <xsl:call-template name="printLine"> <xsl:with-param name="line" select="substring-before(//csv, $lf)"/> + <xsl:with-param name="lineno" select="'1'"/> <xsl:with-param name="remaining" select="substring-after(//csv, $lf)"/> </xsl:call-template> </dive> @@ -50,33 +52,47 @@ <xsl:template name="printLine"> <xsl:param name="line"/> + <xsl:param name="lineno"/> <xsl:param name="remaining"/> <!-- We only want to process lines with different time stamps, and timeField is not necessarily the first field --> <xsl:if test="$line != substring-before($remaining, $lf)"> - <xsl:variable name="curTime"> - <xsl:call-template name="getFieldByIndex"> - <xsl:with-param name="index" select="$timeField"/> - <xsl:with-param name="line" select="$line"/> - </xsl:call-template> - </xsl:variable> - <xsl:variable name="prevTime"> - <xsl:call-template name="getFieldByIndex"> - <xsl:with-param name="index" select="$timeField"/> - <xsl:with-param name="line" select="substring-before($remaining, $lf)"/> - </xsl:call-template> - </xsl:variable> - - <xsl:if test="$curTime != $prevTime"> - <xsl:call-template name="printFields"> - <xsl:with-param name="line" select="$line"/> - </xsl:call-template> - </xsl:if> + <xsl:choose> + <xsl:when test="$delta != '' and $delta > 0"> + <xsl:variable name="curTime"> + <xsl:call-template name="getFieldByIndex"> + <xsl:with-param name="index" select="$timeField"/> + <xsl:with-param name="line" select="$line"/> + </xsl:call-template> + </xsl:variable> + <xsl:variable name="prevTime"> + <xsl:call-template name="getFieldByIndex"> + <xsl:with-param name="index" select="$timeField"/> + <xsl:with-param name="line" select="substring-before($remaining, $lf)"/> + </xsl:call-template> + </xsl:variable> + + <xsl:if test="$curTime != $prevTime"> + <xsl:call-template name="printFields"> + <xsl:with-param name="line" select="$line"/> + <xsl:with-param name="lineno" select="$lineno"/> + </xsl:call-template> + </xsl:if> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="printFields"> + <xsl:with-param name="line" select="$line"/> + <xsl:with-param name="lineno" select="'0'"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:if> <xsl:if test="$remaining != ''"> <xsl:call-template name="printLine"> <xsl:with-param name="line" select="substring-before($remaining, $lf)"/> + <xsl:with-param name="lineno" select="$lineno + 1"/> <xsl:with-param name="remaining" select="substring-after($remaining, $lf)"/> </xsl:call-template> </xsl:if> @@ -84,18 +100,34 @@ <xsl:template name="printFields"> <xsl:param name="line"/> + <xsl:param name="lineno"/> <xsl:variable name="value"> - <xsl:call-template name="getFieldByIndex"> - <xsl:with-param name="index" select="$timeField"/> - <xsl:with-param name="line" select="$line"/> - </xsl:call-template> + <xsl:choose> + <xsl:when test="$delta != '' and $delta > 0"> + <xsl:value-of select="'1'"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="getFieldByIndex"> + <xsl:with-param name="index" select="$timeField"/> + <xsl:with-param name="line" select="$line"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> </xsl:variable> + <xsl:if test="number($value) = $value or number(substring-before($value, ':')) = substring-before($value, ':')"> <sample> <xsl:attribute name="time"> <xsl:choose> + <xsl:when test="$delta != '' and $delta > 0"> + <xsl:call-template name="sec2time"> + <xsl:with-param name="timeSec"> + <xsl:value-of select="$lineno * 1"/> + </xsl:with-param> + </xsl:call-template> + </xsl:when> <xsl:when test="number($value) = $value"> <!-- We assume time in seconds --> |