diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2015-10-24 08:18:48 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-10-24 20:17:21 +0900 |
commit | bf2df951e67758eece18499e8edf86cb779692b5 (patch) | |
tree | 7c85d888f5eb4eaa679f5c7ed595cf0bfdaf10e0 /xslt/divelogs-export.xslt | |
parent | 997123c0a43311a05f5a85b1738b148b636af2c8 (diff) | |
download | subsurface-bf2df951e67758eece18499e8edf86cb779692b5.tar.gz |
Divelogs.de export: split location on slash
As we join LOCATION with SITE on divelogs.de import using slash (/) as a
separator, we might as well split on last slash on export.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'xslt/divelogs-export.xslt')
-rw-r--r-- | xslt/divelogs-export.xslt | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/xslt/divelogs-export.xslt b/xslt/divelogs-export.xslt index abfcc8980..b23ee4806 100644 --- a/xslt/divelogs-export.xslt +++ b/xslt/divelogs-export.xslt @@ -34,12 +34,34 @@ <DIVETIMESEC> <xsl:value-of select="$duration"/> </DIVETIMESEC> - <xsl:variable name="uuid"> - <xsl:value-of select="@divesiteid"/> - </xsl:variable> - <LOCATION> + + <xsl:variable name="uuid"> + <xsl:value-of select="@divesiteid"/> + </xsl:variable> + <xsl:variable name="location"> <xsl:value-of select="//site[@uuid = $uuid]/@name"/> - </LOCATION> + </xsl:variable> + <xsl:choose> + <xsl:when test="contains($location, '/')"> + <xsl:variable name="site"> + <xsl:call-template name="basename"> + <xsl:with-param name="value" select="$location"/> + </xsl:call-template> + </xsl:variable> + <SITE> + <xsl:value-of select="$site"/> + </SITE> + <LOCATION> + <xsl:value-of select="substring($location, 0, string-length($location) - string-length($site))"/> + </LOCATION> + </xsl:when> + <xsl:otherwise> + <SITE> + <xsl:value-of select="$location"/> + </SITE> + </xsl:otherwise> + </xsl:choose> + <WATERVIZIBILITY> <xsl:value-of select="@visibility"/> </WATERVIZIBILITY> @@ -412,4 +434,19 @@ </xsl:template> + <xsl:template name="basename"> + <xsl:param name="value" /> + + <xsl:choose> + <xsl:when test="contains($value, '/')"> + <xsl:call-template name="basename"> + <xsl:with-param name="value" select="substring-after($value, '/')" /> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$value" /> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + </xsl:stylesheet> |