Add subsection to pdf toc

Post here questions and problems related to editing and publishing DITA content.
Edwin
Posts: 22
Joined: Tue May 17, 2016 4:58 pm

Add subsection to pdf toc

Post by Edwin »

Hello I have created a dita document containing subsextions:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="topic_i4f_4hy_sw">
<title>Navigation overview</title>
<prolog>
<metadata>
<keywords>
<indexterm>Navigation</indexterm>
<indexterm>Menu bar</indexterm>
<indexterm>Document view</indexterm>
</keywords>
</metadata>
</prolog>
<body>
<section><title>The menu bar</title><p>bla bla bla</p></section>
<section><title>The document view</title><p>bla bla bla</p></section>
How do I customize the default toc.xsl from the dita2pdf translation to include the section titles in the table of contents. I know that i can create individual nested topics to solve this but i prefer to be able to use sections. My ditamap contains 2 levels, so the sections should be included as a 3rd level toc item
radu_pisoi
Posts: 403
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: Add subsection to pdf toc

Post by radu_pisoi »

Hi,

We don't encountered a similar request until now, so I can't give you precise instruction about this request.

As you already found, you need to modify the functionality from 'toc.xsl' stylesheet. This is the stylesheet that contains templates used to produce the PDF TOC. Of course, in order to override the templates from 'toc.xsl' you need a PDF customization plugin that will contribute a customization stylesheet.

Now, about the changes you have to make in your customization stylesheet. I think you can inspire from the next template from toc.xsl:

Code: Select all

<xsl:template match="*[contains(@class, ' topic/topic ')]" mode="toc">
that is used to produce an entry in TOC for each topic. Did you try to modify this template to handle also the sections?

Also, in order to develop your changes in this stylesheet, my advice is to instruct the DITA-OT processor to not clean the temporary directory produced by the PDF transformation(set the 'clean.temp' parameter to 'no'). After, you run the transformation once, you can open the 'temp/dita_map_MERGED.xml' and investigate it's content.

However, for this kind of request it is better to use the DITA users list http://dita.xml.org/dita-users. This mailing list is monitored by many DITA consultants that can offer you good advice.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply