[PATCH] Support importing quoted multi-line notes field
Miika Turkia
miika.turkia at gmail.com
Wed Dec 31 03:14:41 PST 2014
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 <miika.turkia at gmail.com>
---
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,'"$fs')"/>
</xsl:when>
<xsl:otherwise>
- <xsl:if test="substring-after($line, '"$fs') = ''">
- <xsl:value-of select="substring-before(substring-after($line, '"'), '"')"/>
+ <xsl:if test="substring-after(substring-after($line, '"'), '"') = ''">
+ <xsl:value-of select="concat(substring-after($line, '"'), substring-before($remaining, '"'))"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
--
1.9.1
More information about the subsurface
mailing list