Update dive site structure in UDDF export to match UDDF 3.2.0 specification.

The dive site structure in the UDDF export was using an old structure
where each site is simply listed as a <dive_site>.

The new structure requires a single <divesite> containing at least one
<divebase> - a base location where you are diving from, and at least one
<site>.

As subsurface only tracks sites, I've created a single divebase to be
referenced by all of the sites.

Note: although profiles in Subsurface can be grouped into trips, these
are groupings of profiles, not sites, and the mapping may not be
simple. e.g. on different trips the sames sites may be visited but a
different base used. Or, different bases may be used on a single trip.

Signed-off-by: Marton Long <martin@longhome.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Martin Long 2014-12-09 23:24:48 +00:00 committed by Dirk Hohndel
parent b462a8da35
commit aa74cd8802

View file

@ -78,7 +78,15 @@
</xsl:for-each>
</diver>
<xsl:apply-templates select="//location"/>
<divesite>
<!-- There must be at least one divebase. Subsurface doesn't track this as a concept, so just assign them all to a single divebase. -->
<divebase id="allbase">
<name>Subsurface Divebase</name>
</divebase>
<xsl:apply-templates select="//location"/>
</divesite>
<!-- Define all the unique gases found in the dive log -->
<gasdefinitions>
@ -163,27 +171,26 @@
<xsl:key name="location" match="location" use="."/>
<xsl:template match="location">
<xsl:if test="generate-id() = generate-id(key('location', normalize-space(.)))">
<dive_site>
<site>
<xsl:attribute name="id">
<xsl:value-of select="."/>
</xsl:attribute>
<name>
<xsl:value-of select="."/>
</name>
<link ref="allbase"/>
<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>
<latitude>
<xsl:value-of select="substring-before(@gps, ' ')"/>
</latitude>
<longitude>
<xsl:value-of select="substring-after(@gps, ' ')"/>
</longitude>
</geography>
</dive_site>
</site>
</xsl:if>
</xsl:template>
@ -219,11 +226,11 @@
</link>
</xsl:for-each>
<xsl:if test="location != ''">
<dive_site_ref>
<link>
<xsl:attribute name="ref">
<xsl:value-of select="location"/>
</xsl:attribute>
</dive_site_ref>
</link>
</xsl:if>
</informationbeforedive>