By default, the
Mini TOC only displays the child topics of a given chapter topic. To
add the possibility of also displaying the child sections, use an
Oxygen Publishing
Template and follow these steps:
- If you have not already created a Publishing Template, you need to create one. For
details, see How to Create a Publishing Template.
- Link the folder associated with the publishing template to your current
project in the Project Explorer view.
- Using the Project Explorer view, create an xslt folder inside the project
root folder.
- In the newly created folder, create an XSL file (for example, named
merged2mergedExtension.xsl) with the following
content:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/"
xmlns:opentopic-index="http://www.idiominc.com/opentopic/index"
xmlns:opentopic="http://www.idiominc.com/opentopic"
xmlns:oxy="http://www.oxygenxml.com/extensions/author" xmlns:saxon="http://saxon.sf.net/"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="#all">
<xsl:template match="*[contains(@class, ' topic/topic ')]">
<xsl:choose>
<xsl:when test="
($args.chapter.layout = 'MINITOC' or
$args.chapter.layout = 'MINITOC-BOTTOM-LINKS') and
oxy:is-chapter(/, oxy:get-topicref-for-topic(/, @id)) and
*[contains(@class, ' topic/topic ')]">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="*[contains(@class, ' topic/title ')]"/>
<xsl:apply-templates select="*[contains(@class, ' topic/prolog ')]"/>
<xsl:apply-templates select="*[contains(@class, ' topic/titlealts ')]"/>
<div>
<xsl:choose>
<xsl:when test="$args.chapter.layout = 'MINITOC'">
<xsl:attribute name="class">- topic/div chapter/minitoc </xsl:attribute>
<xsl:call-template name="generate-minitoc-links"/>
<xsl:call-template name="generate-minitoc-desc"/>
</xsl:when>
<xsl:when test="$args.chapter.layout = 'MINITOC-BOTTOM-LINKS'">
<xsl:attribute name="class">- topic/div chapter/minitoc chapter/minitoc-bottom </xsl:attribute>
<xsl:call-template name="generate-minitoc-desc"/>
<xsl:call-template name="generate-minitoc-links"/>
</xsl:when>
</xsl:choose>
</div>
<xsl:apply-templates select="*[contains(@class, ' topic/topic ')]"/>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:next-match/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="generate-minitoc-desc">
<div class="- topic/div chapter/minitoc-desc ">
<xsl:apply-templates select="
*[not(contains(@class, ' topic/title ')) and
not(contains(@class, ' topic/prolog ')) and
not(contains(@class, ' topic/titlealts ')) and
not(contains(@class, ' topic/topic ')) and
not(contains(@class, ' topic/section '))
]"/>
</div>
</xsl:template>
<xsl:template name="generate-minitoc-links">
<div class="- topic/div chapter/minitoc-links ">
<related-links class="- topic/related-links ">
<linklist class="- topic/linklist ">
<desc class="- topic/desc ">
<ph class="- topic/ph chapter/minitoc-label ">
<xsl:call-template name="getVariable">
<xsl:with-param name="id" select="'Mini Toc'"/>
</xsl:call-template>
</ph>
</desc>
<xsl:apply-templates select="
*[contains(@class, ' topic/topic ')] |
descendant-or-self::*[contains(@class, ' topic/section ')]"
mode="in-this-chapter-list"/>
</linklist>
</related-links>
</div>
</xsl:template>
<xsl:template match="
*[contains(@class, ' topic/topic ')
or contains(@class, ' topic/section ')]" mode="in-this-chapter-list">
<xsl:variable name="link-type" select="
if (contains(@class, ' topic/section ')) then
'section'
else
'topic'"/>
<link class="- topic/link " href="#{@id}" type="{$link-type}" role="child">
<linktext class="- topic/linktext ">
<xsl:value-of select="*[contains(@class, ' topic/title ')]"/>
</linktext>
</link>
</xsl:template>
</xsl:stylesheet>
- Open the template descriptor file associated with your publishing
template (the .opt file) and set the XSLT stylesheet created in the previous
step with the
com.oxygenxml.pdf.css.xsl.merged2merged XSLT extension
point:<publishing-template>
...
<pdf>
...
<xslt>
<extension
id="com.oxygenxml.pdf.css.xsl.mergedmerged"
file="xslt/merged2mergedExtension.xsl"/>
</xslt>
<parameters>
<parameter name="args.chapter.layout" value="MINITOC"/>
</parameters>
Note: This solution works also
with args.chapter.layout set to
MINITOC-BOTTOM-LINKS.
- Edit the DITA Map PDF - based on HTML5 & CSS transformation
scenario.
- In the Templates tab, click the Choose
Custom Publishing Template link and select your template.
- Click OK to save the changes and run the transformation
scenario.