summaryrefslogtreecommitdiffstats
path: root/xslt/xml2manualcsv.xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2018-10-06 09:24:16 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-07 17:41:14 +0300
commitf96d1557594e6547c15e6f776901be7df89df546 (patch)
treefb4d7e1b828b569313d36f5c882354908378e824 /xslt/xml2manualcsv.xslt
parentc44ece0ea1b42d36ed1b0813f9d377f36435ba13 (diff)
downloadsubsurface-f96d1557594e6547c15e6f776901be7df89df546.tar.gz
CSV export: include unquoted quotable fields
Turns out that the initial quoting implementation discarded the fields without quoting. This one ensures we should be getting also that data exported. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Diffstat (limited to 'xslt/xml2manualcsv.xslt')
-rw-r--r--xslt/xml2manualcsv.xslt44
1 files changed, 28 insertions, 16 deletions
diff --git a/xslt/xml2manualcsv.xslt b/xslt/xml2manualcsv.xslt
index d16cf8399..b2de440f9 100644
--- a/xslt/xml2manualcsv.xslt
+++ b/xslt/xml2manualcsv.xslt
@@ -219,6 +219,7 @@
<xsl:call-template name="quote">
<xsl:with-param name="line" select="substring-before(translate(translate(@tags, $fs, ' '), $lf, ' '), '&quot;')"/>
<xsl:with-param name="remaining" select="substring-after(translate(translate(@tags, $fs, ' '), $lf, ' '), '&quot;')"/>
+ <xsl:with-param name="all" select="@tags"/>
</xsl:call-template>
<xsl:text>&quot;</xsl:text>
@@ -336,6 +337,7 @@
<xsl:call-template name="quote">
<xsl:with-param name="line" select="substring-before(translate(translate(., $fs, ' '), $lf, ' '), '&quot;')"/>
<xsl:with-param name="remaining" select="substring-after(translate(translate(., $fs, ' '), $lf, ' '), '&quot;')"/>
+ <xsl:with-param name="all" select="translate(., $fs, ' ')"/>
</xsl:call-template>
<xsl:text>&quot;</xsl:text>
</xsl:template>
@@ -345,6 +347,7 @@
<xsl:call-template name="quote">
<xsl:with-param name="line" select="substring-before(translate(translate(., $fs, ' '), $lf, ' '), '&quot;')"/>
<xsl:with-param name="remaining" select="substring-after(translate(translate(., $fs, ' '), $lf, ' '), '&quot;')"/>
+ <xsl:with-param name="all" select="."/>
</xsl:call-template>
<xsl:text>&quot;</xsl:text>
</xsl:template>
@@ -354,6 +357,7 @@
<xsl:call-template name="quote">
<xsl:with-param name="line" select="substring-before(translate(translate(., $fs, ' '), $lf, ' '), '&quot;')"/>
<xsl:with-param name="remaining" select="substring-after(translate(translate(., $fs, ' '), $lf, ' '), '&quot;')"/>
+ <xsl:with-param name="all" select="."/>
</xsl:call-template>
<xsl:text>&quot;</xsl:text>
</xsl:template>
@@ -363,6 +367,7 @@
<xsl:call-template name="quote">
<xsl:with-param name="line" select="substring-before(translate(translate(., $fs, ' '), $lf, '\n'), '&quot;')"/>
<xsl:with-param name="remaining" select="substring-after(translate(translate(., $fs, ' '), $lf, '\n'), '&quot;')"/>
+ <xsl:with-param name="all" select="translate(translate(., $fs, ' '), $lf, '\n')"/>
</xsl:call-template>
<xsl:text>&quot;</xsl:text>
</xsl:template>
@@ -370,22 +375,29 @@
<xsl:template name="quote">
<xsl:param name="line"/>
<xsl:param name="remaining"/>
+ <xsl:param name="all"/>
- <xsl:if test="$line != ''">
- <xsl:value-of select="concat($line, '&quot;', '&quot;')"/>
- </xsl:if>
- <xsl:if test="$remaining != ''">
- <xsl:choose>
- <xsl:when test="substring-before($remaining, '&quot;') != ''">
- <xsl:call-template name="quote">
- <xsl:with-param name="line" select="substring-before($remaining, '&quot;')"/>
- <xsl:with-param name="remaining" select="substring-after($remaining, '&quot;')"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$remaining" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
+ <xsl:choose>
+ <xsl:when test="$line = ''">
+ <xsl:value-of select="$all"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat($line, '&quot;', '&quot;')"/>
+ <xsl:if test="$remaining != ''">
+ <xsl:choose>
+ <xsl:when test="substring-before($remaining, '&quot;') != ''">
+ <xsl:call-template name="quote">
+ <xsl:with-param name="line" select="substring-before($remaining, '&quot;')"/>
+ <xsl:with-param name="remaining" select="substring-after($remaining, '&quot;')"/>
+ <xsl:with-param name="all" select="$remaining"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$remaining" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
</xsl:stylesheet>