aboutsummaryrefslogtreecommitdiffstats
path: root/xslt/divelogs-export.xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2013-03-10 09:52:20 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-03-10 09:27:53 -0700
commit7c6ff9f957a1e7bfebb968cdc4bb96e2832ea4d8 (patch)
tree823223c2c26ee5e8a1eb5b75f3214b3a22bd3b65 /xslt/divelogs-export.xslt
parentcb30d6d864d893468b405de7821be1e96cd13e94 (diff)
downloadsubsurface-7c6ff9f957a1e7bfebb968cdc4bb96e2832ea4d8.tar.gz
Convert Subsurface XML to divelogs.de format
The resulting divelogs.de formatted XML is then to be zipped and uploaded to divelogs.de website. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'xslt/divelogs-export.xslt')
-rw-r--r--xslt/divelogs-export.xslt110
1 files changed, 110 insertions, 0 deletions
diff --git a/xslt/divelogs-export.xslt b/xslt/divelogs-export.xslt
new file mode 100644
index 000000000..4e9d92d2b
--- /dev/null
+++ b/xslt/divelogs-export.xslt
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:import href="commonTemplates.xsl"/>
+ <xsl:strip-space elements="*"/>
+ <xsl:output method="xml" encoding="iso-8859-1" indent="yes"/>
+
+ <xsl:template match="/divelog/dives">
+ <xsl:apply-templates select="dive"/>
+ </xsl:template>
+
+ <xsl:template match="dive">
+ <DIVELOGSDATA>
+ <DIVELOGSNUMBER>
+ <xsl:value-of select="@number"/>
+ </DIVELOGSNUMBER>
+ <DATE>
+ <xsl:value-of select="concat(substring-after(substring-after(@date, '-'), '-'), '.', substring-before(substring-after(@date, '-'), '-'), '.', substring-before(@date, '-'))"/>
+ </DATE>
+ <TIME>
+ <xsl:value-of select="@time"/>
+ </TIME>
+ <DIVETIMESEC>
+ <xsl:call-template name="time2sec">
+ <xsl:with-param name="time">
+ <xsl:value-of select="@duration"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </DIVETIMESEC>
+ <LOCATION>
+ <xsl:value-of select="location"/>
+ </LOCATION>
+ <WATERVIZIBILITY>
+ <xsl:value-of select="@visibility"/>
+ </WATERVIZIBILITY>
+ <PARTNER>
+ <xsl:value-of select="buddy"/>
+ </PARTNER>
+ <CYLINDERDESCRIPTION>
+ <xsl:value-of select="cylinder/@description"/>
+ </CYLINDERDESCRIPTION>
+ <CYLINDERSIZE>
+ <xsl:value-of select="substring-before(cylinder/@size, ' ')"/>
+ </CYLINDERSIZE>
+ <CYLINDERSTARTPRESSURE>
+ <xsl:value-of select="substring-before(node()/sample/@pressure, ' ')"/>
+ </CYLINDERSTARTPRESSURE>
+ <CYLINDERENDPRESSURE>
+ <xsl:variable name="samples">
+ <xsl:value-of select="count(node()/sample)"/>
+ </xsl:variable>
+ <xsl:value-of select="node()/sample[position() = $samples]/@pressure"/>
+ </CYLINDERENDPRESSURE>
+ <WEIGHT>
+ <xsl:call-template name="sum">
+ <xsl:with-param name="values" select="weightsystem/@weight"/>
+ </xsl:call-template>
+ </WEIGHT>
+ <O2PCT>
+ <xsl:value-of select="substring-before(cylinder/@o2, '%')"/>
+ </O2PCT>
+ <LOGNOTES>
+ <xsl:value-of select="notes"/>
+ </LOGNOTES>
+ <LAT>
+ <xsl:value-of select="substring-before(location/@gps, ' ')"/>
+ </LAT>
+ <LNG>
+ <xsl:value-of select="substring-after(location/@gps, ' ')"/>
+ </LNG>
+ <MAXDEPTH>
+ <xsl:value-of select="substring-before(node()/depth/@max, ' ')"/>
+ </MAXDEPTH>
+ <MEANDEPTH>
+ <xsl:value-of select="substring-before(node()/depth/@mean, ' ')"/>
+ </MEANDEPTH>
+ <AIRTEMP>
+ <xsl:value-of select="substring-before(divetemperature/@air, ' ')"/>
+ </AIRTEMP>
+ <WATERTEMPMAXDEPTH>
+ <xsl:value-of select="substring-before(node()/temperature/@water, ' ')"/>
+ </WATERTEMPMAXDEPTH>
+ <SAMPLEINTERVAL>
+ <xsl:variable name="first">
+ <xsl:call-template name="time2sec">
+ <xsl:with-param name="time">
+ <xsl:value-of select="node()/sample[1]/@time"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="second">
+ <xsl:call-template name="time2sec">
+ <xsl:with-param name="time">
+ <xsl:value-of select="node()/sample[2]/@time"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="$second - $first"/>
+ </SAMPLEINTERVAL>
+ <xsl:for-each select="divecomputer[1]/sample">
+ <SAMPLE>
+ <DEPTH>
+ <xsl:value-of select="substring-before(./@depth, ' ')"/>
+ </DEPTH>
+ </SAMPLE>
+ </xsl:for-each>
+ </DIVELOGSDATA>
+ </xsl:template>
+
+</xsl:stylesheet>