mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-11 03:21:29 +00:00
9b7d321c87
Let's show the units in CSV header so the actual fields have only the values. This should be easier to parse with some other programs. Fixes #472 Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
80 lines
3.2 KiB
HTML
80 lines
3.2 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:param name="units" select="units"/>
|
|
<xsl:output method="text" encoding="UTF-8"/>
|
|
|
|
<xsl:variable name="fs">,</xsl:variable>
|
|
|
|
<xsl:template match="/divelog/dives">
|
|
<xsl:choose>
|
|
<xsl:when test="$units = 1">
|
|
<xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"sample time"', $fs, '"sample depth (ft)"', $fs, '"sample temperature (F)"', $fs, '"sample pressure (psi)"')"/>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"sample time"', $fs, '"sample depth (m)"', $fs, '"sample temperature (C)"', $fs, '"sample pressure (bar)"')"/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
<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[1]/sample|sample">
|
|
<xsl:value-of select="concat('"', $number, '"')"/>
|
|
<xsl:value-of select="$fs"/>
|
|
<xsl:value-of select="concat('"', $date, '"')"/>
|
|
<xsl:value-of select="$fs"/>
|
|
<xsl:value-of select="concat('"', $time, '"')"/>
|
|
<xsl:value-of select="$fs"/>
|
|
<xsl:value-of select="concat('"', substring-before(@time, ' '), '"')"/>
|
|
<xsl:value-of select="$fs"/>
|
|
<xsl:choose>
|
|
<xsl:when test="$units = 1">
|
|
<xsl:value-of select="concat('"', round((substring-before(@depth, ' ') div 0.3048) * 1000) div 1000, '"')"/>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:value-of select="concat('"', round(substring-before(@depth, ' ') * 1000) div 1000, '"')"/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
|
|
<xsl:value-of select="$fs"/>
|
|
<xsl:if test="@temp != ''">
|
|
<xsl:choose>
|
|
<xsl:when test="$units = 1">
|
|
<xsl:value-of select="concat('"', format-number((substring-before(@temp, ' ') * 1.8) + 32, '#.#'), '"')"/>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:value-of select="concat('"', substring-before(@temp, ' '), '"')"/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:if>
|
|
|
|
<xsl:value-of select="$fs"/>
|
|
<xsl:if test="@pressure != ''">
|
|
<xsl:choose>
|
|
<xsl:when test="$units = 1">
|
|
<xsl:value-of select="concat('"', format-number((substring-before(@pressure, ' ') * 14.5037738007), '#'), '"')"/>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<xsl:value-of select="concat('"', substring-before(@pressure, ' '), '"')"/>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
</xsl:if>
|
|
|
|
<xsl:text>
|
|
</xsl:text>
|
|
</xsl:for-each>
|
|
</xsl:template>
|
|
|
|
</xsl:stylesheet>
|