diff --git a/ws/Docbook/CustomLayer/slide/slideHdm.xsl b/ws/Docbook/CustomLayer/slide/slideHdm.xsl
index b0532222f3ffa1e6cbca93802cda25a32296e6c9..d5164491c9edcebb2d93d8f0426086e8d76f1514 100644
--- a/ws/Docbook/CustomLayer/slide/slideHdm.xsl
+++ b/ws/Docbook/CustomLayer/slide/slideHdm.xsl
@@ -10,77 +10,31 @@
   
   <xsl:import href="../Common/common.xsl"/>
 
-  <xsl:template match="/">
-    <xsl:apply-templates select="//d:chapter[contains(@annotations, 'slide')]|
-      //d:section[contains(@annotations, 'slide')]"
-      mode='slideSet'/>
+  <xsl:template match="/">    
+
+    <xsl:for-each select="//d:chapter[contains(@annotations, 'slide')]|
+                          //d:section[contains(@annotations, 'slide')]">
+      <xsl:call-template name="slideUnit">
+        <xsl:with-param name="rootId" select="@xml:id"/>
+        <xsl:with-param name="sections" select="."/>
+      </xsl:call-template>
+    </xsl:for-each>
+    
+
+    <xsl:for-each select="//d:chapter[descendant::*[contains(@annotations, 'slide')]]|
+                          //d:section[descendant::*[contains(@annotations, 'slide')]]">
+      <xsl:call-template name="slideUnit">
+        <xsl:with-param name="rootId" select="@xml:id"/>
+        <xsl:with-param name="sections" select="descendant::*[contains(@annotations, 'slide')]"/>
+      </xsl:call-template>
+    </xsl:for-each>
     
-    <xsl:apply-templates select="//d:chapter[descendant::*[contains(@annotations, 'slide')]]|
-      //d:section[descendant::*[contains(@annotations, 'slide')]]"
-      mode='selectedSlideSet'/>
-  </xsl:template>
-  
-  <xsl:template match="d:chapter | d:section" mode='selectedSlideSet'>
-    <xsl:result-document method="xhtml" encoding="utf-8" href="Slides/{@xml:id}.html" indent="no">
-      <html lang="en">
-        <head>
-          <title>
-            <xsl:value-of select="d:title"/>
-          </title>
-          <link href="mi.css" rel="stylesheet" />
-          <link href="reveal.js/css/reveal.css" rel="stylesheet" />
-          <link href="reveal.js/css/theme/solarized.css" id="theme" rel="stylesheet" />
-          
-          <!-- Code syntax highlighting -->
-          <link href="reveal.js/lib/css/zenburn.css" rel="stylesheet" />
-          
-        </head>
-        
-        <body>
-          <!-- Wrap the entire slide show in a div using the "reveal" class. -->
-          <div class="reveal">
-            <!-- Wrap all slides in a single "slides" class -->
-            <div class="slides">
-              <xsl:apply-templates select="descendant::*[contains(@annotations, 'slide')]" mode="slideDescendants"/>
-            </div>
-          </div>
-          
-          <script src="reveal.js/lib/js/head.min.js"></script>
-          <script src="reveal.js/js/reveal.js"></script>
-          <script>/*<![CDATA[*/
-            
-            Reveal.initialize({
-            controls: true,
-            progress: true,
-            history: true,
-            center: true,
-            
-            transition: 'slide', // none/fade/slide/convex/concave/zoom
-            
-            math: {
-            mathjax: 'https://prog.mi.hdm-stuttgart.de/mathjax/MathJax.js',
-            config: 'TeX-AMS-MML_HTMLorMML',  // See http://docs.mathjax.org/en/latest/config-files.html
-            },
-            // Optional reveal.js plugins
-            dependencies: [
-            { src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
-            { src: 'reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
-            { src: 'reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
-            { src: 'reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
-            { src: 'reveal.js/plugin/zoom-js/zoom.js', async: true },
-            { src: 'reveal.js/plugin/notes/notes.js', async: true },
-            { src: 'reveal.js/plugin/math/math.js', async: true }
-            ]
-            });
-            /*]]>*/</script>
-        </body>
-      </html>
-    </xsl:result-document>
   </xsl:template>
   
-  <xsl:template match="d:chapter | d:section" mode='slideSet'>
-    <xsl:result-document method="xhtml" encoding="utf-8" href="Slides/{@xml:id}.html" indent="no">
-      
+  <xsl:template name="slideUnit">
+    <xsl:param name="rootId"/>
+    <xsl:param name="sections"/>
+    <xsl:result-document method="xhtml" encoding="utf-8" href="Slides/{$rootId}.html" indent="no">
       <html lang="en">
         <head>
           <title>
@@ -100,7 +54,7 @@
           <div class="reveal">
             <!-- Wrap all slides in a single "slides" class -->
             <div class="slides">
-              <xsl:apply-templates select="." mode="slideDescendants"/>
+              <xsl:apply-templates select="$sections" mode="slideDescendants"/>
             </div>
           </div>