[PATCH 1/2] Support for multi-line notes on SubsurfaceCSV import

Miika Turkia miika.turkia at gmail.com
Mon Jan 5 00:09:40 PST 2015


This patch only implements the feature, indentation fix is to follow.
This ensures that the actual change can be more easily reviewed.

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

diff --git a/xslt/subsurfacecsv.xslt b/xslt/subsurfacecsv.xslt
index 3afbd03..077ec6c 100644
--- a/xslt/subsurfacecsv.xslt
+++ b/xslt/subsurfacecsv.xslt
@@ -33,6 +33,7 @@
 
     <xsl:call-template name="printFields">
       <xsl:with-param name="line" select="$line"/>
+      <xsl:with-param name="remaining" select="$remaining"/>
     </xsl:call-template>
 
     <xsl:if test="$remaining != ''">
@@ -45,8 +46,15 @@
 
   <xsl:template name="printFields">
     <xsl:param name="line"/>
+    <xsl:param name="remaining"/>
 
-
+    <xsl:variable name="number">
+      <xsl:call-template name="getFieldByIndex">
+        <xsl:with-param name="index" select="0"/>
+        <xsl:with-param name="line" select="$line"/>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:if test="$number >= 0">
     <dive>
       <xsl:attribute name="date">
         <xsl:call-template name="getFieldByIndex">
@@ -63,10 +71,7 @@
       </xsl:attribute>
 
       <xsl:attribute name="number">
-        <xsl:call-template name="getFieldByIndex">
-          <xsl:with-param name="index" select="0"/>
-          <xsl:with-param name="line" select="$line"/>
-        </xsl:call-template>
+        <xsl:value-of select="$number"/>
       </xsl:attribute>
 
       <xsl:attribute name="duration">
@@ -345,6 +350,7 @@
         <xsl:call-template name="getFieldByIndex">
           <xsl:with-param name="index" select="20"/>
           <xsl:with-param name="line" select="$line"/>
+          <xsl:with-param name="remaining" select="$remaining"/>
         </xsl:call-template>
       </xsl:variable>
       <xsl:if test="$notes != ''">
@@ -375,11 +381,13 @@
       </xsl:if>
 
     </dive>
+  </xsl:if>
   </xsl:template>
 
   <xsl:template name="getFieldByIndex">
     <xsl:param name="index"/>
     <xsl:param name="line"/>
+    <xsl:param name="remaining"/>
     <xsl:choose>
       <xsl:when test="$index > 0">
         <xsl:choose>
@@ -387,12 +395,14 @@
             <xsl:call-template name="getFieldByIndex">
               <xsl:with-param name="index" select="$index -1"/>
               <xsl:with-param name="line" select="substring-after($line, $fs)"/>
+              <xsl:with-param name="remaining" select="$remaining"/>
             </xsl:call-template>
           </xsl:when>
           <xsl:otherwise>
             <xsl:call-template name="getFieldByIndex">
               <xsl:with-param name="index" select="$index -1"/>
               <xsl:with-param name="line" select="substring-after($line, $fs)"/>
+              <xsl:with-param name="remaining" select="$remaining"/>
             </xsl:call-template>
           </xsl:otherwise>
         </xsl:choose>
@@ -405,9 +415,14 @@
                 <xsl:value-of select="substring-before($line,'"$fs')"/>
               </xsl:when>
               <xsl:otherwise>
-                <xsl:if test="substring-after($line, '"$fs') = ''">
-                  <xsl:value-of select="substring-before(substring-after($line, '"'), '"')"/>
-                </xsl:if>
+                <xsl:choose>
+                  <xsl:when test="substring-after(substring-after($line, '"'), '"') = ''">
+                    <xsl:value-of select="concat(substring-after($line, '"'), $lf, substring-before($remaining, '"'))"/>
+                  </xsl:when>
+                  <xsl:otherwise>
+                    <xsl:value-of select="substring-before(substring-after($line, '"'), '"')"/>
+                  </xsl:otherwise>
+                </xsl:choose>
               </xsl:otherwise>
             </xsl:choose>
           </xsl:when>
-- 
1.9.1



More information about the subsurface mailing list