diff options
Diffstat (limited to 'xslt')
-rw-r--r-- | xslt/MacDive.xslt | 49 | ||||
-rw-r--r-- | xslt/csv2xml.xslt | 76 | ||||
-rw-r--r-- | xslt/manualcsv2xml.xslt | 10 | ||||
-rw-r--r-- | xslt/uddf-export.xslt | 130 |
4 files changed, 159 insertions, 106 deletions
diff --git a/xslt/MacDive.xslt b/xslt/MacDive.xslt index 444876721..59b05c3fe 100644 --- a/xslt/MacDive.xslt +++ b/xslt/MacDive.xslt @@ -1,5 +1,6 @@ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:strip-space elements="*"/> + <xsl:include href="commonTemplates.xsl"/> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> @@ -67,7 +68,16 @@ </xsl:attribute> <xsl:attribute name="tags"> - <xsl:value-of select="entryType"/> + <xsl:for-each select="tags/tag|entryType"> + <xsl:choose> + <xsl:when test="position() = 1"> + <xsl:value-of select="."/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat(',', .)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> </xsl:attribute> <xsl:variable name="delta"> @@ -79,10 +89,10 @@ <location debug="true"> <xsl:for-each select="site/country|site/location|site/name"> <xsl:choose> - <xsl:when test="following-sibling::location[1] != ''"> + <xsl:when test="following-sibling::location[1] != '' and . != ''"> <xsl:value-of select="concat(., ' / ')"/> </xsl:when> - <xsl:when test="following-sibling::name[1] != ''"> + <xsl:when test="following-sibling::name[1] != '' and . != ''"> <xsl:value-of select="concat(., ' / ')"/> </xsl:when> <xsl:otherwise> @@ -104,10 +114,10 @@ <location> <xsl:for-each select="country|location|site"> <xsl:choose> - <xsl:when test="following-sibling::location[1] != ''"> + <xsl:when test="following-sibling::location[1] != '' and . != ''"> <xsl:value-of select="concat(., ' / ')"/> </xsl:when> - <xsl:when test="following-sibling::site[1] != ''"> + <xsl:when test="following-sibling::site[1] != '' and . != ''"> <xsl:value-of select="concat(., ' / ')"/> </xsl:when> <xsl:otherwise> @@ -198,6 +208,21 @@ </cylinder> </xsl:for-each> + <xsl:for-each select="gases/gas"> + <event name="gaschange"> + <xsl:attribute name="time"> + <xsl:call-template name="sec2time"> + <xsl:with-param name="timeSec"> + <xsl:value-of select="sum(preceding-sibling::gas/duration)"/> + </xsl:with-param> + </xsl:call-template> + </xsl:attribute> + <xsl:attribute name="value"> + <xsl:value-of select="helium * 65536 + oxygen"/> + </xsl:attribute> + </event> + </xsl:for-each> + <xsl:if test="diveMaster"> <divemaster> <xsl:value-of select="diveMaster"/> @@ -387,7 +412,7 @@ </xsl:if> </sample> - <xsl:if test="alarm != ''"> + <xsl:if test="alarm != '' and alarm != gas_change"> <event> <xsl:attribute name="time"> <xsl:call-template name="timeConvert"> @@ -543,18 +568,6 @@ </xsl:template> <!-- end convert weight --> - <xsl:template name="temperatureSamples"> - <xsl:param name="units"/> - <xsl:choose> - <xsl:when test="$units = 'Imperial'"> - <xsl:value-of select="count(descendant::temperature[. != 32])"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="count(descendant::temperature[. != 0])"/> - </xsl:otherwise> - </xsl:choose> - </xsl:template> - <xsl:template name="pressureSamples"> <xsl:value-of select="count(descendant::pressure[. > 0])"/> </xsl:template> diff --git a/xslt/csv2xml.xslt b/xslt/csv2xml.xslt index dba207052..05f9e23c6 100644 --- a/xslt/csv2xml.xslt +++ b/xslt/csv2xml.xslt @@ -16,6 +16,7 @@ <xsl:param name="time" select="time"/> <xsl:param name="units" select="units"/> <xsl:param name="separatorIndex" select="separatorIndex"/> + <xsl:param name="delta" select="delta"/> <xsl:output method="xml" indent="yes"/> <xsl:variable name="lf"><xsl:text> @@ -41,6 +42,7 @@ <divecomputerid deviceid="ffffffff" model="csv" /> <xsl:call-template name="printLine"> <xsl:with-param name="line" select="substring-before(//csv, $lf)"/> + <xsl:with-param name="lineno" select="'1'"/> <xsl:with-param name="remaining" select="substring-after(//csv, $lf)"/> </xsl:call-template> </dive> @@ -50,33 +52,47 @@ <xsl:template name="printLine"> <xsl:param name="line"/> + <xsl:param name="lineno"/> <xsl:param name="remaining"/> <!-- We only want to process lines with different time stamps, and timeField is not necessarily the first field --> <xsl:if test="$line != substring-before($remaining, $lf)"> - <xsl:variable name="curTime"> - <xsl:call-template name="getFieldByIndex"> - <xsl:with-param name="index" select="$timeField"/> - <xsl:with-param name="line" select="$line"/> - </xsl:call-template> - </xsl:variable> - <xsl:variable name="prevTime"> - <xsl:call-template name="getFieldByIndex"> - <xsl:with-param name="index" select="$timeField"/> - <xsl:with-param name="line" select="substring-before($remaining, $lf)"/> - </xsl:call-template> - </xsl:variable> - - <xsl:if test="$curTime != $prevTime"> - <xsl:call-template name="printFields"> - <xsl:with-param name="line" select="$line"/> - </xsl:call-template> - </xsl:if> + <xsl:choose> + <xsl:when test="$delta != '' and $delta > 0"> + <xsl:variable name="curTime"> + <xsl:call-template name="getFieldByIndex"> + <xsl:with-param name="index" select="$timeField"/> + <xsl:with-param name="line" select="$line"/> + </xsl:call-template> + </xsl:variable> + <xsl:variable name="prevTime"> + <xsl:call-template name="getFieldByIndex"> + <xsl:with-param name="index" select="$timeField"/> + <xsl:with-param name="line" select="substring-before($remaining, $lf)"/> + </xsl:call-template> + </xsl:variable> + + <xsl:if test="$curTime != $prevTime"> + <xsl:call-template name="printFields"> + <xsl:with-param name="line" select="$line"/> + <xsl:with-param name="lineno" select="$lineno"/> + </xsl:call-template> + </xsl:if> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="printFields"> + <xsl:with-param name="line" select="$line"/> + <xsl:with-param name="lineno" select="'0'"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:if> <xsl:if test="$remaining != ''"> <xsl:call-template name="printLine"> <xsl:with-param name="line" select="substring-before($remaining, $lf)"/> + <xsl:with-param name="lineno" select="$lineno + 1"/> <xsl:with-param name="remaining" select="substring-after($remaining, $lf)"/> </xsl:call-template> </xsl:if> @@ -84,18 +100,34 @@ <xsl:template name="printFields"> <xsl:param name="line"/> + <xsl:param name="lineno"/> <xsl:variable name="value"> - <xsl:call-template name="getFieldByIndex"> - <xsl:with-param name="index" select="$timeField"/> - <xsl:with-param name="line" select="$line"/> - </xsl:call-template> + <xsl:choose> + <xsl:when test="$delta != '' and $delta > 0"> + <xsl:value-of select="'1'"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="getFieldByIndex"> + <xsl:with-param name="index" select="$timeField"/> + <xsl:with-param name="line" select="$line"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> </xsl:variable> + <xsl:if test="number($value) = $value or number(substring-before($value, ':')) = substring-before($value, ':')"> <sample> <xsl:attribute name="time"> <xsl:choose> + <xsl:when test="$delta != '' and $delta > 0"> + <xsl:call-template name="sec2time"> + <xsl:with-param name="timeSec"> + <xsl:value-of select="$lineno * 1"/> + </xsl:with-param> + </xsl:call-template> + </xsl:when> <xsl:when test="number($value) = $value"> <!-- We assume time in seconds --> diff --git a/xslt/manualcsv2xml.xslt b/xslt/manualcsv2xml.xslt index 15eb8f00d..83c543581 100644 --- a/xslt/manualcsv2xml.xslt +++ b/xslt/manualcsv2xml.xslt @@ -17,6 +17,7 @@ <xsl:param name="meanDepthField" select="meanDepthField"/> <xsl:param name="divemasterField" select="divemasterField"/> <xsl:param name="buddyField" select="buddyField"/> + <xsl:param name="suitField" select="suitField"/> <xsl:param name="notesField" select="notesField"/> <xsl:param name="weightField" select="weightField"/> <xsl:param name="dateformat" select="dateformat"/> @@ -343,6 +344,15 @@ </buddy> </xsl:if> + <xsl:if test="$suitField >= 0"> + <suit> + <xsl:call-template name="getFieldByIndex"> + <xsl:with-param name="index" select="$suitField"/> + <xsl:with-param name="line" select="$line"/> + </xsl:call-template> + </suit> + </xsl:if> + <xsl:if test="$notesField >= 0"> <notes> <xsl:call-template name="getFieldByIndex"> diff --git a/xslt/uddf-export.xslt b/xslt/uddf-export.xslt index d1d46a9b9..4365702dc 100644 --- a/xslt/uddf-export.xslt +++ b/xslt/uddf-export.xslt @@ -279,11 +279,75 @@ <xsl:value-of select="format-number(substring-before(., ' ') + 273.15, '0.00')"/> </airtemperature> </xsl:for-each> + <xsl:variable name="trimmedweightlist"> + <xsl:for-each select="weightsystem"> + <weight> + <xsl:value-of select="substring-before(@weight, ' ')"/> + </weight> + </xsl:for-each> + </xsl:variable> + <xsl:if test="sum(xt:node-set($trimmedweightlist)/node()) >= 0"> + <equipmentused> + <leadquantity> + <xsl:value-of select="sum(xt:node-set($trimmedweightlist)/node())"/> + </leadquantity> + </equipmentused> + </xsl:if> <xsl:if test="parent::trip"> <tripmembership ref="trip{generate-id(..)}"/> </xsl:if> </informationbeforedive> + <xsl:for-each select="cylinder"> + <tankdata> + <link> + <xsl:attribute name="ref"> + <xsl:choose> + <xsl:when test="@o2 != ''"> + <xsl:value-of select="concat('mix', substring-before(@o2, '.'))"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="'mix21'"/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + </link> + + <xsl:if test="@size"> + + <tankvolume> + <xsl:value-of select="substring-before(@size, ' ')"/> + </tankvolume> + </xsl:if> + <xsl:choose> + <xsl:when test="@start"> + <tankpressurebegin> + <xsl:value-of select="substring-before(@start, ' ') * 100000"/> + </tankpressurebegin> + </xsl:when> + <xsl:otherwise> + <tankpressurebegin> + <xsl:value-of select="substring-before(divecomputer[1]/sample[@pressure]/@pressure[1], ' ') * 100000"/> + </tankpressurebegin> + </xsl:otherwise> + </xsl:choose> + + <xsl:choose> + <xsl:when test="@end"> + <tankpressureend> + <xsl:value-of select="substring-before(@end, ' ') * 100000"/> + </tankpressureend> + </xsl:when> + <xsl:otherwise> + <tankpressureend> + <xsl:value-of select="substring-before(divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') * 100000"/> + </tankpressureend> + </xsl:otherwise> + </xsl:choose> + + </tankdata> + </xsl:for-each> + <samples> <xsl:for-each select="divecomputer[1]/event | divecomputer[1]/sample"> @@ -483,65 +547,7 @@ </xsl:for-each> </samples> - <xsl:for-each select="cylinder"> - <tankdata> - <link> - <xsl:attribute name="ref"> - <xsl:choose> - <xsl:when test="@o2 != ''"> - <xsl:value-of select="concat('mix', substring-before(@o2, '.'))"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="'mix21'"/> - </xsl:otherwise> - </xsl:choose> - </xsl:attribute> - </link> - - <xsl:if test="@size"> - - <tankvolume> - <xsl:value-of select="substring-before(@size, ' ')"/> - </tankvolume> - </xsl:if> - <xsl:choose> - <xsl:when test="@start"> - <tankpressurebegin> - <xsl:value-of select="substring-before(@start, ' ') * 100000"/> - </tankpressurebegin> - </xsl:when> - <xsl:otherwise> - <tankpressurebegin> - <xsl:value-of select="substring-before(divecomputer[1]/sample[@pressure]/@pressure[1], ' ') * 100000"/> - </tankpressurebegin> - </xsl:otherwise> - </xsl:choose> - - <xsl:choose> - <xsl:when test="@end"> - <tankpressureend> - <xsl:value-of select="substring-before(@end, ' ') * 100000"/> - </tankpressureend> - </xsl:when> - <xsl:otherwise> - <tankpressureend> - <xsl:value-of select="substring-before(divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') * 100000"/> - </tankpressureend> - </xsl:otherwise> - </xsl:choose> - - </tankdata> - </xsl:for-each> - <informationafterdive> - <xsl:variable name="trimmedweightlist"> - <xsl:for-each select="weightsystem"> - <weight> - <xsl:value-of select="substring-before(@weight, ' ')"/> - </weight> - </xsl:for-each> - </xsl:variable> - <xsl:if test="node()/depth/@max != ''"> <greatestdepth> <xsl:value-of select="substring-before(node()/depth/@max, ' ')"/> @@ -605,14 +611,6 @@ </xsl:when> </xsl:choose> </visibility> - <equipmentused> - <leadquantity> - <xsl:if test="sum(xt:node-set($trimmedweightlist)/node()) >= 0"> - <xsl:value-of select="sum(xt:node-set($trimmedweightlist)/node())"/> - </xsl:if> - </leadquantity> - </equipmentused> - </informationafterdive> </dive> |