diff --git a/ws/Docbook/Extensions/Tdata/Makefile b/ws/Docbook/Extensions/Tdata/Makefile index a15f8b8f303ae6087cd2d26a66a7f267a4a07a33..19df74d30e1996fce43b161a909fe573204992d4 100644 --- a/ws/Docbook/Extensions/Tdata/Makefile +++ b/ws/Docbook/Extensions/Tdata/Makefile @@ -40,6 +40,7 @@ article/appendix nop \ article toc,title \ book toc,title,figure,table,example,equation \ chapter toc,title \ +appendix toc,title \ part toc,title \ preface toc,title \ reference toc,title \ diff --git a/ws/Docbook/Extensions/Tdata/fig.xml b/ws/Docbook/Extensions/Tdata/fig.xml index 46c0fbccf73fa8b2f99b53df24f088c61d6e7886..34feeb6a82586ca1dabf727d74490f5ed4759e0f 100644 --- a/ws/Docbook/Extensions/Tdata/fig.xml +++ b/ws/Docbook/Extensions/Tdata/fig.xml @@ -57,7 +57,25 @@ </qandadiv> </qandaset> - <para>This is the end my friend.</para> + <section xml:id="nestedQuestion"> + <title>Nested question</title> + + <qandaset defaultlabel="qanda" xml:id="qandaNestedQuestion"> + <title>A nested question</title> + + <qandadiv> + <qandaentry xml:id="qandaQ1"> + <question> + <para>My nested question</para> + </question> + + <answer> + <para>My nested answer</para> + </answer> + </qandaentry> + </qandadiv> + </qandaset> + </section> </chapter> <xi:include href="Components/exampleSlides.xml" xpointer="element(/1)"/> diff --git a/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl b/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl index d1f42beaf8df80847b798026d0516bc2cb08e9f8..2955871b3f9a5a17e25a9420f3ecc0a59efaef87 100644 --- a/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl +++ b/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl @@ -1,226 +1,208 @@ <?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="http://docbook.org/ns/docbook" xmlns:db="http://docbook.org/ns/docbook"> - - - <xsl:import href="../../docbook-xsl/profiling/profile.xsl"/> - <xsl:include href="common.xsl"/> - - <xsl:param name="generateIdPrefix">__sdwordm4342cs__</xsl:param> - <xsl:output indent="no"/> - <xsl:param name="lastAnswerId" select="document('lastAnswerId.xml',/)/lastAnswer/@id" /> - - - - - <xsl:key name="internRef" match="//*[@linkend]" use="@linkend"/> - -<!-- <xsl:template match="node() | @*"> - <xsl:copy> - <xsl:apply-templates select="node()| @*"/> - </xsl:copy> - </xsl:template> ---> - -<!-- <xsl:template match="@fileref"> - <xsl:attribute name="fileref"> - <xsl:text>_Resources/</xsl:text> <!-\- account for descend into "target" subdir -\-> - <xsl:if test="ancestor::*/@xml:base"> - <xsl:call-template name="hdm.get.leftmost.of.separator"> - <xsl:with-param name="path" select="ancestor::*/@xml:base"/> - <xsl:with-param name="separator" select="'/'"/> - </xsl:call-template> - <xsl:text>/</xsl:text> - </xsl:if> - <xsl:value-of select="."/> - </xsl:attribute> - </xsl:template> ---> - - <xsl:template match="*" mode="hdmIdGenerate"> - <xsl:choose> - <xsl:when test="@xml:id"> - <xsl:value-of select="@xml:id"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="$generateIdPrefix"/> - <xsl:value-of select="generate-id()"/> - </xsl:otherwise> - </xsl:choose> - </xsl:template> - - <!-- - <xsl:template match="db:answer"> - <db:answer> - <xsl:variable name="proximaParentId" select="ancestor::*[@xml:id and position()=1]/@xml:id"/> - <xsl:choose> - <xsl:when test="following::*[@xml:id=$lastAnswerId] or ancestor::*[@xml:id=$lastAnswerId]"> - <xsl:apply-templates select="@* | node()"/> + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns="http://docbook.org/ns/docbook" xmlns:db="http://docbook.org/ns/docbook"> + + + <xsl:include href="common.xsl"/> + + <xsl:param name="generateIdPrefix">__sdwordm4342cs__</xsl:param> + <xsl:output indent="yes"/> + <xsl:param name="lastAnswerId" select="document('lastAnswerId.xml',/)/lastAnswer/@id" /> + + <xsl:key name="internRef" match="//*[@linkend]" use="@linkend"/> + + <xsl:template match="node() | @*"> + <xsl:copy> + <xsl:apply-templates select="node()| @*"/> + </xsl:copy> + </xsl:template> + + <xsl:template match="*" mode="hdmIdGenerate"> + <xsl:choose> + <xsl:when test="@xml:id"> + <xsl:value-of select="@xml:id"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$generateIdPrefix"/> + <xsl:value-of select="generate-id()"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <!-- Providing list of exercises --> + <xsl:template match="db:book"> + <xsl:copy> + <xsl:apply-templates select="@* | node()"/> + <xsl:if test=".//db:qandaset"> + <appendix> + <title>List of Exercises</title> + + <table border="1" xml:id="{@xml:id}tableExercise"> + <caption> + <xsl:text>Exercises in </xsl:text> + <emphasis> + <xsl:value-of select="db:info/db:title" /> + </emphasis> + </caption> + <col width="25%" /> + <col width="45%" /> + <col width="30%" /> + <tr> + <th>Chapter</th> + <th>Exercise title / page</th> + <th>Status of completion</th> + </tr> + + <xsl:for-each-group select=".//db:qandaset" group-by="ancestor::db:chapter/@xml:id"> + <xsl:for-each select="current-group()"> + <tr> + <xsl:if test="1 = position()"> <!-- Group's key entry only present in first row --> + <td valign="top" rowspan="{count(current-group())}"> + <xref linkend="{current-grouping-key()}"/> + </td> + </xsl:if> + <td> + <xsl:value-of select="db:title"/> + </td> + <td/> <!-- empty status of completion --> + </tr> + </xsl:for-each> + + </xsl:for-each-group> + </table> + <xsl:apply-templates select="db:chapter[descendant::db:qandaset]" mode="genQuandaset"/> + </appendix> + </xsl:if> + </xsl:copy> + </xsl:template> + + + <xsl:template match="db:chapter" mode="genQuandaset"> + <chapter id="{@xml:id}_qanda"> + <title> + <xsl:text>Exercises in </xsl:text> + <emphasis> + <xsl:for-each select="db:title" > + <xsl:copy-of select="node()|text()"/> + </xsl:for-each> + </emphasis> + </title> + <itemizedlist> + <xsl:for-each select="descendant::db:qandaset"> + <listitem> + <xref linkend="{@xml:id}"/> + </listitem> + </xsl:for-each> + </itemizedlist> + </chapter> + </xsl:template> + + <xsl:template match="db:qandaset" mode="selectOwnOrInheritedTitle"> + <link linkend="{@xml:id}"> <!-- xrefstyle="template:%n, %t" --> + <xsl:choose> + <xsl:when test="db:title"> + <xsl:copy-of select="db:title/node()"/> </xsl:when> <xsl:otherwise> - <para>Answer id=<xsl:value-of select="ancestor::*[@xml:id][1]/@xml:id"/> not yet published.</para> + <xsl:copy-of select="preceding-sibling::db:title[1]/node()"/> </xsl:otherwise> - </xsl:choose> - </db:answer> - </xsl:template> - --> - <xsl:template match="db:part"> + </xsl:choose> + </link> + </xsl:template> + + <!-- Excluding non-referenced <bibliography> and <glossary> elements --> + + <xsl:template match="db:bibliography/db:biblioentry[not(key('internRef', @xml:id))]"> + <xsl:comment> + <xsl:text>Excluding non referenced bibliography entry '</xsl:text> + <xsl:value-of select="db:abbrev"/> + <xsl:text>', @xml:id='</xsl:text> + <xsl:value-of select="@xml:id"/> + <xsl:text>'</xsl:text> + </xsl:comment> + </xsl:template> + + <xsl:template match="db:glossary//db:glosslist"> + + <xsl:choose> + <xsl:when test=".//db:glossentry[key('internRef', @xml:id) or key('internRef', .//*/@xml:id)]"> + <xsl:comment>Non-empty glosslist</xsl:comment> <xsl:copy> - <xsl:apply-templates select="@* | node()"/> - <xsl:if test=".//db:qandaset"> - <appendix> - <title> - <xsl:text>List of exercise sets in </xsl:text> - <xsl:value-of select="db:title" /> - </title> - - <table border="1" xml:id="{@xml:id}solutionsExercise"> - <caption>Index of exercises</caption> - <col width="25%" /> - <col width="45%" /> - <col width="30%" /> - <tr> - <th>Chapter</th> - <th>Exercise title / page</th> - <th>Status of completion</th> - </tr> - <xsl:for-each select=".//db:chapter[.//db:qandaset]"> - <xsl:variable name="qandaSets" select=".//db:qandaset"/> - <!-- Top level chapter + first exercise's title --> - <tr> - <td valign="top" rowspan="{count($qandaSets)}"> - <xref linkend="{@xml:id}"/> - </td> - <td> - <xsl:apply-templates select="$qandaSets[1]" - mode="selectOwnOrInheritedTitle"/> - </td> - <td/> - </tr> - <!-- Remaining exercises --> - <xsl:for-each select="$qandaSets[1 < position()]"> - <tr> - <td> - <xsl:apply-templates select="." - mode="selectOwnOrInheritedTitle"/> - </td> - <td/> - </tr> - </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" --> - <xsl:choose> - <xsl:when test="db:title"> - <xsl:copy-of select="db:title/node()"/> - </xsl:when> - <xsl:otherwise> - <xsl:copy-of select="preceding-sibling::db:title[1]/node()"/> - </xsl:otherwise> - </xsl:choose> - </link> - </xsl:template> - - <!-- Excluding non-referenced <bibliography> and <glossary> elements --> - - <xsl:template match="db:bibliography/db:biblioentry[not(key('internRef', @xml:id))]"> - <xsl:comment> - <xsl:text>Excluding non referenced bibliography entry '</xsl:text> - <xsl:value-of select="db:abbrev"/> - <xsl:text>', @xml:id='</xsl:text> - <xsl:value-of select="@xml:id"/> - <xsl:text>'</xsl:text> - </xsl:comment> - </xsl:template> - - <xsl:template match="db:glossary//db:glosslist"> - - <xsl:choose> - <xsl:when test=".//db:glossentry[key('internRef', @xml:id) or key('internRef', .//*/@xml:id)]"> - <xsl:comment>Non-empty glosslist</xsl:comment> - <xsl:copy> - <xsl:apply-templates select="@* | node()"/> - </xsl:copy> - </xsl:when> - <xsl:otherwise> - <xsl:comment> - <xsl:text>No @xml:id or all glosslist entries are not being referenced, excluding whole list.</xsl:text> - </xsl:comment> - <xsl:apply-templates select="db:glossentry"/> - </xsl:otherwise> - </xsl:choose> - </xsl:template> - - <xsl:template match="db:glossary/db:glosslist//db:glossentry[not(key('internRef', @xml:id)) and not(key('internRef', .//*/@xml:id))]"> + <xsl:apply-templates select="@* | node()"/> + </xsl:copy> + </xsl:when> + <xsl:otherwise> <xsl:comment> - <xsl:text>Excluding non referenced glossary entry '</xsl:text> - <xsl:value-of select="db:glossterm"/> - <xsl:text>', @xml:id='</xsl:text> - <xsl:value-of select="@xml:id"/> - <xsl:text>'</xsl:text> + <xsl:text>No @xml:id or all glosslist entries are not being referenced, excluding whole list.</xsl:text> </xsl:comment> + <xsl:apply-templates select="db:glossentry"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template match="db:glossary/db:glosslist//db:glossentry[not(key('internRef', @xml:id)) and not(key('internRef', .//*/@xml:id))]"> + <xsl:comment> + <xsl:text>Excluding non referenced glossary entry '</xsl:text> + <xsl:value-of select="db:glossterm"/> + <xsl:text>', @xml:id='</xsl:text> + <xsl:value-of select="@xml:id"/> + <xsl:text>'</xsl:text> + </xsl:comment> + </xsl:template> + + <!-- + <xsl:template match="db:bibliography"> + <db:bibliography> + <xsl:apply-templates select="*[not(name(.) = 'biblioentry')]|db:biblioentry[key('internRef', @xml:id)]"/> + </db:bibliography> </xsl:template> - <!-- - <xsl:template match="db:bibliography"> - <db:bibliography> - <xsl:apply-templates select="*[not(name(.) = 'biblioentry')]|db:biblioentry[key('internRef', @xml:id)]"/> - </db:bibliography> - </xsl:template> - - - <xsl:template match="db:glossary/db:glosslist"> - <db:glosslist> - <xsl:apply-templates select="*[not(name(.) = 'glossentry')]|db:glossentry[key('internRef', @xml:id)]"/> - </db:glosslist> - </xsl:template> - --> - - <!-- make annotations --> - <xsl:template match="db:annotation[@role='make']"> - <xsl:apply-templates select="*" mode="make"/> + <xsl:template match="db:glossary/db:glosslist"> + <db:glosslist> + <xsl:apply-templates select="*[not(name(.) = 'glossentry')]|db:glossentry[key('internRef', @xml:id)]"/> + </db:glosslist> </xsl:template> - - <xsl:template match="db:para[@role='eclipse']" mode='make'> - - <xsl:variable name="baseDir"> - <xsl:text>P/</xsl:text> - <xsl:value-of select="."/> - </xsl:variable> - - <itemizedlist> - <listitem> - <para> - <xsl:text>Maven module source code available at sub directory </xsl:text> - <filename xlink:href="https://gitlab.mi.hdm-stuttgart.de/goik/GoikLectures/tree/master/{$baseDir}"> - <xsl:value-of select="$baseDir"/> - </filename> - <xsl:text> below lecture notes' source code root, see </xsl:text> - <link linkend="sd1ImportMavenSolutions"> hints regarding import</link> - <xsl:text>.</xsl:text> - </para> - </listitem> - - <listitem> - <para>Online browsing of <link xlink:href="{$baseDir}/target/site/apidocs/allclasses-noframe.html">API and implementation</link>.</para> - </listitem> - </itemizedlist> - </xsl:template> - - <xsl:template match="*" mode="make"> - <db:para> - <xsl:text>No template of mode='make' defined for element'</xsl:text> - <xsl:value-of select="name(.)"/> - <xsl:text>'</xsl:text> - </db:para> - </xsl:template> - + --> + + <!-- make annotations --> + <xsl:template match="db:annotation[@role='make']"> + <xsl:apply-templates select="*" mode="make"/> + </xsl:template> + + <xsl:template match="db:para[@role='eclipse']" mode='make'> + + <xsl:variable name="baseDir"> + <xsl:text>P/</xsl:text> + <xsl:value-of select="."/> + </xsl:variable> + + <itemizedlist> + <listitem> + <para> + <xsl:text>Maven module source code available at sub directory </xsl:text> + <filename xlink:href="https://gitlab.mi.hdm-stuttgart.de/goik/GoikLectures/tree/master/{$baseDir}"> + <xsl:value-of select="$baseDir"/> + </filename> + <xsl:text> below lecture notes' source code root, see </xsl:text> + <link linkend="sd1ImportMavenSolutions"> hints regarding import</link> + <xsl:text>.</xsl:text> + </para> + </listitem> + + <listitem> + <para>Online browsing of <link xlink:href="{$baseDir}/target/site/apidocs/allclasses-noframe.html">API and implementation</link>.</para> + </listitem> + </itemizedlist> + </xsl:template> + + <xsl:template match="*" mode="make"> + <db:para> + <xsl:text>No template of mode='make' defined for element'</xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:text>'</xsl:text> + </db:para> + </xsl:template> + </xsl:stylesheet>