On Tue, Nov 3, 2015 at 5:27 PM, Dirk Hohndel <d...@hohndel.org> wrote:
> On Tue, Nov 03, 2015 at 02:43:50PM +0200, Lubomir I. Ivanov wrote:
>> On 3 November 2015 at 06:24, Miika Turkia <miika.tur...@gmail.com> wrote:
>> >
>> > I would not be surprised, if there was still something more lurking 
>> > around...
>>
>> yours and Linus' patches make the file work.
>> i'm sure everyone has noticed that the parsing of this file slow as
>> heck, though...and it locks the UI, which could make the user think
>> the app has hanged. :\
>
> Yes, this definitely needs some kind of progress indicator.
>
> A secondary concern would be some profiling to figure out WHY it takes so
> bloody long, but frankly, this is a corner case / rare use case so I'm not
> as worked up about this. But we definitely need a progress indicator.
>
>> like mentioned in one of my previous emails there is something wrong
>> when parsing depths. i get a lot of:
>> "Strange depth reading NaN m"
>>
>> probably due to some of the samples in the XSLT output being:
>> <sample time="" depth="NaN m"/>
>
> Miika, can we just skip those? A depth that is Not a Number isn't really
> all that interesting...
>
> And please, don't get me started on software that writes shit like this
> into a data file.

These were empty waypoints (samples) that can easily be discarded...
Two patches, so you actually see the real change and don't get flooded
with indentation changes.

miika
From 875ddef13f17fca8eb3300d0c6fa82f673b43910 Mon Sep 17 00:00:00 2001
From: Miika Turkia <miika.tur...@gmail.com>
Date: Tue, 3 Nov 2015 18:14:07 +0200
Subject: [PATCH 2/2] Fix UDDF import indentation

Only indentation is changed on this commit.

Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 xslt/uddf.xslt | 184 ++++++++++++++++++++++++++++-----------------------------
 1 file changed, 92 insertions(+), 92 deletions(-)

diff --git a/xslt/uddf.xslt b/xslt/uddf.xslt
index dddd8bd..89e40b1 100644
--- a/xslt/uddf.xslt
+++ b/xslt/uddf.xslt
@@ -459,107 +459,107 @@
 
       <xsl:for-each select="samples/waypoint|u:samples/u:waypoint|u1:samples/u1:waypoint|samples/d">
         <xsl:if test="./depth|./u:depth|./u1:depth != ''">
-        <sample>
-          <xsl:attribute name="time">
-            <xsl:call-template name="timeConvert">
-              <xsl:with-param name="timeSec">
-                <xsl:value-of select="divetime|u:divetime|u1:divetime|preceding-sibling::t[1]"/>
-              </xsl:with-param>
-            </xsl:call-template>
-          </xsl:attribute>
+          <sample>
+            <xsl:attribute name="time">
+              <xsl:call-template name="timeConvert">
+                <xsl:with-param name="timeSec">
+                  <xsl:value-of select="divetime|u:divetime|u1:divetime|preceding-sibling::t[1]"/>
+                </xsl:with-param>
+              </xsl:call-template>
+            </xsl:attribute>
 
-          <xsl:choose>
-            <xsl:when test="depth != ''">
-              <xsl:attribute name="depth">
-                <xsl:value-of select="concat(format-number(depth, '0.00'), ' m')"/>
-              </xsl:attribute>
-            </xsl:when>
-            <xsl:when test="u:depth|u1:depth != ''">
-              <xsl:attribute name="depth">
-                <xsl:value-of select="concat(format-number(u:depth|u1:depth, '0.00'), ' m')"/>
-              </xsl:attribute>
-            </xsl:when>
-            <xsl:when test=". != 0">
-              <xsl:attribute name="depth">
-                <xsl:value-of select="concat(format-number(., '0.00'), ' m')"/>
+            <xsl:choose>
+              <xsl:when test="depth != ''">
+                <xsl:attribute name="depth">
+                  <xsl:value-of select="concat(format-number(depth, '0.00'), ' m')"/>
+                </xsl:attribute>
+              </xsl:when>
+              <xsl:when test="u:depth|u1:depth != ''">
+                <xsl:attribute name="depth">
+                  <xsl:value-of select="concat(format-number(u:depth|u1:depth, '0.00'), ' m')"/>
+                </xsl:attribute>
+              </xsl:when>
+              <xsl:when test=". != 0">
+                <xsl:attribute name="depth">
+                  <xsl:value-of select="concat(format-number(., '0.00'), ' m')"/>
+                </xsl:attribute>
+              </xsl:when>
+            </xsl:choose>
+
+            <xsl:if test="temperature != '' and $temperatureSamples &gt; 0">
+              <xsl:attribute name="temp">
+                <xsl:value-of select="concat(format-number(temperature - 273.15, '0.0'), ' C')"/>
               </xsl:attribute>
