From 649b32f2db60221e926173898634dd6b89d16518 Mon Sep 17 00:00:00 2001
From: Martin Goik <goik@hdm-stuttgart.de>
Date: Fri, 5 Jun 2015 19:38:09 +0200
Subject: [PATCH] Removing unnecessary "if", replacing link by xref for chapter
 references

---
 ws/Docbook/Extensions/Xsl/docbook2docbook.xsl | 37 +++++--------------
 1 file changed, 10 insertions(+), 27 deletions(-)

diff --git a/ws/Docbook/Extensions/Xsl/docbook2docbook.xsl b/ws/Docbook/Extensions/Xsl/docbook2docbook.xsl
index d830d05c3..3721ca8f1 100644
--- a/ws/Docbook/Extensions/Xsl/docbook2docbook.xsl
+++ b/ws/Docbook/Extensions/Xsl/docbook2docbook.xsl
@@ -89,15 +89,12 @@
                         <th>Exercise title / page</th>
                         <th>Status of completion</th>
                     </tr>
-                    <xsl:for-each select=".//db:chapter">
+                    <xsl:for-each select=".//db:chapter[.//db:qandaset]">
                         <xsl:variable name="qandaSets" select=".//db:qandaset"/>
-                        
-                        <xsl:if test="$qandaSets">
+                            <!-- Top level chapter + first exercise's title -->
                             <tr>
                                 <td valign="top" rowspan="{count($qandaSets)}">
-                                    <link linkend="{@xml:id}">
-                                        <xsl:copy-of select="db:title/node()"/>
-                                    </link>
+                                    <xref linkend="{@xml:id}"/>
                                 </td>
                                 <td> 
                                     <xsl:apply-templates select="$qandaSets[1]" 
@@ -105,7 +102,7 @@
                                 </td>
                                 <td/>
                             </tr>
-                            
+                            <!-- Remaining exercises -->
                             <xsl:for-each select="$qandaSets[1 &lt; position()]">
                                 <tr>
                                     <td> 
@@ -115,19 +112,15 @@
                                     <td/>
                                 </tr>
                             </xsl:for-each>
-                            
-                        </xsl:if>
-                        
-                    </xsl:for-each>
-                    
+                    </xsl:for-each>                    
                 </table>
             </appendix>
             </xsl:if>
         </xsl:copy>        
     </xsl:template>
-    
+
     <xsl:template match="db:qandaset" mode="selectOwnOrInheritedTitle">
-        <link linkend="{@xml:id}"> <!--  xrefstyle="template:%n, %t" -->
+        <link linkend="{@xml:id}"> <!--  xrefstyle="template:%n, %t" -->            
             <xsl:choose>
                 <xsl:when test="db:title">
                     <xsl:copy-of select="db:title/node()"/>
@@ -209,23 +202,13 @@
         <itemizedlist>
             <listitem>
                 <para>
-                    <xsl:text>Maven module source code available at sub directory </xsl:text>
-		    <filename>
+                    <xsl:text>Maven module source code available at sub directory </xsl:text> <filename>
 		      <xsl:value-of select="$baseDir"/>
-		    </filename>		    
-
-                    <xsl:text> below lecture notes' source code root, see </xsl:text>
-
-                    <link linkend="sd1ImportMavenSolutions"> hints regarding import.</link>
-
-                </para>
- 
-
+		    </filename> <xsl:text> below lecture notes' source code root, see </xsl:text> <link linkend="sd1ImportMavenSolutions"> hints regarding import.</link></para>
             </listitem>
             
             <listitem>
-                <para>Online browsing of <link xlink:href="{$baseDir}/target/site/apidocs/allclasses-noframe.html">API
-                    and implementation</link>.</para>
+                <para>Online browsing of <link xlink:href="{$baseDir}/target/site/apidocs/allclasses-noframe.html">API and implementation</link>.</para>
             </listitem>
         </itemizedlist>
     </xsl:template>
-- 
GitLab