[PATCH 2/7] Update dive site structure in UDDF export to match UDDF 3.2.0 specification.

Martin Long martin at longhome.co.uk
Tue Dec 9 15:24:48 PST 2014


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.
---
 xslt/uddf-export.xslt | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/xslt/uddf-export.xslt b/xslt/uddf-export.xslt
index d452bf8..42e0e58 100644
--- a/xslt/uddf-export.xslt
+++ b/xslt/uddf-export.xslt
@@ -78,8 +78,16 @@
         </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>
         <!-- Get unique gas mixes from all the recorded dives -->
@@ -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>
 
-- 
1.9.1



More information about the subsurface mailing list