[PATCH 1/4] CSV import: support time with decimal comma

Miika Turkia miika.turkia at gmail.com
Wed Nov 9 11:39:23 PST 2016


Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 xslt/csv2xml.xslt | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/xslt/csv2xml.xslt b/xslt/csv2xml.xslt
index da41bb1..95ead33 100644
--- a/xslt/csv2xml.xslt
+++ b/xslt/csv2xml.xslt
@@ -213,7 +213,7 @@
     </xsl:variable>
 
 
-    <xsl:if test="number($value) = $value or number(substring-before($value, ':')) = substring-before($value, ':')">
+    <xsl:if test="number(translate($value, ',', '.')) = translate($value, ',', '.') or number(substring-before($value, ':')) = substring-before($value, ':')">
       <sample>
         <xsl:attribute name="time">
           <xsl:choose>
@@ -224,7 +224,7 @@
                 </xsl:with-param>
               </xsl:call-template>
             </xsl:when>
-            <xsl:when test="number($value) = $value">
+            <xsl:when test="number(translate($value, ',', '.')) = translate($value, ',', '.')">
               <!-- We assume time in seconds -->
 
               <xsl:call-template name="sec2time">
@@ -234,6 +234,10 @@
                       <!-- Well, I suppose it was min.sec -->
                       <xsl:value-of select="substring-before($value, '.') * 60 + substring-after($value, '.')" />
                     </xsl:when>
+                    <xsl:when test="substring-after($value, ',') != ''">
+                      <!-- Well, I suppose it was min.sec -->
+                      <xsl:value-of select="substring-before($value, ',') * 60 + substring-after($value, ',')" />
+                    </xsl:when>
                     <xsl:otherwise>
                       <xsl:value-of select="$value"/>
                     </xsl:otherwise>
-- 
2.5.0



More information about the subsurface mailing list