DITA->PDF transform; how to remove title page and TOC

Here should go questions about transforming XML with XSLT and FOP.
GreatBigBore
Posts: 4

DITA->PDF transform; how to remove title page and TOC

Sat Feb 20, 2016 1:02 am

Sorry to ask such dumb questions here, but I promise I've been all over the place trying to figure this out. I tried reading the xsl files, but some of the syntax is totally baffling to me, so I'm not making much progress. If anyone out there is feeling indulgent, I am trying to answer three questions:

  • How to omit the title page from the PDF
  • How to omit the TOC from the PDF
  • What in the world does this syntax mean in the XSL: contains(@class, ' topic/title ') -- I understand the contains function, and I understand @class. But I don't understand ' topic/title '. What's with the spaces? Why do templates with this function run, when there is nothing in my project that has a class attribute with such a weird value. And I can't find ' topic/title ' being assigned to any class attribute in any of the xsl.

Thanks to anyone who can give me some advice.
radu_pisoi
Posts: 302
Location: Craiova

Re: DITA->PDF transform; how to remove title page and TOC

Tue Feb 23, 2016 12:01 pm

Hi,
GreatBigBore wrote:* How to omit the title page from the PDF
* How to omit the TOC from the PDF

I assumed you are using the Apache FOP processor for generating the PDF file. In order to do that you have to override some XSLT templates that are responsible for generating TOC and the title page. The title page is generated by the template createFrontMatter (DITA-OT/plugins/org.dita.pdf2/xsl/fo/front-matter.xsl) and TOC is generated by the createToc template (DITA-OT/plugins/org.dita.pdf2/xsl/fo/toc.xsl).

A solution to avoid their generation is to comment the invocation of the above templates from the rootTemplate template defined in the file DITA-OT/plugins/org.dita.pdf2/xsl/fo/root-processing_fop.xsl. After you have commented the code, it should look something like:

Code: Select all

<xsl:template match="/" name="rootTemplate">
    <xsl:call-template name="validateTopicRefs"/>
    <fo:root xsl:use-attribute-sets="__fo__root">
      <xsl:call-template name="createLayoutMasters"/>
      <xsl:call-template name="createMetadata"/>
      <xsl:call-template name="createBookmarks"/>
      <!--<xsl:call-template name="createFrontMatter"/>
      <xsl:if test="not($retain-bookmap-order)">
        <xsl:call-template name="createToc"/>
      </xsl:if>-->
      <xsl:apply-templates/>     
      <xsl:if test="not($retain-bookmap-order)">
        <xsl:call-template name="createIndex"/>
      </xsl:if>
    </fo:root>
  </xsl:template>


To apply these modifications, it is recommended to write a PDF customization plugin that will override the above XSLT template. The procedure for creating a such plugin can be found in our user manual at http://oxygenxml.com/doc/versions/17.1/ ... ation.html

GreatBigBore wrote:What in the world does this syntax mean in the XSL: contains(@class, ' topic/title ') -- I understand the contains function, and I understand @class. But I don't understand ' topic/title '. What's with the spaces? Why do templates with this function run, when there is nothing in my project that has a class attribute with such a weird value. And I can't find ' topic/title ' being assigned to any class attribute in any of the xsl.


Class attributes are usually necessary only when using a DITA customization. You don't have to explicitly specify the class attributes for the default DITA implementation. The class attributes are already specified as default value attributes in the DITA DTDs and are taken into consideration by the transformation. You can read more about the DITA specialization here:
http://docs.oasis-open.org/dita/v1.2/os ... l#classatt
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
asurkau
Posts: 3

Re: DITA->PDF transform; how to remove title page and TOC

Fri May 26, 2017 6:35 pm

If your PDF plugin is based on DITA OT 2.x, it is quite easy to remove either the title page or the TOC.
Add the following variables to basic-settings.xsl and set to true or false, as required:

Code: Select all

<xsl:variable name="generate-front-cover" select="false()"/>
<xsl:variable name="generate-toc" select="false()"/>


Hope this helps!

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 0 guests