-            </xsl:when>
-          </xsl:choose>
-
-          <xsl:if test="temperature != '' and $temperatureSamples &gt; 0">
-            <xsl:attribute name="temp">
-              <xsl:value-of select="concat(format-number(temperature - 273.15, '0.0'), ' C')"/>
-            </xsl:attribute>
-          </xsl:if>
+            </xsl:if>
 
-          <xsl:if test="u:temperature|u1:temperature != '' and $temperatureSamples &gt; 0">
-            <xsl:attribute name="temp">
-              <xsl:value-of select="concat(format-number(u:temperature|u1:temperature - 273.15, '0.0'), ' C')"/>
-            </xsl:attribute>
-          </xsl:if>
+            <xsl:if test="u:temperature|u1:temperature != '' and $temperatureSamples &gt; 0">
+              <xsl:attribute name="temp">
+                <xsl:value-of select="concat(format-number(u:temperature|u1:temperature - 273.15, '0.0'), ' C')"/>
+              </xsl:attribute>
+            </xsl:if>
 
-          <xsl:if test="tankpressure|u:tankpressure|u1:tankpressure != ''">
-            <xsl:attribute name="pressure">
-              <xsl:value-of select="concat(format-number(tankpressure|u:tankpressure|u1:tankpressure div 100000, '0.0'), ' bar')"/>
-            </xsl:attribute>
-          </xsl:if>
+            <xsl:if test="tankpressure|u:tankpressure|u1:tankpressure != ''">
+              <xsl:attribute name="pressure">
+                <xsl:value-of select="concat(format-number(tankpressure|u:tankpressure|u1:tankpressure div 100000, '0.0'), ' bar')"/>
+              </xsl:attribute>
+            </xsl:if>
 
-          <xsl:if test="otu|u:otu|u1:otu &gt; 0">
-            <xsl:attribute name="otu">
-              <xsl:value-of select="otu|u:otu|u1:otu"/>
-            </xsl:attribute>
-          </xsl:if>
+            <xsl:if test="otu|u:otu|u1:otu &gt; 0">
+              <xsl:attribute name="otu">
+                <xsl:value-of select="otu|u:otu|u1:otu"/>
+              </xsl:attribute>
+            </xsl:if>
 
-          <xsl:if test="cns|u:cns|u1:cns &gt; 0">
-            <xsl:attribute name="cns">
-              <xsl:value-of select="cns|u:cns|u1:cns"/>
-            </xsl:attribute>
-          </xsl:if>
+            <xsl:if test="cns|u:cns|u1:cns &gt; 0">
+              <xsl:attribute name="cns">
+                <xsl:value-of select="cns|u:cns|u1:cns"/>
+              </xsl:attribute>
+            </xsl:if>
 
-          <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|u1:setpo2"/>
-                </xsl:with-param>
-              </xsl:call-template>
-            </xsl:attribute>
-          </xsl:if>
+            <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|u1:setpo2"/>
+                  </xsl:with-param>
+                </xsl:call-template>
+              </xsl:attribute>
+            </xsl:if>
 
