diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2014-01-15 18:47:22 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-16 09:36:53 +0700 |
commit | bdecafc86a7c03d818283df2ca132373a9b888d9 (patch) | |
tree | 5fd1498e503e46e4bd6f6de811ea68b385a3636a /xslt | |
parent | 33391a77e9385cf403c2fb1b191b443fcf373294 (diff) | |
download | subsurface-bdecafc86a7c03d818283df2ca132373a9b888d9.tar.gz |
Use timeField variable on CSV import
We want to skip duplicate lines on CSV import. For this we need to use
time field, that is not necessarily the first field of the input. This
patch uses the configured time field instead of first one.
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 | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/xslt/csv2xml.xslt b/xslt/csv2xml.xslt index 87d494f30..5c524f668 100644 --- a/xslt/csv2xml.xslt +++ b/xslt/csv2xml.xslt @@ -34,7 +34,7 @@ <xsl:attribute name="time"> <xsl:value-of select="concat(substring($time, 2, 2), ':', substring($time, 4, 2))"/> </xsl:attribute> - <divecomputerid deviceid="ffffffff" model="stone" /> + <divecomputerid deviceid="ffffffff" model="csv" /> <xsl:call-template name="printLine"> <xsl:with-param name="line" select="substring-before(//csv, $lf)"/> <xsl:with-param name="remaining" select="substring-after(//csv, $lf)"/> @@ -48,10 +48,27 @@ <xsl:param name="line"/> <xsl:param name="remaining"/> - <xsl:if test="substring-before($line, $fs) != substring-before(substring-before($remaining, $lf), $fs)"> - <xsl:call-template name="printFields"> - <xsl:with-param name="line" select="$line"/> - </xsl:call-template> + <!-- 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:if> <xsl:if test="$remaining != ''"> <xsl:call-template name="printLine"> |