diff options
Diffstat (limited to 'xslt')
-rw-r--r-- | xslt/subsurfacecsv.xslt | 23 | ||||
-rw-r--r-- | xslt/xml2csv.xslt | 15 | ||||
-rw-r--r-- | xslt/xml2manualcsv.xslt | 67 |
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('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"sample time"', $fs, '"sample depth"', $fs, '"sample temperature"', $fs, '"sample pressure"')"/> + <xsl:choose> + <xsl:when test="$units = 1"> + <xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"sample time"', $fs, '"sample depth (ft)"', $fs, '"sample temperature (F)"', $fs, '"sample pressure (psi)"')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"sample time"', $fs, '"sample depth (m)"', $fs, '"sample temperature (C)"', $fs, '"sample pressure (bar)"')"/> + </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('"', round((substring-before(@depth, ' ') div 0.3048) * 1000) div 1000, ' ft"')"/> + <xsl:value-of select="concat('"', round((substring-before(@depth, ' ') div 0.3048) * 1000) div 1000, '"')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat('"', round(substring-before(@depth, ' ') * 1000) div 1000, '"')"/> @@ -45,7 +52,7 @@ <xsl:if test="@temp != ''"> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat('"', format-number((substring-before(@temp, ' ') * 1.8) + 32, '#.#'), ' F"')"/> + <xsl:value-of select="concat('"', format-number((substring-before(@temp, ' ') * 1.8) + 32, '#.#'), '"')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat('"', substring-before(@temp, ' '), '"')"/> @@ -57,7 +64,7 @@ <xsl:if test="@pressure != ''"> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat('"', format-number((substring-before(@pressure, ' ') * 14.5037738007), '#'), ' psi"')"/> + <xsl:value-of select="concat('"', format-number((substring-before(@pressure, ' ') * 14.5037738007), '#'), '"')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat('"', substring-before(@pressure, ' '), '"')"/> 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('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"duration"', $fs, '"maxdepth"', $fs, '"avgdepth"', $fs, '"airtemp"', $fs, '"watertemp"', $fs, '"cylinder size"', $fs, '"startpressure"', $fs, '"endpressure"', $fs, '"o2"', $fs, '"he"', $fs, '"location"', $fs, '"gps"', $fs, '"divemaster"', $fs, '"buddy"', $fs, '"suit"', $fs, '"rating"', $fs, '"visibility"', $fs, '"notes"', $fs, '"weight"', $fs, '"tags"')"/> + <xsl:choose> + <xsl:when test="$units = 1"> + <xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"duration"', $fs, '"maxdepth (ft)"', $fs, '"avgdepth (ft)"', $fs, '"airtemp (F)"', $fs, '"watertemp (F)"', $fs, '"cylinder size (cuft)"', $fs, '"startpressure (psi)"', $fs, '"endpressure (psi)"', $fs, '"o2"', $fs, '"he"', $fs, '"location"', $fs, '"gps"', $fs, '"divemaster"', $fs, '"buddy"', $fs, '"suit"', $fs, '"rating"', $fs, '"visibility"', $fs, '"notes"', $fs, '"weight (lbs)"', $fs, '"tags"')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"duration"', $fs, '"maxdepth (m)"', $fs, '"avgdepth (m)"', $fs, '"airtemp (C)"', $fs, '"watertemp (C)"', $fs, '"cylinder size (l)"', $fs, '"startpressure (bar)"', $fs, '"endpressure (bar)"', $fs, '"o2"', $fs, '"he"', $fs, '"location"', $fs, '"gps"', $fs, '"divemaster"', $fs, '"buddy"', $fs, '"suit"', $fs, '"rating"', $fs, '"visibility"', $fs, '"notes"', $fs, '"weight (kg)"', $fs, '"tags"')"/> + </xsl:otherwise> + </xsl:choose> <xsl:text> </xsl:text> <xsl:apply-templates select="dive|trip/dive"/> @@ -71,10 +78,10 @@ <xsl:text>"</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>"</xsl:text> @@ -82,10 +89,17 @@ <xsl:text>"</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, ' ') > 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>"</xsl:text> @@ -93,10 +107,17 @@ <xsl:text>"</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, ' ') > 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>"</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>"</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>"</xsl:text> @@ -217,10 +238,10 @@ <xsl:text>"</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>"</xsl:text> @@ -231,11 +252,11 @@ <xsl:choose> <xsl:when test="$units = 1"> <xsl:if test="substring-before(@air, ' ') > 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>"</xsl:text> @@ -244,11 +265,11 @@ <xsl:choose> <xsl:when test="$units = 1"> <xsl:if test="substring-before(@water, ' ') > 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>"</xsl:text> @@ -258,10 +279,10 @@ <xsl:text>"</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>"</xsl:text> @@ -269,10 +290,10 @@ <xsl:text>"</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>"</xsl:text> @@ -280,10 +301,10 @@ <xsl:text>"</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>"</xsl:text> |