diff options
-rw-r--r-- | xslt/xml2manualcsv.xslt | 67 |
1 files changed, 44 insertions, 23 deletions
diff --git a/xslt/xml2manualcsv.xslt b/xslt/xml2manualcsv.xslt index fcb97b52d..e240d3123 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="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="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> |