DITA-FMx always uses the <title> element in a topic file to generate title text in both XHTML and PDF outputs (regardless, for example, of the value of the navtitle attribute on the corresponding <topicref> element in the ditamap, and regardless of the value of the locktitle attribute).
I wanted a way to have one title on my HTML help pages and optionally a different one in the PDF file I generated using DITA-FMx's Generate Book from Map command.
I decided to use the <navtitle> element under <titlealts> ("alternative titles") in topic files to specify an alternative title for PDF output. I'm not too sure that this is DITA-compliant, but it works a charm. There's no support for this element in the default structured applications supplied with DITA-FMx, so I needed to make some modifications.
1. I edited the EDD of the DITA-Topic-FM structured application (which is just used to format text while you are authoring a topic), and added some formatting for the <titlealts> element, for example, 12pt, Red, and Bold. I also added a Prefix to remind me what it was for!
2. I edited the ditamap2fmbook.xsl file of the DITA-Book-FM structured application (which is used to format text for the FrameMaker book generated using the Generate Book from Map command). As its title suggests, this file translates a ditamap into a FrameMaker book. In fact, it only accomplishes the first stage of the conversion process, namely to generate a single XML file that includes all the ditamap and topic file content. This file is then further processed by FrameMaker's Read/Write Rules and converted to FM files.
Editing this XSL file is unfortunately not too straightforward. I needed to make sure that whenever a <navtitle> element is found in a topic file, its text is to be written into the generated XML file as the <title> element in place of the default, top-level <title> element. Here is the key part of the modified XSL:
<xsl:template match="title">
<title>
<xsl:choose>
<xsl:when test="following-sibling::titlealts/navtitle">
<xsl:copy-of select="@*">
<xsl:value-of select="following-sibling::titlealts/navtitle/text()">
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="@*node()">
</xsl:otherwise>
</xsl:choose>
</title>
</xsl:template>
So when the <title> element is followed by a sibling <titlealts> element that has a child <navtitle> element, write that element's text into the <title> element instead. Otherwise, just use the <title> element's text as usual.
Now when I want a different bookmark and heading in my PDF, I just add a <navtitle> element to my topic file, and set the locktitle attribute to "yes" in the <topicref> element of the ditamap that references the topic file. If I set the locktitle attribute back to "no", the <navtitle> is ignored and the default title text is used instead.
Based in France, SingleSourceDocs provides solutions for all aspects of single-source documentation
Thursday, 23 April 2009
Wednesday, 15 April 2009
Automatically applying master pages
I use DITA-FMx's Generate Book from Map command to generate a FrameMaker book from a DITAMAP. I have tried to streamline the process as much to possible, with the result that I can now generate a full-featured PDF file from a DITAMAP in just a few minutes.
One of the things that saves a bit of time is automatically applying master pages to the generated FrameMaker documents.
To do this, I set up the following table on the MasterPageMaps reference page of my DITA-FMx-Book template file:

The last line, beginning with E:title, instructs FrameMaker to test the value of the outputclass attribute on the title element of a DITA topic file and assign the NonChapterPage1 master page if the attribute value is "NonChapterName".
I assign the master pages by either:
- Selecting the chapter files in the Book window and choosing Format > Page Layout > Assign Master Pages
- Selecting the Apply Master Pages checkbox on the Update window when I first regenerate the table of contents for my book.
One of the things that saves a bit of time is automatically applying master pages to the generated FrameMaker documents.
To do this, I set up the following table on the MasterPageMaps reference page of my DITA-FMx-Book template file:

The last line, beginning with E:title, instructs FrameMaker to test the value of the outputclass attribute on the title element of a DITA topic file and assign the NonChapterPage1 master page if the attribute value is "NonChapterName".
I assign the master pages by either:
- Selecting the chapter files in the Book window and choosing Format > Page Layout > Assign Master Pages
- Selecting the Apply Master Pages checkbox on the Update window when I first regenerate the table of contents for my book.
Subscribe to:
Posts (Atom)