aboutsummaryrefslogtreecommitdiffstats
path: root/xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2014-02-15 10:51:23 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-15 06:33:33 -0800
commitcb5ab4bc8e192e65dded3bc3f3bfb703441e5436 (patch)
treea115e650a96881748c8ccdd60f62e3a01e0b322f /xslt
parent31aa93857a794078c6a43e4a5b9808a95f13a04e (diff)
downloadsubsurface-cb5ab4bc8e192e65dded3bc3f3bfb703441e5436.tar.gz
Add unit support for CSV 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/csv2xml.xslt34
1 files changed, 31 insertions, 3 deletions
diff --git a/xslt/csv2xml.xslt b/xslt/csv2xml.xslt
index ee8b7556e..5ae689a0b 100644
--- a/xslt/csv2xml.xslt
+++ b/xslt/csv2xml.xslt
@@ -11,6 +11,7 @@
<xsl:param name="stopdepthField" select="stopdepthField"/>
<xsl:param name="date" select="date"/>
<xsl:param name="time" select="time"/>
+ <xsl:param name="units" select="units"/>
<xsl:param name="separatorIndex" select="separatorIndex"/>
<xsl:output method="xml" indent="yes"/>
@@ -113,19 +114,39 @@
</xsl:choose>
</xsl:attribute>
- <xsl:attribute name="depth">
+ <xsl:variable name="depth">
<xsl:call-template name="getFieldByIndex">
<xsl:with-param name="index" select="$depthField"/>
<xsl:with-param name="line" select="$line"/>
</xsl:call-template>
+ </xsl:variable>
+ <xsl:attribute name="depth">
+ <xsl:choose>
+ <xsl:when test="$units = 0">
+ <xsl:value-of select="$depth"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$depth * 0.3048"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:attribute>
<xsl:if test="$tempField >= 0">
- <xsl:attribute name="temp">
+ <xsl:variable name="temp">
<xsl:call-template name="getFieldByIndex">
<xsl:with-param name="index" select="$tempField"/>
<xsl:with-param name="line" select="$line"/>
</xsl:call-template>
+ </xsl:variable>
+ <xsl:attribute name="temp">
+ <xsl:choose>
+ <xsl:when test="$units = 0">
+ <xsl:value-of select="$temp"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat(format-number(($temp - 32) * 5 div 9, '0.0'), ' C')"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:attribute>
</xsl:if>
@@ -164,7 +185,14 @@
</xsl:call-template>
</xsl:variable>
<xsl:attribute name="stopdepth">
- <xsl:copy-of select="$stopdepth"/>
+ <xsl:choose>
+ <xsl:when test="$units = 0">
+ <xsl:copy-of select="$stopdepth"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="format-number($stopdepth * 0.3048, '0.00')"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:attribute>
<xsl:attribute name="in_deco">