summaryrefslogtreecommitdiffstats
path: root/xslt
diff options
context:
space:
mode:
Diffstat (limited to 'xslt')
-rw-r--r--xslt/subsurfacecsv.xslt23
-rw-r--r--xslt/xml2csv.xslt15
-rw-r--r--xslt/xml2manualcsv.xslt67
3 files changed, 70 insertions, 35 deletions
diff --git a/xslt/subsurfacecsv.xslt b/xslt/subsurfacecsv.xslt
index 871d70f99..e4c3106bb 100644
--- a/xslt/subsurfacecsv.xslt
+++ b/xslt/subsurfacecsv.xslt
@@ -134,7 +134,7 @@
<xsl:value-of select="$max"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="concat(format-number((substring-before($max, ' ') * 0.3048), '#.##'), ' m')"/>
+ <xsl:value-of select="concat(round(translate(translate($max, translate($max, '0123456789,.', ''), ''), ',', '.') * 0.3048 * 1000) div 1000, ' m')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
@@ -146,7 +146,7 @@
<xsl:value-of select="$mean"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="concat(format-number((substring-before($mean, ' ') * 0.3048), '#.##'), ' m')"/>
+ <xsl:value-of select="concat(round(translate(translate($mean, translate($mean, '0123456789,.', ''), ''), ',', '.') * 0.3048 * 1000) div 1000, ' m')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
@@ -173,7 +173,7 @@
<xsl:value-of select="$air"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="concat(format-number((substring-before($air, ' ') - 32) * 5 div 9, '0.0'), ' C')"/>
+ <xsl:value-of select="concat(format-number((translate(translate($air, translate($air, '0123456789,.', ''), ''), ',', '.') - 32) * 5 div 9, '0.0'), ' C')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
@@ -185,7 +185,7 @@
<xsl:value-of select="$water"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="concat(format-number((substring-before($water, ' ') - 32) * 5 div 9, '0.0'), ' C')"/>
+ <xsl:value-of select="concat(format-number((translate(translate($water, translate($water, '0123456789,.', ''), ''), ',', '.') - 32) * 5 div 9, '0.0'), ' C')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
@@ -241,7 +241,14 @@
<xsl:value-of select="format-number((translate($size, translate($size, '0123456789', ''), '') * 14.7 div 3440) div 0.035315, '#.#')"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="$size"/>
+ <xsl:choose>
+ <xsl:when test="$units = 0">
+ <xsl:value-of select="$size"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="format-number((translate($size, translate($size, '0123456789', ''), '') * 14.7 div 3000) div 0.035315, '#.#')"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
@@ -258,7 +265,7 @@
<xsl:value-of select="$start"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="concat(format-number((substring-before($start, ' ') div 14.5037738007), '#'), ' bar')"/>
+ <xsl:value-of select="concat(format-number((translate($start, translate($start, '0123456789', ''), '') div 14.5037738007), '#'), ' bar')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
@@ -270,7 +277,7 @@
<xsl:value-of select="$end"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="concat(format-number((substring-before($end, ' ') div 14.5037738007), '#'), ' bar')"/>
+ <xsl:value-of select="concat(format-number((translate($end, translate($end, '0123456789', ''), '') div 14.5037738007), '#'), ' bar')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
@@ -373,7 +380,7 @@
<xsl:value-of select="$weight"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="concat(format-number((substring-before($weight, ' ') * 0.453592), '#.##'), ' kg')"/>
+ <xsl:value-of select="concat(format-number((translate($weight, translate($weight, '0123456789', ''), '') * 0.453592), '#.##'), ' kg')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
diff --git a/xslt/xml2csv.xslt b/xslt/xml2csv.xslt
index 211597325..25f5d8b7c 100644
--- a/xslt/xml2csv.xslt
+++ b/xslt/xml2csv.xslt
@@ -7,7 +7,14 @@
<xsl:variable name="fs">,</xsl:variable>
<xsl:template match="/divelog/dives">
- <xsl:value-of select="concat('&quot;dive number&quot;', $fs, '&quot;date&quot;', $fs, '&quot;time&quot;', $fs, '&quot;sample time&quot;', $fs, '&quot;sample depth&quot;', $fs, '&quot;sample temperature&quot;', $fs, '&quot;sample pressure&quot;')"/>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:value-of select="concat('&quot;dive number&quot;', $fs, '&quot;date&quot;', $fs, '&quot;time&quot;', $fs, '&quot;sample time&quot;', $fs, '&quot;sample depth (ft)&quot;', $fs, '&quot;sample temperature (F)&quot;', $fs, '&quot;sample pressure (psi)&quot;')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat('&quot;dive number&quot;', $fs, '&quot;date&quot;', $fs, '&quot;time&quot;', $fs, '&quot;sample time&quot;', $fs, '&quot;sample depth (m)&quot;', $fs, '&quot;sample temperature (C)&quot;', $fs, '&quot;sample pressure (bar)&quot;')"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="dive|trip/dive"/>
@@ -34,7 +41,7 @@
<xsl:value-of select="$fs"/>
<xsl:choose>
<xsl:when test="$units = 1">
- <xsl:value-of select="concat('&quot;', round((substring-before(@depth, ' ') div 0.3048) * 1000) div 1000, ' ft&quot;')"/>
+ <xsl:value-of select="concat('&quot;', round((substring-before(@depth, ' ') div 0.3048) * 1000) div 1000, '&quot;')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('&quot;', round(substring-before(@depth, ' ') * 1000) div 1000, '&quot;')"/>
@@ -45,7 +52,7 @@
<xsl:if test="@temp != ''">
<xsl:choose>
<xsl:when test="$units = 1">
- <xsl:value-of select="concat('&quot;', format-number((substring-before(@temp, ' ') * 1.8) + 32, '#.#'), ' F&quot;')"/>
+ <xsl:value-of select="concat('&quot;', format-number((substring-before(@temp, ' ') * 1.8) + 32, '#.#'), '&quot;')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('&quot;', substring-before(@temp, ' '), '&quot;')"/>
@@ -57,7 +64,7 @@
<xsl:if test="@pressure != ''">
<xsl:choose>
<xsl:when test="$units = 1">
- <xsl:value-of select="concat('&quot;', format-number((substring-before(@pressure, ' ') * 14.5037738007), '#'), ' psi&quot;')"/>
+ <xsl:value-of select="concat('&quot;', format-number((substring-before(@pressure, ' ') * 14.5037738007), '#'), '&quot;')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('&quot;', substring-before(@pressure, ' '), '&quot;')"/>
diff --git a/xslt/xml2manualcsv.xslt b/xslt/xml2manualcsv.xslt
index fcb97b52d..242332756 100644
--- a/xslt/xml2manualcsv.xslt
+++ b/xslt/xml2manualcsv.xslt
@@ -11,7 +11,14 @@
</xsl:text></xsl:variable>
<xsl:template match="/divelog/dives">
- <xsl:value-of select="concat('&quot;dive number&quot;', $fs, '&quot;date&quot;', $fs, '&quot;time&quot;', $fs, '&quot;duration&quot;', $fs, '&quot;maxdepth&quot;', $fs, '&quot;avgdepth&quot;', $fs, '&quot;airtemp&quot;', $fs, '&quot;watertemp&quot;', $fs, '&quot;cylinder size&quot;', $fs, '&quot;startpressure&quot;', $fs, '&quot;endpressure&quot;', $fs, '&quot;o2&quot;', $fs, '&quot;he&quot;', $fs, '&quot;location&quot;', $fs, '&quot;gps&quot;', $fs, '&quot;divemaster&quot;', $fs, '&quot;buddy&quot;', $fs, '&quot;suit&quot;', $fs, '&quot;rating&quot;', $fs, '&quot;visibility&quot;', $fs, '&quot;notes&quot;', $fs, '&quot;weight&quot;', $fs, '&quot;tags&quot;')"/>
+ <xsl:choose>
+ <xsl:when test="$units = 1">
+ <xsl:value-of select="concat('&quot;dive number&quot;', $fs, '&quot;date&quot;', $fs, '&quot;time&quot;', $fs, '&quot;duration&quot;', $fs, '&quot;maxdepth (ft)&quot;', $fs, '&quot;avgdepth (ft)&quot;', $fs, '&quot;airtemp (F)&quot;', $fs, '&quot;watertemp (F)&quot;', $fs, '&quot;cylinder size (cuft)&quot;', $fs, '&quot;startpressure (psi)&quot;', $fs, '&quot;endpressure (psi)&quot;', $fs, '&quot;o2&quot;', $fs, '&quot;he&quot;', $fs, '&quot;location&quot;', $fs, '&quot;gps&quot;', $fs, '&quot;divemaster&quot;', $fs, '&quot;buddy&quot;', $fs, '&quot;suit&quot;', $fs, '&quot;rating&quot;', $fs, '&quot;visibility&quot;', $fs, '&quot;notes&quot;', $fs, '&quot;weight (lbs)&quot;', $fs, '&quot;tags&quot;')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat('&quot;dive number&quot;', $fs, '&quot;date&quot;', $fs, '&quot;time&quot;', $fs, '&quot;duration&quot;', $fs, '&quot;maxdepth (m)&quot;', $fs, '&quot;avgdepth (m)&quot;', $fs, '&quot;airtemp (C)&quot;', $fs, '&quot;watertemp (C)&quot;', $fs, '&quot;cylinder size (l)&quot;', $fs, '&quot;startpressure (bar)&quot;', $fs, '&quot;endpressure (bar)&quot;', $fs, '&quot;o2&quot;', $fs, '&quot;he&quot;', $fs, '&quot;location&quot;', $fs, '&quot;gps&quot;', $fs, '&quot;divemaster&quot;', $fs, '&quot;buddy&quot;', $fs, '&quot;suit&quot;', $fs, '&quot;rating&quot;', $fs, '&quot;visibility&quot;', $fs, '&quot;notes&quot;', $fs, '&quot;weight (kg)&quot;', $fs, '&quot;tags&quot;')"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="dive|trip/dive"/>
@@ -71,10 +78,10 @@
<xsl:text>&quot;</xsl:text>
<xsl:choose>
<xsl:when test="$units = 1">
- <xsl:value-of select="concat(format-number((cylinder[1]/@size div 14.7 * 3000) * 0.035315, '#.#'), ' cuft')"/>
+ <xsl:value-of select="concat(format-number((substring-before(cylinder[1]/@size, ' ') div 14.7 * 3000) * 0.035315, '#.#'), '')"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="cylinder[1]/@size"/>
+ <xsl:value-of select="substring-before(cylinder[1]/@size, ' ')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&quot;</xsl:text>
@@ -82,10 +89,17 @@
<xsl:text>&quot;</xsl:text>
<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:choose>
+ <xsl:when test="substring-before(divecomputer[1]/sample[@pressure]/@pressure, ' ') &gt; 0">
+ <xsl:value-of select="concat(format-number((substring-before(divecomputer[1]/sample[@pressure]/@pressure, ' ') * 14.5037738007), '#'), '')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="''"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="divecomputer[1]/sample[@pressure]/@pressure"/>
+ <xsl:value-of select="substring-before(divecomputer[1]/sample[@pressure]/@pressure, ' ')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&quot;</xsl:text>
@@ -93,10 +107,17 @@
<xsl:text>&quot;</xsl:text>
<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:choose>
+ <xsl:when test="substring-before(divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') &gt; 0">
+ <xsl:value-of select="concat(format-number((substring-before(divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') * 14.5037738007), '#'), '')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="''"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="divecomputer[1]/sample[@pressure][last()]/@pressure"/>
+ <xsl:value-of select="substring-before(divecomputer[1]/sample[@pressure][last()]/@pressure, ' ')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&quot;</xsl:text>
@@ -184,10 +205,10 @@
<xsl:if test="weightsystem">
<xsl:choose>
<xsl:when test="$units = 1">
- <xsl:value-of select="concat(format-number((sum(xt:node-set($trimmedweightlist)/node()) div 0.453592), '#.##'), ' lb')"/>
+ <xsl:value-of select="concat(format-number((sum(xt:node-set($trimmedweightlist)/node()) div 0.453592), '#.##'), '')"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="concat(sum(xt:node-set($trimmedweightlist)/node()), ' kg')"/>
+ <xsl:value-of select="concat(sum(xt:node-set($trimmedweightlist)/node()), '')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
@@ -206,10 +227,10 @@
<xsl:text>&quot;</xsl:text>
<xsl:choose>
<xsl:when test="$units = 1">
- <xsl:value-of select="concat(format-number((substring-before(@max, ' ') div 0.3048), '#.##'), ' ft')"/>
+ <xsl:value-of select="concat(format-number((substring-before(@max, ' ') div 0.3048), '#.##'), '')"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="@max"/>
+ <xsl:value-of select="substring-before(@max, ' ')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&quot;</xsl:text>
@@ -217,10 +238,10 @@
<xsl:text>&quot;</xsl:text>
<xsl:choose>
<xsl:when test="$units = 1">
- <xsl:value-of select="concat(format-number((substring-before(@mean, ' ') div 0.3048), '#.##'), ' ft')"/>
+ <xsl:value-of select="concat(format-number((substring-before(@mean, ' ') div 0.3048), '#.##'), '')"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="@mean"/>
+ <xsl:value-of select="substring-before(@mean, ' ')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&quot;</xsl:text>
@@ -231,11 +252,11 @@
<xsl:choose>
<xsl:when test="$units = 1">
<xsl:if test="substring-before(@air, ' ') &gt; 0">
- <xsl:value-of select="concat(format-number((substring-before(@air, ' ') * 1.8) + 32, '0.0'), ' F')"/>
+ <xsl:value-of select="concat(format-number((substring-before(@air, ' ') * 1.8) + 32, '0.0'), '')"/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="@air"/>
+ <xsl:value-of select="substring-before(@air, ' ')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&quot;</xsl:text>
@@ -244,11 +265,11 @@
<xsl:choose>
<xsl:when test="$units = 1">
<xsl:if test="substring-before(@water, ' ') &gt; 0">
- <xsl:value-of select="concat(format-number((substring-before(@water, ' ') * 1.8) + 32, '0.0'), ' F')"/>
+ <xsl:value-of select="concat(format-number((substring-before(@water, ' ') * 1.8) + 32, '0.0'), '')"/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="@water"/>
+ <xsl:value-of select="substring-before(@water, ' ')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&quot;</xsl:text>
@@ -258,10 +279,10 @@
<xsl:text>&quot;</xsl:text>
<xsl:choose>
<xsl:when test="$units = 1">
- <xsl:value-of select="concat(format-number((substring-before(@size, ' ') div 14.7 * 3000) * 0.035315, '#.#'), ' cuft')"/>
+ <xsl:value-of select="concat(format-number((substring-before(@size, ' ') div 14.7 * 3000) * 0.035315, '#.#'), '')"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="@size"/>
+ <xsl:value-of select="substring-before(@size, ' ')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&quot;</xsl:text>
@@ -269,10 +290,10 @@
<xsl:text>&quot;</xsl:text>
<xsl:choose>
<xsl:when test="$units = 1">
- <xsl:value-of select="concat(format-number((substring-before(@start, ' ') * 14.5037738007), '#'), ' psi')"/>
+ <xsl:value-of select="concat(format-number((substring-before(@start, ' ') * 14.5037738007), '#'), '')"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="@start"/>
+ <xsl:value-of select="substring-before(@start, ' ')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&quot;</xsl:text>
@@ -280,10 +301,10 @@
<xsl:text>&quot;</xsl:text>
<xsl:choose>
<xsl:when test="$units = 1">
- <xsl:value-of select="concat(format-number((substring-before(@end, ' ') * 14.5037738007), '#'), ' psi')"/>
+ <xsl:value-of select="concat(format-number((substring-before(@end, ' ') * 14.5037738007), '#'), '')"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="@end"/>
+ <xsl:value-of select="substring-before(@end, ' ')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&quot;</xsl:text>