diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2016-12-31 09:52:46 +0200 |
---|---|---|
committer | Subsurface <dirk@subsurface-divelog.org> | 2016-12-31 17:15:15 -0800 |
commit | 02eb16aec5c1189b1b4c2c35e7a493e9269b09e6 (patch) | |
tree | 682bdb7132c1d37cbd0f387476e4b3b6f81ee40d | |
parent | bdef1fa19905e73db93f3fea747c41861e090b6e (diff) | |
download | subsurface-02eb16aec5c1189b1b4c2c35e7a493e9269b09e6.tar.gz |
XSLT to parse AV1 log file
Support for importing the dive profile from Underwater Technologies AV1
dive computer export.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
-rw-r--r-- | xslt/av1.xslt | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/xslt/av1.xslt b/xslt/av1.xslt new file mode 100644 index 000000000..e5f73fa88 --- /dev/null +++ b/xslt/av1.xslt @@ -0,0 +1,91 @@ +<?xml version="1.0"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + <xsl:include href="commonTemplates.xsl"/> + <xsl:strip-space elements="*"/> + <xsl:param name="timeField" select="timeField"/> + <xsl:param name="depthField" select="depthField"/> + <xsl:param name="date" select="date"/> + <xsl:param name="time" select="time"/> + <xsl:param name="hw" select="hw"/> + <xsl:output method="xml" indent="yes"/> + + <xsl:variable name="lf"><xsl:text> +</xsl:text></xsl:variable> + <xsl:variable name="fs"><xsl:text> </xsl:text></xsl:variable> + + <xsl:template match="/"> + <divelog program="subsurface-import" version="2"> + <dives> + <dive> + <xsl:attribute name="date"> + <xsl:value-of select="concat(substring($date, 1, 4), '-', substring($date, 5, 2), '-', substring($date, 7, 2))"/> + </xsl:attribute> + <xsl:attribute name="time"> + <xsl:value-of select="concat(substring($time, 2, 2), ':', substring($time, 4, 2))"/> + </xsl:attribute> + <divecomputer deviceid="ffffffff"> + <xsl:attribute name="model"> + <xsl:value-of select="$hw" /> + </xsl:attribute> + + <xsl:call-template name="printLine"> + <xsl:with-param name="line" select="substring-before(//AV1, $lf)"/> + <xsl:with-param name="lineno" select="'1'"/> + <xsl:with-param name="remaining" select="substring-after(//AV1, $lf)"/> + </xsl:call-template> + </divecomputer> + </dive> + </dives> + </divelog> + </xsl:template> + + <xsl:template name="printLine"> + <xsl:param name="line"/> + <xsl:param name="lineno"/> + <xsl:param name="remaining"/> + + <!-- For now, parse only depth values - they are numeric --> + <xsl:if test="string(number(substring($line, 1, 1))) != 'NaN'"> + <xsl:call-template name="printFields"> + <xsl:with-param name="line" select="$line"/> + <xsl:with-param name="lineno" select="'0'"/> + </xsl:call-template> + </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> + </xsl:template> + + <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:variable> + <sample> + <xsl:attribute name="time"> + <xsl:value-of select="substring-before($value, ':') * 60 + substring-after($value, ':')" /> + </xsl:attribute> + + <xsl:variable name="depth"> + <xsl:call-template name="getFieldByIndex"> + <xsl:with-param name="index" select="$depthField"/> + <xsl:with-param name="line" select="$line"/> + </xsl:call-template> + </xsl:variable> + <xsl:attribute name="depth"> + <xsl:value-of select="translate($depth, ',', '.')"/> + </xsl:attribute> + </sample> + </xsl:template> + +</xsl:stylesheet> |