summaryrefslogtreecommitdiffstats
path: root/xslt
diff options
context:
space:
mode:
authorGravatar Martin Long <martin@longhome.co.uk>2014-12-13 00:34:35 +0000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-12-12 18:26:44 -0800
commitb1da9b207ff056dc9bdd015a5deebf3be0945776 (patch)
treed5fe36b54d076f2339ec05a9b463c0c8a7deee10 /xslt
parent8e923a5e35a469fd859e14b8c6ca85ec876c3ef6 (diff)
downloadsubsurface-b1da9b207ff056dc9bdd015a5deebf3be0945776.tar.gz
Use generated ids for buddies in UDDF export.
This is instead of using their names, which may contain illegal characters. Signed-off-by: Martin Long <martin@longhome.co.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'xslt')
-rw-r--r--xslt/uddf-export.xslt43
1 files changed, 23 insertions, 20 deletions
diff --git a/xslt/uddf-export.xslt b/xslt/uddf-export.xslt
index 7cdb2b216..51513beb5 100644
--- a/xslt/uddf-export.xslt
+++ b/xslt/uddf-export.xslt
@@ -7,6 +7,17 @@
<xsl:key name="gases" match="cylinder" use="concat(substring-before(@o2, '.'), '/', substring-before(@he, '.'))" />
<xsl:key name="images" match="picture" use="concat(../../dive/@number|../dive/@number, ':', @filename, '@', @offset)" />
+ <!-- This needs to be set at this top level so that it is avialable in both the buddies and profiledata sections-->
+ <xsl:variable name="buddies">
+ <xsl:for-each select="//buddy">
+ <xsl:call-template name="tokenize">
+ <xsl:with-param name="string" select="." />
+ <xsl:with-param name="delim" select="', '" />
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:variable>
+
+
<xsl:template match="/divelog/settings"/>
<xsl:template match="/divelog/dives">
@@ -60,19 +71,11 @@
</xsl:for-each>
</equipment>
</owner>
- <xsl:variable name="buddylist">
- <xsl:for-each select="//buddy">
- <xsl:call-template name="tokenize">
- <xsl:with-param name="string" select="." />
- <xsl:with-param name="delim" select="', '" />
- </xsl:call-template>
- </xsl:for-each>
- </xsl:variable>
- <xsl:for-each select="xt:node-set($buddylist)/token[generate-id() = generate-id(key('tokenkey', .)[1])]">
+ <xsl:for-each select="xt:node-set($buddies)/token[generate-id() = generate-id(key('tokenkey', .)[1])]">
<xsl:sort select="." />
<buddy>
<xsl:attribute name="id">
- <xsl:value-of select="."/>
+ <xsl:value-of select="generate-id(key('tokenkey', .)[1])"/>
</xsl:attribute>
<personal>
<xsl:choose>
@@ -93,7 +96,7 @@
</personal>
</buddy>
</xsl:for-each>
- </diver>
+ </diver>
<divesite>
@@ -235,20 +238,20 @@
<xsl:value-of select="./@number"/>
</divenumber>
<xsl:variable name="buddylist">
- <xsl:for-each select="buddy">
- <xsl:call-template name="tokenize">
- <xsl:with-param name="string" select="." />
- <xsl:with-param name="delim" select="', '" />
- </xsl:call-template>
- </xsl:for-each>
+ <xsl:call-template name="tokenize">
+ <xsl:with-param name="string" select="buddy" />
+ <xsl:with-param name="delim" select="', '" />
+ </xsl:call-template>
</xsl:variable>
- <xsl:for-each select="xt:node-set($buddylist)/token[generate-id() = generate-id(key('tokenkey', .)[1])]">
- <xsl:sort select="." />
+ <xsl:for-each select="xt:node-set($buddylist)/token">
+ <xsl:variable name="buddyname" select="."/>
+ <xsl:for-each select="xt:node-set($buddies)/token[generate-id() = generate-id(key('tokenkey', .)[1]) and $buddyname = .]">
<link>
<xsl:attribute name="ref">
- <xsl:value-of select="."/>
+ <xsl:value-of select="generate-id()"/>
</xsl:attribute>
</link>
+ </xsl:for-each>
</xsl:for-each>
<xsl:if test="location != ''">
<link>