mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Grab a bit more info from UDDF import
otu and po2 are now grabbed. The po2 value comes from setpo2 tag. Also divecomputerid is constructed from the generator information. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
51d2088021
commit
0f9142b4e3
2 changed files with 77 additions and 14 deletions
|
@ -1,6 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
<!-- Convert ISO 8601 time format to "standard" date and time format
|
||||
-->
|
||||
<xsl:template name="datetime">
|
||||
<xsl:param name="value"/>
|
||||
|
||||
|
@ -58,4 +60,42 @@
|
|||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Convert units in Pascal given in scientific notation to normal
|
||||
decimal notation -->
|
||||
<xsl:template name="convertPascal">
|
||||
<xsl:param name="value"/>
|
||||
|
||||
<xsl:variable name="number">
|
||||
<xsl:value-of select="translate($value, 'e', 'E')"/>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($number, 'E')">
|
||||
<xsl:variable name="pressure">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$value != ''">
|
||||
<xsl:variable name="Exp" select="substring-after($number, 'E')"/>
|
||||
<xsl:variable name="Man" select="substring-before($number, 'E')"/>
|
||||
<xsl:variable name="Fac" select="substring('100000000000000000000', 1, substring($Exp,2) + 1)"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$Exp != ''">
|
||||
<xsl:value-of select="(number($Man) * number($Fac))"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$number"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>0</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:value-of select="$pressure div 100000"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$value"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
|
|
@ -9,20 +9,34 @@
|
|||
|
||||
<xsl:template match="/">
|
||||
<divelog program="subsurface" version="2">
|
||||
<settings>
|
||||
<divecomputerid deviceid="ffffffff">
|
||||
<xsl:apply-templates select="/uddf/generator|/u:uddf/u:generator"/>
|
||||
</divecomputerid>
|
||||
</settings>
|
||||
<dives>
|
||||
<xsl:apply-templates select="/uddf/profiledata/repetitiongroup/dive|/u:uddf/u:profiledata/u:repetitiongroup/u:dive"/>
|
||||
</dives>
|
||||
</divelog>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Print warning if we don't handle some element -->
|
||||
<xsl:template match="*">
|
||||
<xsl:message terminate="no">
|
||||
WARNING: Unmatched element: <xsl:value-of select="name()"/>
|
||||
</xsl:message>
|
||||
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
<xsl:template match="generator|u:generator">
|
||||
<xsl:if test="manufacturer/name|u:manufacturer/u:name != ''">
|
||||
<xsl:attribute name="model">
|
||||
<xsl:value-of select="manufacturer/name|/u:manufacturer/u:name"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="name|u:name != ''">
|
||||
<xsl:attribute name="firmware">
|
||||
<xsl:value-of select="name|u:name"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="version|u:version != ''">
|
||||
<xsl:attribute name="serial">
|
||||
<xsl:value-of select="version|u:version"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="gasdefinitions|u:gasdefinitions">
|
||||
<xsl:for-each select="u:mix|mix">
|
||||
|
@ -150,16 +164,25 @@
|
|||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<!-- otu -->
|
||||
<xsl:if test="cns > 0">
|
||||
<xsl:attribute name="cns">
|
||||
<xsl:value-of select="concat(cns, ' C')"/>
|
||||
<xsl:if test="otu|u:otu > 0">
|
||||
<xsl:attribute name="otu">
|
||||
<xsl:value-of select="otu|u:otu"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="u:cns > 0">
|
||||
<xsl:if test="cns|u:cns > 0">
|
||||
<xsl:attribute name="cns">
|
||||
<xsl:value-of select="concat(u:cns, ' C')"/>
|
||||
<xsl:value-of select="concat(cns|u:cns, ' C')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="setpo2|u:setpo2 != ''">
|
||||
<xsl:attribute name="po2">
|
||||
<xsl:call-template name="convertPascal">
|
||||
<xsl:with-param name="value">
|
||||
<xsl:value-of select="setpo2|u:setpo2"/>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</sample>
|
||||
|
|
Loading…
Add table
Reference in a new issue