aboutsummaryrefslogtreecommitdiffstats
path: root/xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2018-10-07 14:56:46 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-07 17:41:14 +0300
commitd3239aed0fbe374da600090336f55f05208f2178 (patch)
tree8fccce211963ab398cf9a6d4aa71d8cc5ea16a37 /xslt
parentb3694faefc0ea68c9b25f779d59cdf26f19bca7d (diff)
downloadsubsurface-d3239aed0fbe374da600090336f55f05208f2178.tar.gz
CSV import: support for quoted "
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Diffstat (limited to 'xslt')
-rw-r--r--xslt/commonTemplates.xsl44
1 files changed, 43 insertions, 1 deletions
diff --git a/xslt/commonTemplates.xsl b/xslt/commonTemplates.xsl
index cd26f10ec..82efeacb9 100644
--- a/xslt/commonTemplates.xsl
+++ b/xslt/commonTemplates.xsl
@@ -286,6 +286,34 @@
<xsl:value-of select="concat($year, '-', $month, '-', $day, ' ', $time)"/>
</xsl:template>
+ <xsl:template name="unquote">
+ <xsl:param name="field" />
+ <xsl:param name="value" />
+
+ <xsl:variable name="quote">
+ <xsl:choose>
+ <xsl:when test="$value != ''">
+ <xsl:value-of select="'&quot;'"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="''"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="substring-before($field, '&quot;') = ''">
+ <xsl:value-of select="concat($value, '&quot;', $field)" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="unquote">
+ <xsl:with-param name="field" select="substring-after(substring-after($field, '&quot;'), '&quot;')" />
+ <xsl:with-param name="value" select="concat($value, $quote, substring-before($field, '&quot;'))" />
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
<xsl:template name="getFieldByIndex">
<xsl:param name="index"/>
<xsl:param name="line"/>
@@ -303,7 +331,21 @@
<xsl:when test="substring($line, 1, 1) = '&quot;'">
<xsl:choose>
<xsl:when test="substring-before(substring-after($line, '&quot;'), concat('&quot;', $fs)) != ''">
- <xsl:value-of select="substring-before(substring-after($line, '&quot;'), concat('&quot;', $fs))"/>
+
+
+ <xsl:choose>
+ <xsl:when test="substring-before(substring-before(substring-after($line, '&quot;'), concat('&quot;', $fs)), '&quot;') != ''">
+ <xsl:call-template name="unquote">
+ <xsl:with-param name="field" select="substring-before(substring-after($line, '&quot;'), concat('&quot;', $fs))" />
+ <xsl:with-param name="value" select="''" />
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+
+ <xsl:value-of select="substring-before(substring-after($line, '&quot;'), concat('&quot;', $fs))"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
</xsl:when>
<xsl:otherwise>
<xsl:choose>