mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Added support for UDDf version 3.1
This adds support for UDDF version 3.1 as produced by at least DiversDiary. Basically we have to include the different name space into our selections. This patch also checks if the temperature is zero on all samples and skips temperature readings if it looks like the dive computer does not record them. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9b35381cf2
commit
6a98588ed0
2 changed files with 67 additions and 41 deletions
|
@ -131,4 +131,20 @@
|
|||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Trying to see if we have temperature readings -->
|
||||
<xsl:template name="temperatureSamples">
|
||||
<xsl:param name="units"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 'Imperial'">
|
||||
<xsl:value-of select="count(descendant::temperature[. != 32])"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$units = 'Kelvin'">
|
||||
<xsl:value-of select="count(descendant::temperature[. != 273.15])"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="count(descendant::temperature[. != 0])"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:u="http://www.streit.cc/uddf/3.2/"
|
||||
xmlns:u1="http://www.streit.cc/uddf/3.1/"
|
||||
exclude-result-prefixes="u"
|
||||
version="1.0">
|
||||
<xsl:import href="commonTemplates.xsl"/>
|
||||
|
@ -11,44 +12,44 @@
|
|||
<divelog program="subsurface-import" version="2">
|
||||
<settings>
|
||||
<divecomputerid deviceid="ffffffff">
|
||||
<xsl:apply-templates select="/uddf/generator|/u:uddf/u:generator"/>
|
||||
<xsl:apply-templates select="/uddf/generator|/u:uddf/u:generator|/u1:uddf/u1:generator"/>
|
||||
</divecomputerid>
|
||||
</settings>
|
||||
<dives>
|
||||
<xsl:apply-templates select="/uddf/profiledata/repetitiongroup/dive|/u:uddf/u:profiledata/u:repetitiongroup/u:dive"/>
|
||||
<xsl:apply-templates select="/uddf/profiledata/repetitiongroup/dive|/u:uddf/u:profiledata/u:repetitiongroup/u:dive|/u1:uddf/u1:profiledata/u1:repetitiongroup/u1:dive"/>
|
||||
</dives>
|
||||
</divelog>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="generator|u:generator">
|
||||
<xsl:if test="manufacturer/name|u:manufacturer/u:name != ''">
|
||||
<xsl:template match="generator|u:generator|u1:generator">
|
||||
<xsl:if test="manufacturer/name|u:manufacturer/u:name|u1:manufacturer/u1:name != ''">
|
||||
<xsl:attribute name="model">
|
||||
<xsl:value-of select="name|u:name"/>
|
||||
<xsl:value-of select="name|u:name|u1:name"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="name|u:name != ''">
|
||||
<xsl:if test="name|u:name|u1:name != ''">
|
||||
<xsl:attribute name="firmware">
|
||||
<xsl:value-of select="manufacturer/name|/u:manufacturer/u:name"/>
|
||||
<xsl:value-of select="manufacturer/name|/u:manufacturer/u:name|/u1:manufacturer/u1:name"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="version|u:version != ''">
|
||||
<xsl:if test="version|u:version|u1:version != ''">
|
||||
<xsl:attribute name="serial">
|
||||
<xsl:value-of select="version|u:version"/>
|
||||
<xsl:value-of select="version|u:version|u1:version"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="gasdefinitions|u:gasdefinitions">
|
||||
<xsl:for-each select="u:mix|mix">
|
||||
<xsl:template match="gasdefinitions|u:gasdefinitions|u1:gasdefinitions">
|
||||
<xsl:for-each select="mix|u:mix|u1:mix">
|
||||
<cylinder>
|
||||
<xsl:attribute name="description">
|
||||
<xsl:value-of select="u:name|name"/>
|
||||
<xsl:value-of select="name|u:name|u1:name"/>
|
||||
</xsl:attribute>
|
||||
|
||||
<xsl:attribute name="o2">
|
||||
<xsl:call-template name="gasConvert">
|
||||
<xsl:with-param name="mix">
|
||||
<xsl:value-of select="u:o2|o2"/>
|
||||
<xsl:value-of select="o2|u:o2|u1:o2"/>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
|
@ -56,7 +57,7 @@
|
|||
<xsl:attribute name="he">
|
||||
<xsl:call-template name="gasConvert">
|
||||
<xsl:with-param name="mix">
|
||||
<xsl:value-of select="u:he|he"/>
|
||||
<xsl:value-of select="he|u:he|u1:he"/>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
|
@ -64,8 +65,15 @@
|
|||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="u:dive|dive">
|
||||
<xsl:template match="dive|u:dive|u1:dive">
|
||||
<dive>
|
||||
<!-- Count the amount of temeprature samples during the dive -->
|
||||
<xsl:variable name="temperatureSamples">
|
||||
<xsl:call-template name="temperatureSamples" select="samples/waypoint/temperature|u:samples/u:waypoint/u:temperature|u1:samples/u1:waypoint/u1:temperature">
|
||||
<xsl:with-param name="units" select="'Kelvin'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="date != ''">
|
||||
<xsl:attribute name="date">
|
||||
|
@ -75,44 +83,46 @@
|
|||
<xsl:value-of select="concat(format-number(time/hour, '00'), ':', format-number(time/minute, '00'))"/>
|
||||
</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:when test="informationbeforedive/datetime|u:informationbeforedive/u:datetime != ''">
|
||||
<xsl:when test="informationbeforedive/datetime|u:informationbeforedive/u:datetime|u1:informationbeforedive/u1:datetime != ''">
|
||||
<xsl:call-template name="datetime">
|
||||
<xsl:with-param name="value">
|
||||
<xsl:value-of select="informationbeforedive/datetime|u:informationbeforedive/u:datetime"/>
|
||||
<xsl:value-of select="informationbeforedive/datetime|u:informationbeforedive/u:datetime|u1:informationbeforedive/u1:datetime"/>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:for-each select="lowesttemperature|informationafterdive/lowesttemperature|u:lowesttemperature|u:informationafterdive/u:lowesttemperature">
|
||||
<xsl:for-each select="lowesttemperature|informationafterdive/lowesttemperature|u:lowesttemperature|u:informationafterdive/u:lowesttemperature|u1:lowesttemperature|u1:informationafterdive/u1:lowesttemperature">
|
||||
<temperature>
|
||||
<xsl:attribute name="water">
|
||||
<xsl:value-of select="concat(format-number(.- 273.15, '0.0'), ' C')"/>
|
||||
</xsl:attribute>
|
||||
<xsl:if test="$temperatureSamples > 0 or . != 273.15">
|
||||
<xsl:attribute name="water">
|
||||
<xsl:value-of select="concat(format-number(.- 273.15, '0.0'), ' C')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</temperature>
|
||||
</xsl:for-each>
|
||||
|
||||
<divecomputer deviceid="ffffffff">
|
||||
<xsl:attribute name="model">
|
||||
<xsl:value-of select="/uddf/generator/name|/u:uddf/u:generator/u:name"/>
|
||||
<xsl:value-of select="/uddf/generator/name|/u:uddf/u:generator/u:name|/u1:uddf/u1:generator/u1:name"/>
|
||||
</xsl:attribute>
|
||||
</divecomputer>
|
||||
|
||||
<xsl:apply-templates select="/uddf/gasdefinitions|/u:uddf/u:gasdefinitions"/>
|
||||
<xsl:apply-templates select="/uddf/gasdefinitions|/u:uddf/u:gasdefinitions|/u1:uddf/u1:gasdefinitions"/>
|
||||
<depth>
|
||||
<xsl:for-each select="greatestdepth|informationafterdive/greatestdepth|u:greatestdepth|u:informationafterdive/u:greatestdepth">
|
||||
<xsl:for-each select="greatestdepth|informationafterdive/greatestdepth|u:greatestdepth|u:informationafterdive/u:greatestdepth|u1:greatestdepth|u1:informationafterdive/u1:greatestdepth">
|
||||
<xsl:attribute name="max">
|
||||
<xsl:value-of select="concat(., ' m')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:for-each>
|
||||
<xsl:for-each select="averagedepth|informationafterdive/averagedepth|u:averagedepth|u:informationafterdive/u:averagedepth">
|
||||
<xsl:for-each select="averagedepth|informationafterdive/averagedepth|u:averagedepth|u:informationafterdive/u:averagedepth|u1:averagedepth|u1:informationafterdive/u1:averagedepth">
|
||||
<xsl:attribute name="mean">
|
||||
<xsl:value-of select="concat(., ' m')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:for-each>
|
||||
</depth>
|
||||
|
||||
<xsl:for-each select="samples/waypoint/switchmix|u:samples/u:waypoint/u:switchmix">
|
||||
<xsl:for-each select="samples/waypoint/switchmix|u:samples/u:waypoint/u:switchmix|u1:samples/u1:waypoint/u1:switchmix">
|
||||
<!-- Index to lookup gas per cent -->
|
||||
<xsl:variable name="idx">
|
||||
<xsl:value-of select="./@ref"/>
|
||||
|
@ -122,7 +132,7 @@
|
|||
<xsl:attribute name="time">
|
||||
<xsl:call-template name="timeConvert">
|
||||
<xsl:with-param name="timeSec">
|
||||
<xsl:value-of select="preceding-sibling::divetime|preceding-sibling::u:divetime"/>
|
||||
<xsl:value-of select="preceding-sibling::divetime|preceding-sibling::u:divetime|preceding-sibling::u1:divetime"/>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
|
@ -130,19 +140,19 @@
|
|||
<xsl:attribute name="value">
|
||||
<xsl:call-template name="gasConvert">
|
||||
<xsl:with-param name="mix">
|
||||
<xsl:value-of select="//gasdefinitions/mix[@id=$idx]/o2|//u:gasdefinitions/u:mix[@id=$idx]/u:o2"/>
|
||||
<xsl:value-of select="//gasdefinitions/mix[@id=$idx]/o2|//u:gasdefinitions/u:mix[@id=$idx]/u:o2|//u1:gasdefinitions/u1:mix[@id=$idx]/u1:o2"/>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
</event>
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:for-each select="samples/waypoint|u:samples/u:waypoint">
|
||||
<xsl:for-each select="samples/waypoint|u:samples/u:waypoint|u1:samples/u1:waypoint">
|
||||
<sample>
|
||||
<xsl:attribute name="time">
|
||||
<xsl:call-template name="timeConvert">
|
||||
<xsl:with-param name="timeSec">
|
||||
<xsl:value-of select="divetime|u:divetime"/>
|
||||
<xsl:value-of select="divetime|u:divetime|u1:divetime"/>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
|
@ -152,41 +162,41 @@
|
|||
<xsl:value-of select="concat(depth, ' m')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="u:depth != ''">
|
||||
<xsl:if test="u:depth|u1:depth != ''">
|
||||
<xsl:attribute name="depth">
|
||||
<xsl:value-of select="concat(u:depth, ' m')"/>
|
||||
<xsl:value-of select="concat(u:depth|u1:depth, ' m')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="temperature != ''">
|
||||
<xsl:if test="temperature != '' and $temperatureSamples > 0">
|
||||
<xsl:attribute name="temperature">
|
||||
<xsl:value-of select="concat(format-number(temperature - 273.15, '0.0'), ' C')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="u:temperature != ''">
|
||||
<xsl:if test="u:temperature|u1:temperature != '' and $temperatureSamples > 0">
|
||||
<xsl:attribute name="temperature">
|
||||
<xsl:value-of select="concat(format-number(u:temperature - 273.15, '0.0'), ' C')"/>
|
||||
<xsl:value-of select="concat(format-number(u:temperature|u1:temperature - 273.15, '0.0'), ' C')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="otu|u:otu > 0">
|
||||
<xsl:if test="otu|u:otu|u1:otu > 0">
|
||||
<xsl:attribute name="otu">
|
||||
<xsl:value-of select="otu|u:otu"/>
|
||||
<xsl:value-of select="otu|u:otu|u1:otu"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="cns|u:cns > 0">
|
||||
<xsl:if test="cns|u:cns|u1:cns > 0">
|
||||
<xsl:attribute name="cns">
|
||||
<xsl:value-of select="concat(cns|u:cns, ' C')"/>
|
||||
<xsl:value-of select="concat(cns|u:cns|u1:cns, ' C')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="setpo2|u:setpo2 != ''">
|
||||
<xsl:if test="setpo2|u:setpo2|u1:setpo2 != ''">
|
||||
<xsl:attribute name="po2">
|
||||
<xsl:call-template name="convertPascal">
|
||||
<xsl:with-param name="value">
|
||||
<xsl:value-of select="setpo2|u:setpo2"/>
|
||||
<xsl:value-of select="setpo2|u:setpo2|u1:setpo2"/>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
|
|
Loading…
Add table
Reference in a new issue