[PATCH] Translate comma to colon on XML import

Miika Turkia miika.turkia at gmail.com
Thu Mar 7 11:57:21 PST 2013


Translate decimal commas on XML import to decimal points. (As detected
from available sample files using Linus' debug printing.)

Also check for empty values on MacDive temperature import.

Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 xslt/MacDive.xslt             |   10 +++++++---
 xslt/SuuntoSDM.xslt           |    6 +++---
 xslt/jdivelog2subsurface.xslt |    2 +-
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/xslt/MacDive.xslt b/xslt/MacDive.xslt
index e9ad9a8..c719e69 100644
--- a/xslt/MacDive.xslt
+++ b/xslt/MacDive.xslt
@@ -297,7 +297,7 @@
         <weightsystem>
           <xsl:attribute name="weight">
             <xsl:call-template name="weightConvert">
-              <xsl:with-param name="weight" select="weight"/>
+              <xsl:with-param name="weight" select="translate(weight, ',', '.')"/>
               <xsl:with-param name="units" select="$units"/>
             </xsl:call-template>
           </xsl:attribute>
@@ -435,10 +435,14 @@
 
     <xsl:choose>
       <xsl:when test="$units = 'Imperial'">
-        <xsl:value-of select="concat(format-number(($temp - 32) * 5 div 9, '0.0'), ' C')"/>
+        <xsl:if test="$temp != ''">
+          <xsl:value-of select="concat(format-number(($temp - 32) * 5 div 9, '0.0'), ' C')"/>
+        </xsl:if>
       </xsl:when>
       <xsl:otherwise>
-        <xsl:value-of select="concat($temp, ' C')"/>
+        <xsl:if test="$temp != ''">
+          <xsl:value-of select="concat($temp, ' C')"/>
+        </xsl:if>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>
diff --git a/xslt/SuuntoSDM.xslt b/xslt/SuuntoSDM.xslt
index a3159a5..3a56a10 100644
--- a/xslt/SuuntoSDM.xslt
+++ b/xslt/SuuntoSDM.xslt
@@ -33,10 +33,10 @@
 
       <xsl:choose>
         <xsl:when test="MEANDEPTH != ''">
-          <depth max="{concat(MAXDEPTH,' m')}" mean="{concat(MEANDEPTH, ' m')}"/>
+          <depth max="{concat(translate(MAXDEPTH, ',', '.'),' m')}" mean="{concat(translate(MEANDEPTH, ',', '.'), ' m')}"/>
         </xsl:when>
         <xsl:otherwise>
-          <depth max="{concat(MAXDEPTH,' m')}"/>
+          <depth max="{concat(translate(MAXDEPTH, ',', '.'),' m')}"/>
         </xsl:otherwise>
       </xsl:choose>
 
@@ -187,7 +187,7 @@
                 </xsl:call-template>
               </xsl:attribute>
               <xsl:attribute name="depth">
-                <xsl:value-of select="concat(DEPTH, ' m')"/>
+                <xsl:value-of select="concat(translate(DEPTH, ',', '.'), ' m')"/>
               </xsl:attribute>
               <xsl:attribute name="temp">
                 <xsl:value-of select="TEMPERATURE"/>
diff --git a/xslt/jdivelog2subsurface.xslt b/xslt/jdivelog2subsurface.xslt
index b09c578..b36eb96 100644
--- a/xslt/jdivelog2subsurface.xslt
+++ b/xslt/jdivelog2subsurface.xslt
@@ -78,7 +78,7 @@
                 <xsl:value-of select="0" />
               </xsl:when>
               <xsl:otherwise>
-                <xsl:value-of select="Equipment/Weight"/>
+                <xsl:value-of select="translate(Equipment/Weight, ',', '.')"/>
               </xsl:otherwise>
             </xsl:choose>
           </xsl:attribute>
-- 
1.7.9.5



More information about the subsurface mailing list