mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Desktop: Rework the Summary CSV Export XSLT.
Rework of the XSLT used to generate the Summary CSV export: - fixed a bug causing invalid CSV to be generated for double quotes (`""`); - changed quoting and escaping to be compliant with RFC 4180; - changed output to contain information for all cylinders for all dives (instead of limiting the number of cylinders to howevermany are used for the last dive); - added an index to the cylinder data headings; - changed unit designators to use `[]` instead of `()`; - some minor improvements to the XSLT. Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
parent
a127c4ac63
commit
4c193d7bdf
2 changed files with 429 additions and 448 deletions
|
@ -1,3 +1,4 @@
|
|||
export: fix bug resulting in invalid CSV for '""' in 'CSV summary dive details'
|
||||
desktop: add support for multiple tanks to the profile ruler
|
||||
export: change format produced by 'CSV summary dive details' from TSV (tab separated) to CSV
|
||||
desktop: add function to merge dive site into site selected in list
|
||||
|
|
|
@ -6,169 +6,118 @@
|
|||
<xsl:param name="units" select="units"/>
|
||||
<xsl:output method="text" encoding="UTF-8"/>
|
||||
|
||||
<xsl:variable name="fs"><xsl:text>,</xsl:text></xsl:variable>
|
||||
<xsl:variable name="lf"><xsl:text>
|
||||
</xsl:text></xsl:variable>
|
||||
<xsl:variable name="fs" select="','"/>
|
||||
<xsl:variable name="quote" select="'"'"/>
|
||||
<xsl:variable name="lf" select="'
'"/>
|
||||
|
||||
<xsl:template match="/divelog/dives">
|
||||
<xsl:variable name="cylinders">
|
||||
<xsl:value-of select="count(dive[position()=last()]/cylinder|trip[position()=last()]/dive[position()=last()]/cylinder)"/>
|
||||
</xsl:variable>
|
||||
<xsl:template name="EscapeQuotes">
|
||||
<xsl:param name="value"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 1">
|
||||
|
||||
<!-- Print beginning of the header -->
|
||||
<xsl:value-of select="concat(
|
||||
'"dive number"',
|
||||
$fs,
|
||||
'"date"',
|
||||
$fs,
|
||||
'"time"',
|
||||
$fs,
|
||||
'"duration (min)"',
|
||||
$fs,
|
||||
'"sac (cuft/min)"',
|
||||
$fs,
|
||||
'"maxdepth (ft)"',
|
||||
$fs,
|
||||
'"avgdepth (ft)"',
|
||||
$fs,
|
||||
'"mode"',
|
||||
$fs,
|
||||
'"airtemp (F)"',
|
||||
$fs,
|
||||
'"watertemp (F)"',
|
||||
$fs)"/>
|
||||
|
||||
<!-- Print cylinder info according to the amount of cylinders in dive -->
|
||||
<xsl:for-each select="dive[position()=last()]/cylinder|trip[position()=last()]/dive[position()=last()]/cylinder">
|
||||
<xsl:value-of select="concat(
|
||||
'"cylinder size (cuft)"',
|
||||
$fs,
|
||||
'"startpressure (psi)"',
|
||||
$fs,
|
||||
'"endpressure (psi)"',
|
||||
$fs,
|
||||
'"o2 (%)"',
|
||||
$fs,
|
||||
'"he (%)"',
|
||||
$fs)"/>
|
||||
</xsl:for-each>
|
||||
|
||||
<!-- Print rest of the header -->
|
||||
<xsl:value-of select="concat(
|
||||
'"location"',
|
||||
$fs,
|
||||
'"gps"',
|
||||
$fs,
|
||||
'"divemaster"',
|
||||
$fs,
|
||||
'"buddy"',
|
||||
$fs,
|
||||
'"suit"',
|
||||
$fs,
|
||||
'"rating"',
|
||||
$fs,
|
||||
'"visibility"',
|
||||
$fs,
|
||||
'"notes"',
|
||||
$fs,
|
||||
'"weight (lbs)"',
|
||||
$fs,
|
||||
'"tags"')"/>
|
||||
<xsl:when test="contains($value, $quote)">
|
||||
<xsl:value-of select="concat(substring-before($value, $quote), $quote, $quote)"/>
|
||||
<xsl:call-template name="EscapeQuotes">
|
||||
<xsl:with-param name="value" select="substring-after($value, $quote)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
|
||||
<!-- Print beginning of the header -->
|
||||
<xsl:value-of select="concat(
|
||||
'"dive number"',
|
||||
$fs,
|
||||
'"date"',
|
||||
$fs,
|
||||
'"time"',
|
||||
$fs,
|
||||
'"duration (min)"',
|
||||
$fs,
|
||||
'"sac (l/min)"',
|
||||
$fs,
|
||||
'"maxdepth (m)"',
|
||||
$fs,
|
||||
'"avgdepth (m)"',
|
||||
$fs,
|
||||
'"mode"',
|
||||
$fs,
|
||||
'"airtemp (C)"',
|
||||
$fs,
|
||||
'"watertemp (C)"',
|
||||
$fs)"/>
|
||||
|
||||
<!-- Print cylinder info according to the amount of cylinders in dive -->
|
||||
<xsl:for-each select="dive[position()=last()]/cylinder|trip[position()=last()]/dive[position()=last()]/cylinder">
|
||||
<xsl:value-of select="concat(
|
||||
'"cylinder size (l)"',
|
||||
$fs,
|
||||
'"startpressure (bar)"',
|
||||
$fs,
|
||||
'"endpressure (bar)"',
|
||||
$fs,
|
||||
'"o2 (%)"',
|
||||
$fs,
|
||||
'"he (%)"',
|
||||
$fs)"/>
|
||||
</xsl:for-each>
|
||||
|
||||
<!-- Print rest of the header -->
|
||||
<xsl:value-of select="concat(
|
||||
'"location"',
|
||||
$fs,
|
||||
'"gps"',
|
||||
$fs,
|
||||
'"divemaster"',
|
||||
$fs,
|
||||
'"buddy"',
|
||||
$fs,
|
||||
'"suit"',
|
||||
$fs,
|
||||
'"rating"',
|
||||
$fs,
|
||||
'"visibility"',
|
||||
$fs,
|
||||
'"notes"',
|
||||
$fs,
|
||||
'"weight (kg)"',
|
||||
$fs,
|
||||
'"tags"')"/>
|
||||
<xsl:value-of select="$value"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>
|
||||
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="CsvEscape">
|
||||
<xsl:param name="value"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($value, $fs)">
|
||||
<xsl:value-of select="$quote"/>
|
||||
<xsl:call-template name="EscapeQuotes">
|
||||
<xsl:with-param name="value" select="$value"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$quote"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains($value, $lf)">
|
||||
<xsl:value-of select="$quote"/>
|
||||
<xsl:call-template name="EscapeQuotes">
|
||||
<xsl:with-param name="value" select="$value"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$quote"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains($value, $quote)">
|
||||
<xsl:value-of select="$quote"/>
|
||||
<xsl:call-template name="EscapeQuotes">
|
||||
<xsl:with-param name="value" select="$value"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$quote"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$value"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="/divelog/dives">
|
||||
<!-- Find the maximum number of cylinders used on a dive -->
|
||||
<xsl:variable name="cylinders">
|
||||
<xsl:for-each select="dive|trip/dive">
|
||||
<xsl:sort select="count(cylinder)" data-type="number" order="descending"/>
|
||||
<xsl:if test="position() = 1">
|
||||
<xsl:value-of select="count(cylinder)"/>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 1">
|
||||
<xsl:call-template name="printHeaders">
|
||||
<xsl:with-param name="cylinders" select="$cylinders"/>
|
||||
<xsl:with-param name="volumeUnits" select="'cuft'"/>
|
||||
<xsl:with-param name="distanceUnits" select="'ft'"/>
|
||||
<xsl:with-param name="temperatureUnits" select="'F'"/>
|
||||
<xsl:with-param name="pressureUnits" select="'psi'"/>
|
||||
<xsl:with-param name="massUnits" select="'lbs'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="printHeaders">
|
||||
<xsl:with-param name="cylinders" select="$cylinders"/>
|
||||
<xsl:with-param name="volumeUnits" select="'l'"/>
|
||||
<xsl:with-param name="distanceUnits" select="'m'"/>
|
||||
<xsl:with-param name="temperatureUnits" select="'C'"/>
|
||||
<xsl:with-param name="pressureUnits" select="'bar'"/>
|
||||
<xsl:with-param name="massUnits" select="'kg'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:apply-templates select="dive|trip/dive">
|
||||
<xsl:with-param name="cylinders" select="$cylinders"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Suppress printing of divesite notes -->
|
||||
<xsl:template match="divesites/site/notes"/>
|
||||
|
||||
<xsl:template match="dive">
|
||||
<xsl:param name="cylinders"/>
|
||||
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="@number"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="@number"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="@date"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="@date"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="@time"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="@time"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="substring-before(@duration, ' ')"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="substring-before(@duration, ' ')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 1">
|
||||
<xsl:value-of select="format-number(substring-before(@sac, ' ') * 0.035315, '#.##')"/>
|
||||
|
@ -177,26 +126,26 @@
|
|||
<xsl:value-of select="substring-before(@sac, ' ')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="divecomputer[1]/depth/@mean|divecomputer[1]/depth/@max != ''">
|
||||
<xsl:apply-templates select="divecomputer[1]/depth"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>""</xsl:text>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>""</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="$fs"/>
|
||||
|
||||
<!-- Dive mode -->
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:if test="divecomputer[1]/@dctype != ''">
|
||||
<xsl:value-of select="divecomputer[1]/@dctype"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="divecomputer[1]/@dctype"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="$fs"/>
|
||||
|
||||
<!-- Air temperature -->
|
||||
<xsl:choose>
|
||||
|
@ -210,12 +159,8 @@
|
|||
<xsl:with-param name="temp" select="divecomputer[1]/temperature/@air"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- empty air temperature -->
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>""</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="$fs"/>
|
||||
|
||||
<!-- Water temperature -->
|
||||
<xsl:choose>
|
||||
|
@ -229,24 +174,14 @@
|
|||
<xsl:with-param name="temp" select="divecomputer[1]/temperature/@water"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- water temperature -->
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>""</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="$fs"/>
|
||||
|
||||
<xsl:for-each select="cylinder">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$cylinders < position()"/>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@start|@end != ''">
|
||||
<xsl:apply-templates select="."/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:when test="position() <= $cylinders">
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 1">
|
||||
<xsl:value-of select="concat(format-number((substring-before(@size, ' ') div 14.7 * 3000) * 0.035315, '#.#'), '')"/>
|
||||
|
@ -255,9 +190,23 @@
|
|||
<xsl:value-of select="substring-before(@size, ' ')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@start|@end != ''">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 1">
|
||||
<xsl:value-of select="concat(format-number((substring-before(@start, ' ') * 14.5037738007), '#'), '')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before(@start, ' ')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 1">
|
||||
<xsl:choose>
|
||||
|
@ -273,9 +222,25 @@
|
|||
<xsl:value-of select="substring-before(../divecomputer[1]/sample[@pressure]/@pressure, ' ')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@start|@end != ''">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 1">
|
||||
<xsl:value-of select="concat(format-number((substring-before(@end, ' ') * 14.5037738007), '#'), '')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before(@end, ' ')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 1">
|
||||
<xsl:choose>
|
||||
|
@ -291,23 +256,25 @@
|
|||
<xsl:value-of select="substring-before(../divecomputer[1]/sample[@pressure][last()]/@pressure, ' ')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="substring-before(@o2, '%')"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="substring-before(@he, '%')"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="substring-before(@o2, '%')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="substring-before(@he, '%')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:if test="count(cylinder) < $cylinders">
|
||||
<xsl:call-template name="emptyCylinder">
|
||||
<xsl:call-template name="printEmptyCylinders">
|
||||
<xsl:with-param name="count" select="$cylinders - count(cylinder)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
|
@ -318,61 +285,58 @@
|
|||
<xsl:apply-templates select="location"/>
|
||||
<xsl:if test="string-length(location) = 0">
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>""</xsl:text>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>""</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<!-- Format with dive site managemenet -->
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value">
|
||||
<xsl:if test="string-length(@divesiteid) > 0">
|
||||
<xsl:variable name="uuid">
|
||||
<xsl:value-of select="@divesiteid" />
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="//divesites/site[@uuid = $uuid]/@name"/>
|
||||
</xsl:if>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value">
|
||||
<xsl:if test="string-length(@divesiteid) > 0">
|
||||
<xsl:variable name="uuid">
|
||||
<xsl:value-of select="@divesiteid" />
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="//divesites/site[@uuid = $uuid]/@gps"/>
|
||||
</xsl:if>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:apply-templates select="divemaster"/>
|
||||
<xsl:if test="string-length(divemaster) = 0">
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>""</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="buddy"/>
|
||||
<xsl:if test="string-length(buddy) = 0">
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="divemaster"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>""</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="suit"/>
|
||||
<xsl:if test="string-length(suit) = 0">
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="buddy"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>""</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="suit"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="@rating"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="@rating"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="@visibility"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:apply-templates select="notes"/>
|
||||
<xsl:if test="string-length(notes) = 0">
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="@visibility"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="notes"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>""</xsl:text>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:variable name="trimmedweightlist">
|
||||
<xsl:for-each select="weightsystem">
|
||||
|
@ -381,9 +345,9 @@
|
|||
</weight>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:if test="weightsystem">
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 1">
|
||||
<xsl:value-of select="concat(format-number((sum(xt:node-set($trimmedweightlist)/node()) div 0.453592), '#.##'), '')"/>
|
||||
|
@ -392,24 +356,160 @@
|
|||
<xsl:value-of select="concat(sum(xt:node-set($trimmedweightlist)/node()), '')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
<xsl:text>"</xsl:text>
|
||||
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="quote">
|
||||
<xsl:with-param name="line" select="substring-before(translate(@tags, $lf, ' '), '"')"/>
|
||||
<xsl:with-param name="remaining" select="substring-after(translate(@tags, $lf, ' '), '"')"/>
|
||||
<xsl:with-param name="all" select="@tags"/>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:text>"</xsl:text>
|
||||
|
||||
<xsl:text>
|
||||
</xsl:text>
|
||||
</xsl:template>
|
||||
<xsl:template match="divecomputer/depth">
|
||||
</xsl:if>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="@tags"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$lf"/>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Print the header -->
|
||||
<xsl:template name="printHeaders">
|
||||
<xsl:param name="cylinders"/>
|
||||
<xsl:param name="volumeUnits"/>
|
||||
<xsl:param name="distanceUnits"/>
|
||||
<xsl:param name="temperatureUnits"/>
|
||||
<xsl:param name="pressureUnits"/>
|
||||
<xsl:param name="massUnits"/>
|
||||
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="'dive number'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="'date'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="'time'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="'duration [min]'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="concat('sac [', $volumeUnits, '/min]')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="concat('maxdepth [', $distanceUnits, ']')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="concat('avgdepth [', $distanceUnits, ']')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="'mode'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="concat('airtemp [', $temperatureUnits, ']')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="concat('watertemp [', $temperatureUnits, ']')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
|
||||
<!-- Print cylinder info according to the amount of cylinders in dive -->
|
||||
<xsl:call-template name="printCylinderHeaders">
|
||||
<xsl:with-param name="index" select="1"/>
|
||||
<xsl:with-param name="count" select="$cylinders"/>
|
||||
<xsl:with-param name="volumeUnits" select="$volumeUnits"/>
|
||||
<xsl:with-param name="pressureUnits" select="$pressureUnits"/>
|
||||
</xsl:call-template>
|
||||
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="'location'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="'gps'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="'divemaster'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="'buddy'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="'suit'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="'rating'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="'visibility'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="'notes'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="concat('weight [', $massUnits, ']')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="'tags'"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:value-of select="$lf"/>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Print the header for cylinders -->
|
||||
<xsl:template name="printCylinderHeaders">
|
||||
<xsl:param name="index"/>
|
||||
<xsl:param name="count"/>
|
||||
<xsl:param name="volumeUnits"/>
|
||||
<xsl:param name="pressureUnits"/>
|
||||
|
||||
<xsl:if test="$index <= $count">
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="concat('cylinder size (', $index, ') [', $volumeUnits, ']')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="concat('startpressure (', $index, ') [', $pressureUnits, ']')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="concat('endpressure (', $index, ') [', $pressureUnits, ']')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="concat('o2 (', $index, ') [%]')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="concat('he (', $index, ') [%]')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
|
||||
<xsl:call-template name="printCylinderHeaders">
|
||||
<xsl:with-param name="index" select="$index + 1"/>
|
||||
<xsl:with-param name="count" select="$count"/>
|
||||
<xsl:with-param name="volumeUnits" select="$volumeUnits"/>
|
||||
<xsl:with-param name="pressureUnits" select="$pressureUnits"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Depth template -->
|
||||
<xsl:template match="divecomputer/depth">
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 1">
|
||||
<xsl:value-of select="concat(format-number((substring-before(@max, ' ') div 0.3048), '#.##'), '')"/>
|
||||
|
@ -418,9 +518,11 @@
|
|||
<xsl:value-of select="substring-before(@max, ' ')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 1">
|
||||
<xsl:value-of select="concat(format-number((substring-before(@mean, ' ') div 0.3048), '#.##'), '')"/>
|
||||
|
@ -429,15 +531,16 @@
|
|||
<xsl:value-of select="format-number(substring-before(@mean, ' '), '#.##')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Temperature template -->
|
||||
<xsl:template name="temperature">
|
||||
<xsl:param name="temp"/>
|
||||
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 1">
|
||||
<xsl:if test="substring-before($temp, ' ') > 0">
|
||||
|
@ -448,157 +551,34 @@
|
|||
<xsl:value-of select="substring-before($temp, ' ')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="cylinder">
|
||||
<xsl:value-of select="$fs"/>
|
||||
<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, '#.#'), '')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before(@size, ' ')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 1">
|
||||
<xsl:value-of select="concat(format-number((substring-before(@start, ' ') * 14.5037738007), '#'), '')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before(@start, ' ')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$units = 1">
|
||||
<xsl:value-of select="concat(format-number((substring-before(@end, ' ') * 14.5037738007), '#'), '')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before(@end, ' ')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="substring-before(@o2, '%')"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="substring-before(@he, '%')"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="location">
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="@gps"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:template>
|
||||
<xsl:template match="divemaster">
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="quote">
|
||||
<xsl:with-param name="line" select="substring-before(translate(., $lf, ' '), '"')"/>
|
||||
<xsl:with-param name="remaining" select="substring-after(translate(., $lf, ' '), '"')"/>
|
||||
<xsl:with-param name="all" select="."/>
|
||||
</xsl:call-template>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:template>
|
||||
<xsl:template match="buddy">
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="quote">
|
||||
<xsl:with-param name="line" select="substring-before(translate(., $lf, ' '), '"')"/>
|
||||
<xsl:with-param name="remaining" select="substring-after(translate(., $lf, ' '), '"')"/>
|
||||
<xsl:with-param name="all" select="."/>
|
||||
</xsl:call-template>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:template>
|
||||
<xsl:template match="suit">
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="quote">
|
||||
<xsl:with-param name="line" select="substring-before(translate(., $lf, ' '), '"')"/>
|
||||
<xsl:with-param name="remaining" select="substring-after(translate(., $lf, ' '), '"')"/>
|
||||
<xsl:with-param name="all" select="."/>
|
||||
</xsl:call-template>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:template>
|
||||
<xsl:template match="notes">
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="quote">
|
||||
<xsl:with-param name="line" select="substring-before(translate(., $lf, '\n'), '"')"/>
|
||||
<xsl:with-param name="remaining" select="substring-after(translate(., $lf, '\n'), '"')"/>
|
||||
<xsl:with-param name="all" select="translate(., $lf, '\n')"/>
|
||||
</xsl:call-template>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="quote">
|
||||
<xsl:param name="line"/>
|
||||
<xsl:param name="remaining"/>
|
||||
<xsl:param name="all"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$line = ''">
|
||||
<xsl:value-of select="$all"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat($line, '"', '"')"/>
|
||||
<xsl:if test="$remaining != ''">
|
||||
<xsl:choose>
|
||||
<xsl:when test="substring-before($remaining, '"') != ''">
|
||||
<xsl:call-template name="quote">
|
||||
<xsl:with-param name="line" select="substring-before($remaining, '"')"/>
|
||||
<xsl:with-param name="remaining" select="substring-after($remaining, '"')"/>
|
||||
<xsl:with-param name="all" select="$remaining"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$remaining" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Template to fill in non-existent cylinder info to CSV -->
|
||||
<xsl:template name="emptyCylinder">
|
||||
<!-- Fill in non-existent cylinder info -->
|
||||
<xsl:template name="printEmptyCylinders">
|
||||
<xsl:param name="count"/>
|
||||
|
||||
<xsl:if test="$count > 0">
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:call-template name="emptyCylinder">
|
||||
<xsl:call-template name="printEmptyCylinders">
|
||||
<xsl:with-param name="count" select="$count - 1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Location template -->
|
||||
<xsl:template match="location">
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="."/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fs"/>
|
||||
<xsl:call-template name="CsvEscape">
|
||||
<xsl:with-param name="value" select="@gps"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
|
|
Loading…
Reference in a new issue