From 9c2120be5c16c159722b64b6de0826bab7e258a2 Mon Sep 17 00:00:00 2001
From: Martin Goik <goik@hdm-stuttgart.de>
Date: Thu, 9 Nov 2017 23:59:07 +0100
Subject: [PATCH] Eliminate duplicate code

---
 .../CustomLayer/webhelp/hdmextensions.xsl     | 31 +++++++++----------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/ws/Docbook/CustomLayer/webhelp/hdmextensions.xsl b/ws/Docbook/CustomLayer/webhelp/hdmextensions.xsl
index 603ec4fd8..22c7840e7 100644
--- a/ws/Docbook/CustomLayer/webhelp/hdmextensions.xsl
+++ b/ws/Docbook/CustomLayer/webhelp/hdmextensions.xsl
@@ -91,19 +91,10 @@
       <xsl:call-template name="process.qandaset"/>
     </div>
     
-    <xsl:variable name="qandaId" select="@xml:id"/>
-    <xsl:variable name="tid" select="$topicLookup/map/entry[@id = $qandaId]/@tid"/>
-    <div class="bbForum" data-tid="{$tid}">
-      <p>
-        <a target="_blank">
-          <xsl:attribute name="href">
-            <xsl:text>https://bb.mi.hdm-stuttgart.de/topic/</xsl:text>
-            <xsl:value-of select="$tid"/>
-          </xsl:attribute>
-          <xsl:text>Create comment</xsl:text>
-        </a>
-      </p>
-    </div>
+    <xsl:call-template name="bbComent">
+      <xsl:with-param name="elementId" select="@xml:id"/>
+    </xsl:call-template>
+    
   </xsl:template>
   
   <xsl:template match="d:figure">
@@ -126,9 +117,16 @@
       <xsl:with-param name="placement" select="$placement"/>
     </xsl:call-template>
 
-    <xsl:variable name="figureId" select="@xml:id"/>
-    <xsl:variable name="tid" select="$topicLookup/map/entry[@id = $figureId]/@tid"/>
-    <div class="bbForum" data-tid="{$tid}">
+    <xsl:call-template name="bbComent">
+      <xsl:with-param name="elementId" select="@xml:id"/>
+    </xsl:call-template>
+
+  </xsl:template>
+  
+  <xsl:template name="bbComent">
+    <xsl:param name="elementId"/>
+    <xsl:variable name="tid" select="$topicLookup/map/entry[@id = $elementId]/@tid"/>
+    <div class="bbForum" data-tid="$tid">
       <p>
         <a target="_blank">
           <xsl:attribute name="href">
@@ -139,7 +137,6 @@
         </a>
       </p>
     </div>
-    
   </xsl:template>
   
   <!-- Modify navigation bar from webhelp-common.xsl -->
-- 
GitLab