aboutsummaryrefslogtreecommitdiffstats
path: root/xslt/xml2manualcsv.xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2014-12-31 22:09:35 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-12-31 12:12:26 -0800
commit48019a73d55a4493e8eb47383cda12c5f9054039 (patch)
tree9bb2e87dae7c40a2be2cb0de861a1f71c728a4b3 /xslt/xml2manualcsv.xslt
parent5d68c7d4a19ca56405bc039808e7262eb3b18510 (diff)
downloadsubsurface-48019a73d55a4493e8eb47383cda12c5f9054039.tar.gz
Imperial support for CSV details export
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'xslt/xml2manualcsv.xslt')
-rw-r--r--xslt/xml2manualcsv.xslt82
1 files changed, 73 insertions, 9 deletions
diff --git a/xslt/xml2manualcsv.xslt b/xslt/xml2manualcsv.xslt
index d78062327..e0cfb575c 100644
--- a/xslt/xml2manualcsv.xslt
+++ b/xslt/xml2manualcsv.xslt
@@ -3,6 +3,7 @@
xmlns:xt="http://www.jclark.com/xt"
extension-element-prefixes="xt" 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>
@@ -46,15 +47,36 @@
<xsl:otherwise>
<xsl:value-of select="$fs"/>
<xsl:text>&quot;</xsl:text>
- <xsl:value-of select="cylinder[1]/@size"/>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:value-of select="cylinder/@description"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="cylinder[1]/@size"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="$fs"/>
<xsl:text>&quot;</xsl:text>
- <xsl:value-of select="divecomputer[1]/sample[@pressure]/@pressure"/>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:value-of select="concat(format-number((substring-before(divecomputer[1]/sample[@pressure]/@pressure, ' ') * 14.5037738007), '#'), ' psi')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="divecomputer[1]/sample[@pressure]/@pressure"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="$fs"/>
<xsl:text>&quot;</xsl:text>
- <xsl:value-of select="divecomputer[1]/sample[@pressure][last()]/@pressure"/>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:value-of select="concat(format-number((substring-before(divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') * 14.5037738007), '#'), ' psi')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="divecomputer[1]/sample[@pressure][last()]/@pressure"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="$fs"/>
<xsl:text>&quot;</xsl:text>
@@ -127,21 +149,49 @@
<xsl:template match="divecomputer/depth">
<xsl:value-of select="$fs"/>
<xsl:text>&quot;</xsl:text>
- <xsl:value-of select="@max"/>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:value-of select="concat(format-number((substring-before(@max, ' ') div 0.3048), '#.#'), ' ft')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@max"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="$fs"/>
<xsl:text>&quot;</xsl:text>
- <xsl:value-of select="@mean"/>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:value-of select="concat(format-number((substring-before(@mean, ' ') div 0.3048), '#.#'), ' ft')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@mean"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:text>&quot;</xsl:text>
</xsl:template>
<xsl:template match="divetemperature|temperature">
<xsl:value-of select="$fs"/>
<xsl:text>&quot;</xsl:text>
- <xsl:value-of select="@air"/>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:value-of select="concat(format-number((substring-before(@air, ' ') * 1.8) + 32, '0.0'), ' F')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@air"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="$fs"/>
<xsl:text>&quot;</xsl:text>
- <xsl:value-of select="@water"/>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:value-of select="concat(format-number((substring-before(@water, ' ') * 1.8) + 32, '0.0'), ' F')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@water"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:text>&quot;</xsl:text>
</xsl:template>
<xsl:template match="cylinder">
@@ -151,11 +201,25 @@
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="$fs"/>
<xsl:text>&quot;</xsl:text>
- <xsl:value-of select="@start"/>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:value-of select="concat(format-number((substring-before(@start, ' ') * 14.5037738007), '#'), ' psi')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@start"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="$fs"/>
<xsl:text>&quot;</xsl:text>
- <xsl:value-of select="@end"/>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:value-of select="concat(format-number((substring-before(@end, ' ') * 14.5037738007), '#'), ' psi')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@end"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="$fs"/>
<xsl:text>&quot;</xsl:text>