subsurface/xslt/xml2csv.xslt
Miika Turkia 2b559225d6 Quote header line properly on CSV export
Let's make the export consistent by quoting the header line the same way
the sample rows are quoted.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-26 17:17:02 -07:00

51 lines
1.9 KiB
HTML

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:output method="text" encoding="UTF-8"/>
<xsl:variable name="fs">,</xsl:variable>
<xsl:template match="/divelog/dives">
<xsl:value-of select="concat('&quot;dive number&quot;', $fs, '&quot;dive date&quot;', $fs, '&quot;dive time&quot;', $fs, '&quot;time&quot;', $fs, '&quot;depth&quot;', $fs, '&quot;temperature&quot;', $fs, '&quot;pressure&quot;')"/>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="dive|trip/dive"/>
</xsl:template>
<xsl:template match="dive">
<xsl:variable name="number">
<xsl:value-of select="@number"/>
</xsl:variable>
<xsl:variable name="date">
<xsl:value-of select="@date"/>
</xsl:variable>
<xsl:variable name="time">
<xsl:value-of select="@time"/>
</xsl:variable>
<xsl:for-each select="divecomputer/sample|sample">
<xsl:value-of select="concat('&quot;', $number, '&quot;')"/>
<xsl:value-of select="$fs"/>
<xsl:value-of select="concat('&quot;', $date, '&quot;')"/>
<xsl:value-of select="$fs"/>
<xsl:value-of select="concat('&quot;', $time, '&quot;')"/>
<xsl:value-of select="$fs"/>
<xsl:value-of select="concat('&quot;', substring-before(@time, ' '), '&quot;')"/>
<xsl:value-of select="$fs"/>
<xsl:value-of select="concat('&quot;', substring-before(@depth, ' '), '&quot;')"/>
<xsl:value-of select="$fs"/>
<xsl:if test="@temp != ''">
<xsl:value-of select="concat('&quot;', substring-before(@temp, ' '), '&quot;')"/>
</xsl:if>
<xsl:value-of select="$fs"/>
<xsl:if test="@pressure != ''">
<xsl:value-of select="concat('&quot;', substring-before(@pressure, ' '), '&quot;')"/>
</xsl:if>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>