This adds support for importing multi-line notes field on CSV import.
Naturally the notes filed must be quoted with " in this case.

Signed-off-by: Miika Turkia <[email protected]>
---
 xslt/manualcsv2xml.xslt | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/xslt/manualcsv2xml.xslt b/xslt/manualcsv2xml.xslt
index 597b296..55968b5 100644
--- a/xslt/manualcsv2xml.xslt
+++ b/xslt/manualcsv2xml.xslt
@@ -55,6 +55,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 != ''">
@@ -67,6 +68,7 @@
 
   <xsl:template name="printFields">
     <xsl:param name="line"/>
+    <xsl:param name="remaining"/>
 
     <xsl:variable name="number">
       <xsl:choose>
@@ -313,6 +315,7 @@
           <xsl:call-template name="getFieldByIndex">
             <xsl:with-param name="index" select="$notesField"/>
             <xsl:with-param name="line" select="$line"/>
+            <xsl:with-param name="remaining" select="$remaining"/>
           </xsl:call-template>
         </notes>
       </xsl:if>
@@ -345,6 +348,7 @@
   <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>
@@ -352,12 +356,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>
@@ -370,8 +376,8 @@
                 <xsl:value-of select="substring-before($line,'&quot;$fs')"/>
               </xsl:when>
               <xsl:otherwise>
-                <xsl:if test="substring-after($line, '&quot;$fs') = ''">
-                  <xsl:value-of 
select="substring-before(substring-after($line, '&quot;'), '&quot;')"/>
+                <xsl:if test="substring-after(substring-after($line, 
'&quot;'), '&quot;') = ''">
+                  <xsl:value-of select="concat(substring-after($line, 
'&quot;'), substring-before($remaining, '&quot;'))"/>
                 </xsl:if>
               </xsl:otherwise>
             </xsl:choose>
-- 
1.9.1

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to