Dive computer import improvements

Parse dive computer information or divelog generator information and
include it as divecomputerid and divecomputer as appropriate.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Miika Turkia 2013-03-02 13:10:38 +02:00 committed by Dirk Hohndel
parent e89c2fd656
commit aa02798e2a
3 changed files with 43 additions and 19 deletions

View file

@ -5,10 +5,16 @@
<xsl:template match="/"> <xsl:template match="/">
<divelog program='subsurface' version='2'> <divelog program='subsurface' version='2'>
<settings> <settings>
<divecomputer> <xsl:for-each select="/dives/dive">
<xsl:apply-templates select="/dives/dive/computer"/> <divecomputerid deviceid="ffffffff">
<xsl:apply-templates select="/dives/dive/serial"/> <xsl:attribute name="model">
</divecomputer> <xsl:value-of select="computer"/>
</xsl:attribute>
<xsl:attribute name="serial">
<xsl:value-of select="serial"/>
</xsl:attribute>
</divecomputerid>
</xsl:for-each>
</settings> </settings>
<dives> <dives>
<xsl:apply-templates select="/dives/dive"/> <xsl:apply-templates select="/dives/dive"/>
@ -16,18 +22,6 @@
</divelog> </divelog>
</xsl:template> </xsl:template>
<xsl:template match="computer">
<xsl:attribute name="model">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
<xsl:template match="serial">
<xsl:attribute name="serial">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
<xsl:template match="dive"> <xsl:template match="dive">
<xsl:variable name="units" select="/dives/units"/> <xsl:variable name="units" select="/dives/units"/>
@ -152,7 +146,7 @@
<xsl:value-of select="notes"/> <xsl:value-of select="notes"/>
</notes> </notes>
<divecomputer> <divecomputer deviceid="ffffffff">
<xsl:attribute name="model"> <xsl:attribute name="model">
<xsl:value-of select="computer"/> <xsl:value-of select="computer"/>
</xsl:attribute> </xsl:attribute>

View file

@ -5,12 +5,30 @@
<xsl:template match="/"> <xsl:template match="/">
<divelog program="subsurface" version="2"> <divelog program="subsurface" version="2">
<settings>
<divecomputerid deviceid="ffffffff">
<xsl:apply-templates select="/PROFILE/DEVICE|/profile/device"/>
</divecomputerid>
</settings>
<dives> <dives>
<xsl:apply-templates select="/PROFILE/REPGROUP/DIVE|/profile/repgroup/dive"/> <xsl:apply-templates select="/PROFILE/REPGROUP/DIVE|/profile/repgroup/dive"/>
</dives> </dives>
</divelog> </divelog>
</xsl:template> </xsl:template>
<xsl:template match="DEVICE|device">
<xsl:if test="MODEL|model != ''">
<xsl:attribute name="model">
<xsl:value-of select="MODEL|model"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="version|VERSION != ''">
<xsl:attribute name="serial">
<xsl:value-of select="VERSION|version"/>
</xsl:attribute>
</xsl:if>
</xsl:template>
<xsl:template match="DIVE|dive"> <xsl:template match="DIVE|dive">
<dive> <dive>
<xsl:attribute name="date"> <xsl:attribute name="date">
@ -39,6 +57,12 @@
</temperature> </temperature>
</xsl:if> </xsl:if>
<divecomputer deviceid="ffffffff">
<xsl:attribute name="model">
<xsl:value-of select="/PROFILE/DEVICE/MODEL|/profile/device/model"/>
</xsl:attribute>
</divecomputer>
<xsl:for-each select="GASES/MIX|gases/mix"> <xsl:for-each select="GASES/MIX|gases/mix">
<cylinder> <cylinder>
<xsl:attribute name="description"> <xsl:attribute name="description">

View file

@ -23,12 +23,12 @@
<xsl:template match="generator|u:generator"> <xsl:template match="generator|u:generator">
<xsl:if test="manufacturer/name|u:manufacturer/u:name != ''"> <xsl:if test="manufacturer/name|u:manufacturer/u:name != ''">
<xsl:attribute name="model"> <xsl:attribute name="model">
<xsl:value-of select="manufacturer/name|/u:manufacturer/u:name"/> <xsl:value-of select="name|u:name"/>
</xsl:attribute> </xsl:attribute>
</xsl:if> </xsl:if>
<xsl:if test="name|u:name != ''"> <xsl:if test="name|u:name != ''">
<xsl:attribute name="firmware"> <xsl:attribute name="firmware">
<xsl:value-of select="name|u:name"/> <xsl:value-of select="manufacturer/name|/u:manufacturer/u:name"/>
</xsl:attribute> </xsl:attribute>
</xsl:if> </xsl:if>
<xsl:if test="version|u:version != ''"> <xsl:if test="version|u:version != ''">
@ -92,6 +92,12 @@
</temperature> </temperature>
</xsl:for-each> </xsl:for-each>
<divecomputer deviceid="ffffffff">
<xsl:attribute name="model">
<xsl:value-of select="/uddf/generator/name|/u:uddf/u:generator/u:name"/>
</xsl:attribute>
</divecomputer>
<xsl:apply-templates select="/uddf/gasdefinitions|/u:uddf/u:gasdefinitions"/> <xsl:apply-templates select="/uddf/gasdefinitions|/u:uddf/u:gasdefinitions"/>
<depth> <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">