diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2014-12-22 23:04:07 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-12-22 14:26:19 -0800 |
commit | 7c23a0892182e126df570bd8272dd9214d82886d (patch) | |
tree | 3d65a498ba9acb1db8780e263dd6bbddea41101e | |
parent | a950365b6ff137c21677539f16555e8a66208c0f (diff) | |
download | subsurface-7c23a0892182e126df570bd8272dd9214d82886d.tar.gz |
Support quoting strings with "" on manual CSV import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | xslt/manualcsv2xml.xslt | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/xslt/manualcsv2xml.xslt b/xslt/manualcsv2xml.xslt index ac9d5c354..597b296f7 100644 --- a/xslt/manualcsv2xml.xslt +++ b/xslt/manualcsv2xml.xslt @@ -347,23 +347,51 @@ <xsl:param name="line"/> <xsl:choose> <xsl:when test="$index > 0"> - <xsl:call-template name="getFieldByIndex"> - <xsl:with-param name="index" select="$index -1"/> - <xsl:with-param name="line" select="substring-after($line, $fs)"/> - </xsl:call-template> + <xsl:choose> + <xsl:when test="substring($line, 1, 1) = '"'"> + <xsl:call-template name="getFieldByIndex"> + <xsl:with-param name="index" select="$index -1"/> + <xsl:with-param name="line" select="substring-after($line, $fs)"/> + </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:call-template> + </xsl:otherwise> + </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:choose> - <xsl:when test="substring-before($line,$fs) != ''"> - <xsl:value-of select="substring-before($line,$fs)"/> + <xsl:when test="substring($line, 1, 1) = '"'"> + <xsl:choose> + <xsl:when test="substring-before($line,'"$fs') != ''"> + <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:otherwise> + </xsl:choose> </xsl:when> + <xsl:otherwise> - <xsl:if test="substring-after($line, $fs) = ''"> - <xsl:value-of select="$line"/> - </xsl:if> + <xsl:choose> + <xsl:when test="substring-before($line,$fs) != ''"> + <xsl:value-of select="substring-before($line,$fs)"/> + </xsl:when> + <xsl:otherwise> + <xsl:if test="substring-after($line, $fs) = ''"> + <xsl:value-of select="$line"/> + </xsl:if> + </xsl:otherwise> + </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> + </xsl:template> </xsl:stylesheet> |