summaryrefslogtreecommitdiffstats
path: root/xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2015-07-31 08:19:38 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-31 10:32:23 -0700
commit232001a1f55793ec3d6897a307497b3fa796540f (patch)
tree8a82258e43c9fa707bb0a15c71c2cb9302d4b325 /xslt
parentd7a5bae4c8e32232818d76626a1b737c625b7c19 (diff)
downloadsubsurface-232001a1f55793ec3d6897a307497b3fa796540f.tar.gz
CSV import: implement unit conversion for temperature
If input is in F, we need to convert it to C on import. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'xslt')
-rw-r--r--xslt/manualcsv2xml.xslt36
1 files changed, 28 insertions, 8 deletions
diff --git a/xslt/manualcsv2xml.xslt b/xslt/manualcsv2xml.xslt
index 5141c445e..769092664 100644
--- a/xslt/manualcsv2xml.xslt
+++ b/xslt/manualcsv2xml.xslt
@@ -223,18 +223,38 @@
<temperature>
<xsl:if test="$airtempField &gt;= 0">
<xsl:attribute name="air">
- <xsl:call-template name="getFieldByIndex">
- <xsl:with-param name="index" select="$airtempField"/>
- <xsl:with-param name="line" select="$line"/>
- </xsl:call-template>
+ <xsl:variable name="air">
+ <xsl:call-template name="getFieldByIndex">
+ <xsl:with-param name="index" select="$airtempField"/>
+ <xsl:with-param name="line" select="$line"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$units = 0">
+ <xsl:value-of select="$air"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="(translate(translate($air, translate($air, '1234567890,.', ''), ''), ',', '.') - 32) * 5 div 9"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:attribute>
</xsl:if>
<xsl:if test="$watertempField &gt;= 0">
<xsl:attribute name="water">
- <xsl:call-template name="getFieldByIndex">
- <xsl:with-param name="index" select="$watertempField"/>
- <xsl:with-param name="line" select="$line"/>
- </xsl:call-template>
+ <xsl:variable name="water">
+ <xsl:call-template name="getFieldByIndex">
+ <xsl:with-param name="index" select="$watertempField"/>
+ <xsl:with-param name="line" select="$line"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$units = 0">
+ <xsl:value-of select="$water"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="(translate(translate($water, translate($water, '1234567890,.', ''), ''), ',', '.') - 32) * 5 div 9"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:attribute>
</xsl:if>
</temperature>