-          <xsl:if test="nodecotime|u:nodecotime|u1:nodecotime &gt; 0">
-            <xsl:attribute name="ndl">
-              <xsl:call-template name="timeConvert">
-                <xsl:with-param name="timeSec">
-                  <xsl:value-of select="nodecotime|u:nodecotime|u1:nodecotime"/>
-                </xsl:with-param>
-              </xsl:call-template>
-            </xsl:attribute>
-          </xsl:if>
+            <xsl:if test="nodecotime|u:nodecotime|u1:nodecotime &gt; 0">
+              <xsl:attribute name="ndl">
+                <xsl:call-template name="timeConvert">
+                  <xsl:with-param name="timeSec">
+                    <xsl:value-of select="nodecotime|u:nodecotime|u1:nodecotime"/>
+                  </xsl:with-param>
+                </xsl:call-template>
+              </xsl:attribute>
+            </xsl:if>
 
-          <xsl:if test="decostop|u:decostop|u1:decostop">
-            <xsl:attribute name="stoptime">
-              <xsl:call-template name="timeConvert">
-                <xsl:with-param name="timeSec">
-                  <xsl:value-of select="decostop/@duration|u:decostop/@duration|u1:decostop/@duration"/>
-                </xsl:with-param>
-              </xsl:call-template>
-            </xsl:attribute>
-            <xsl:attribute name="stopdepth">
-              <xsl:value-of select="decostop/@decodepth|u:decostop/@decodepth|u1:decostop/@decodepth"/>
-            </xsl:attribute>
-            <xsl:attribute name="in_deco">
-              <xsl:choose>
-                <xsl:when test="decostop/@kind|u:decostop/@kind|u1:decostop/@kind != 'mandatory'">
-                  <xsl:value-of select="0"/>
-                </xsl:when>
-                <xsl:otherwise>
-                  <xsl:value-of select="1"/>
-                </xsl:otherwise>
-              </xsl:choose>
-            </xsl:attribute>
-          </xsl:if>
-        </sample>
-      </xsl:if>
+            <xsl:if test="decostop|u:decostop|u1:decostop">
+              <xsl:attribute name="stoptime">
+                <xsl:call-template name="timeConvert">
+                  <xsl:with-param name="timeSec">
+                    <xsl:value-of select="decostop/@duration|u:decostop/@duration|u1:decostop/@duration"/>
+                  </xsl:with-param>
+                </xsl:call-template>
+              </xsl:attribute>
+              <xsl:attribute name="stopdepth">
+                <xsl:value-of select="decostop/@decodepth|u:decostop/@decodepth|u1:decostop/@decodepth"/>
+              </xsl:attribute>
+              <xsl:attribute name="in_deco">
+                <xsl:choose>
+                  <xsl:when test="decostop/@kind|u:decostop/@kind|u1:decostop/@kind != 'mandatory'">
+                    <xsl:value-of select="0"/>
+                  </xsl:when>
+                  <xsl:otherwise>
+                    <xsl:value-of select="1"/>
+                  </xsl:otherwise>
+                </xsl:choose>
+              </xsl:attribute>
+            </xsl:if>
+          </sample>
+        </xsl:if>
       </xsl:for-each>
       </divecomputer>
     </dive>
-- 
2.1.4

From eae229ed646531f0a0252922ad301fc714166720 Mon Sep 17 00:00:00 2001
From: Miika Turkia <miika.tur...@gmail.com>
Date: Tue, 3 Nov 2015 18:12:48 +0200
Subject: [PATCH 1/2] Only include samples with data on UDDF import

According to the specification each proper sample should have depth, so
we can just ignore the empty waypoints.

Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 xslt/uddf.xslt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xslt/uddf.xslt b/xslt/uddf.xslt
index d37bf67..dddd8bd 100644
--- a/xslt/uddf.xslt
+++ b/xslt/uddf.xslt
@@ -458,6 +458,7 @@
       </xsl:for-each>
 
       <xsl:for-each select="samples/waypoint|u:samples/u:waypoint|u1:samples/u1:waypoint|samples/d">
+        <xsl:if test="./depth|./u:depth|./u1:depth != ''">
         <sample>
           <xsl:attribute name="time">
             <xsl:call-template name="timeConvert">
@@ -558,6 +559,7 @@
             </xsl:attribute>
           </xsl:if>
         </sample>
+      </xsl:if>
       </xsl:for-each>
       </divecomputer>
     </dive>
-- 
2.1.4

_______________________________________________
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to