mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
CSV import: support for quoted "
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
This commit is contained in:
parent
b3694faefc
commit
d3239aed0f
1 changed files with 43 additions and 1 deletions
|
@ -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="'"'"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="''"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="substring-before($field, '"') = ''">
|
||||
<xsl:value-of select="concat($value, '"', $field)" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="unquote">
|
||||
<xsl:with-param name="field" select="substring-after(substring-after($field, '"'), '"')" />
|
||||
<xsl:with-param name="value" select="concat($value, $quote, substring-before($field, '"'))" />
|
||||
</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) = '"'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="substring-before(substring-after($line, '"'), concat('"', $fs)) != ''">
|
||||
<xsl:value-of select="substring-before(substring-after($line, '"'), concat('"', $fs))"/>
|
||||
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="substring-before(substring-before(substring-after($line, '"'), concat('"', $fs)), '"') != ''">
|
||||
<xsl:call-template name="unquote">
|
||||
<xsl:with-param name="field" select="substring-before(substring-after($line, '"'), concat('"', $fs))" />
|
||||
<xsl:with-param name="value" select="''" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
|
||||
<xsl:value-of select="substring-before(substring-after($line, '"'), concat('"', $fs))"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
|
|
Loading…
Reference in a new issue