summaryrefslogtreecommitdiffstats
path: root/xslt/uddf-export.xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@nixu.fi>2013-11-21 04:04:10 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-21 04:25:01 -0800
commitcd0475fe961ba65b65dd8cc707167c218c2b8649 (patch)
treea6c7f54cfae9121e282c1f4551d1d332881572f5 /xslt/uddf-export.xslt
parent5b0162d9d46cf4ac247eb65176a376360e3d2904 (diff)
downloadsubsurface-cd0475fe961ba65b65dd8cc707167c218c2b8649.tar.gz
Improve UDDF export to include more dive data
Basic information like buddy, location and visibility is included in UDDF export. Also attempt to grab temperature information from both temperature and divetemperature tags. This partially fixes bug #224. However, at least divemaster and tags are not exported (as the UDDF spec either does not have these or has hidden the information of these fields somewhere between so many seemingly unnecessary other fields). See #224 Signed-off-by: Miika Turkia <miika.turkia@nixu.fi> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'xslt/uddf-export.xslt')
-rw-r--r--xslt/uddf-export.xslt88
1 files changed, 84 insertions, 4 deletions
diff --git a/xslt/uddf-export.xslt b/xslt/uddf-export.xslt
index a41a7fccd..1d25c8cf6 100644
--- a/xslt/uddf-export.xslt
+++ b/xslt/uddf-export.xslt
@@ -44,8 +44,12 @@
</xsl:for-each>
</equipment>
</owner>
+
+ <xsl:apply-templates select="//buddy"/>
</diver>
+ <xsl:apply-templates select="//location"/>
+
<!-- Define all the unique gases found in the dive log -->
<gasdefinitions>
<!-- Get unique gas mixes from all the recorded dives -->
@@ -107,13 +111,56 @@
</uddf>
</xsl:template>
+ <xsl:key name="buddy" match="buddy" use="."/>
+ <xsl:template match="buddy">
+ <xsl:if test="generate-id() = generate-id(key('buddy', normalize-space(.)))">
+ <buddy>
+ <xsl:attribute name="id">
+ <xsl:value-of select="."/>
+ </xsl:attribute>
+ <personal>
+ <first_name>
+ <xsl:value-of select="."/>
+ </first_name>
+ </personal>
+ </buddy>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:key name="location" match="location" use="."/>
+ <xsl:template match="location">
+ <xsl:if test="generate-id() = generate-id(key('location', normalize-space(.)))">
+ <dive_site>
+ <xsl:attribute name="id">
+ <xsl:value-of select="."/>
+ </xsl:attribute>
+ <name>
+ <xsl:value-of select="."/>
+ </name>
+ <geography>
+ <location>
+ <xsl:value-of select="."/>
+ </location>
+ <gps>
+ <latitude>
+ <xsl:value-of select="substring-before(@gps, ' ')"/>
+ </latitude>
+ <longitude>
+ <xsl:value-of select="substring-after(@gps, ' ')"/>
+ </longitude>
+ </gps>
+ </geography>
+ </dive_site>
+ </xsl:if>
+ </xsl:template>
+
<xsl:template match="dive">
<dive id="{generate-id(.)}">
<informationbeforedive>
- <xsl:if test="node()/temperature/@air != ''">
+ <xsl:if test="temperature/@air|divetemperature/@air != ''">
<airtemperature>
- <xsl:value-of select="format-number(substring-before(node()/temperature/@air, ' ') + 273.15, '0.00')"/>
+ <xsl:value-of select="format-number(substring-before(temperature/@air|divetemperature/@air, ' ') + 273.15, '0.00')"/>
</airtemperature>
</xsl:if>
<datetime>
@@ -122,6 +169,20 @@
<divenumber>
<xsl:value-of select="./@number"/>
</divenumber>
+ <xsl:if test="buddy != ''">
+ <buddy_ref>
+ <xsl:attribute name="ref">
+ <xsl:value-of select="buddy"/>
+ </xsl:attribute>
+ </buddy_ref>
+ </xsl:if>
+ <xsl:if test="location != ''">
+ <dive_site_ref>
+ <xsl:attribute name="ref">
+ <xsl:value-of select="location"/>
+ </xsl:attribute>
+ </dive_site_ref>
+ </xsl:if>
</informationbeforedive>
<samples>
@@ -250,9 +311,9 @@
</xsl:call-template>
</diveduration>
</xsl:if>
- <xsl:if test="node()/temperature/@water != ''">
+ <xsl:if test="temperature/@water|divetemperature/@water != ''">
<lowesttemperature>
- <xsl:value-of select="format-number(substring-before(node()/temperature/@water, ' ') + 273.15, '0.00')"/>
+ <xsl:value-of select="format-number(substring-before(temperature/@water|divetemperature/@water, ' ') + 273.15, '0.00')"/>
</lowesttemperature>
</xsl:if>
<notes>
@@ -272,6 +333,25 @@
</xsl:choose>
</ratingvalue>
</rating>
+ <visibility>
+ <xsl:choose>
+ <xsl:when test="./@visibility = 1">
+ <xsl:value-of select="1"/>
+ </xsl:when>
+ <xsl:when test="./@visibility = 2">
+ <xsl:value-of select="3"/>
+ </xsl:when>
+ <xsl:when test="./@visibility = 3">
+ <xsl:value-of select="5"/>
+ </xsl:when>
+ <xsl:when test="./@visibility = 4">
+ <xsl:value-of select="10"/>
+ </xsl:when>
+ <xsl:when test="./@visibility = 5">
+ <xsl:value-of select="15"/>
+ </xsl:when>
+ </xsl:choose>
+ </visibility>
</informationafterdive>
</dive>