From 70cf5dba24e0281c88c6b4476d8be8d9ffe3ebf7 Mon Sep 17 00:00:00 2001
From: goik <goik@mi-VirtualBox>
Date: Sat, 27 Aug 2016 22:12:26 +0200
Subject: [PATCH] Slide generating style sheet

---
 ws/Docbook/Extensions/Tdata/Makefile         |  6 +-
 ws/Docbook/Extensions/Tdata/fig.xml          | 38 +++++++++
 ws/Docbook/Extensions/Xsl/docbook2slides.xsl | 87 ++++++++++++++++++++
 3 files changed, 130 insertions(+), 1 deletion(-)
 create mode 100644 ws/Docbook/Extensions/Xsl/docbook2slides.xsl

diff --git a/ws/Docbook/Extensions/Tdata/Makefile b/ws/Docbook/Extensions/Tdata/Makefile
index 43890ce46..b1e907e42 100644
--- a/ws/Docbook/Extensions/Tdata/Makefile
+++ b/ws/Docbook/Extensions/Tdata/Makefile
@@ -29,7 +29,11 @@ SAXONCMD=java -cp "/usr/share/java/Saxon-HE.jar:/usr/share/java/xercesImpl.jar"
 
 
 
-all: epub webhelp pdf
+all: epub webhelp pdf slides
+
+slides: fig.xml
+	mkdir -p Slides
+	${SAXONCMD} -s:fig.xml -xsl:../Xsl/docbook2slides.xsl
 
 
 
diff --git a/ws/Docbook/Extensions/Tdata/fig.xml b/ws/Docbook/Extensions/Tdata/fig.xml
index 960b30f8e..6904225f1 100644
--- a/ws/Docbook/Extensions/Tdata/fig.xml
+++ b/ws/Docbook/Extensions/Tdata/fig.xml
@@ -242,4 +242,42 @@
 
     <para>This is the end my friend.</para>
   </chapter>
+
+  <chapter>
+    <title>Mixing lecture notes and slides</title>
+
+    <section xml:id="classintro">
+      <title>Objects and classes</title>
+
+      <annotation role="slide">
+        <para>Ignore me, just here to supply a valid annotation content
+        model.</para>
+      </annotation>
+      <para>To be continued accordingly ...</para>
+
+      <section xml:id="objectsClassesBasics">
+        <title>Classes in OO languages</title>
+
+        <itemizedlist>
+          <listitem>
+            <para>Blueprints for objects</para>
+          </listitem>
+
+          <listitem>
+            <para>Attributes and methods.</para>
+          </listitem>
+        </itemizedlist>
+      </section>
+
+      <section xml:id="classVsInstance">
+        <title>Classes and instances</title>
+
+        <mediaobject>
+          <imageobject>
+            <imagedata fileref="Ref/Fig/class.svg"/>
+          </imageobject>
+        </mediaobject>
+      </section>
+    </section>
+  </chapter>
 </book>
diff --git a/ws/Docbook/Extensions/Xsl/docbook2slides.xsl b/ws/Docbook/Extensions/Xsl/docbook2slides.xsl
new file mode 100644
index 000000000..1dc9cf941
--- /dev/null
+++ b/ws/Docbook/Extensions/Xsl/docbook2slides.xsl
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
+    xmlns:xlink="http://www.w3.org/1999/xlink"  xmlns:d="http://docbook.org/ns/docbook">
+    
+    <xsl:import href="/usr/share/xmlmind/addon/config/docbook5/xsl/html/docbook.xsl" />
+    
+    <xsl:template match="/">
+        <xsl:apply-templates select="//d:section[d:annotation[@role='slide']]" mode='entry'/>        
+    </xsl:template>
+    
+    <xsl:template match="d:section" mode='entry'>
+        <xsl:result-document method="xhtml" encoding="utf-8" href="Slides/{@xml:id}.html" indent="yes">
+            <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">
+                            <section>
+                                <xsl:apply-templates select="*[not(name(.)='section')]"/>
+                            </section>
+                            <xsl:apply-templates select="d:section"/>
+                        </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
+			
+			// 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 }
+			]
+			});
+			/*]]>*/</script>
+                </body>
+            </html>
+        </xsl:result-document>
+    </xsl:template>
+    
+    <xsl:template match="d:section">
+        <section>
+            <xsl:apply-templates/>
+        </section>
+    </xsl:template>
+    
+    <xsl:template match="d:section/d:title">
+        <h1>
+            <xsl:value-of select="."/>
+        </h1>
+    </xsl:template>
+    
+    <xsl:template match="sag">
+        <xsl:comment>
+            <xsl:text>No template defined for element '</xsl:text>
+            <xsl:value-of select="namespace-uri()"/>
+            <xsl:text>:</xsl:text>
+            <xsl:value-of select="name(.)"/>
+            <xsl:text>'</xsl:text>
+        </xsl:comment>
+    </xsl:template>
+</xsl:stylesheet>
-- 
GitLab