diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2014-12-31 22:09:35 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-12-31 12:12:26 -0800 |
commit | 48019a73d55a4493e8eb47383cda12c5f9054039 (patch) | |
tree | 9bb2e87dae7c40a2be2cb0de861a1f71c728a4b3 | |
parent | 5d68c7d4a19ca56405bc039808e7262eb3b18510 (diff) | |
download | subsurface-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>
-rw-r--r-- | xslt/xml2manualcsv.xslt | 82 |
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>"</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>"</xsl:text> <xsl:value-of select="$fs"/> <xsl:text>"</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>"</xsl:text> <xsl:value-of select="$fs"/> <xsl:text>"</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>"</xsl:text> <xsl:value-of select="$fs"/> <xsl:text>"</xsl:text> @@ -127,21 +149,49 @@ <xsl:template match="divecomputer/depth"> <xsl:value-of select="$fs"/> <xsl:text>"</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>"</xsl:text> <xsl:value-of select="$fs"/> <xsl:text>"</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>"</xsl:text> </xsl:template> <xsl:template match="divetemperature|temperature"> <xsl:value-of select="$fs"/> <xsl:text>"</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>"</xsl:text> <xsl:value-of select="$fs"/> <xsl:text>"</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>"</xsl:text> </xsl:template> <xsl:template match="cylinder"> @@ -151,11 +201,25 @@ <xsl:text>"</xsl:text> <xsl:value-of select="$fs"/> <xsl:text>"</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>"</xsl:text> <xsl:value-of select="$fs"/> <xsl:text>"</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>"</xsl:text> <xsl:value-of select="$fs"/> <xsl:text>"</xsl:text> |