The default implementation in the DITA Open Toolkit: single page sequence
Two templates in two stylesheets handle the topic element in the DITA OT: xsl/dita2fo-shell.xsl and xsl/xslfo/topic2foImpl.xsl. Which template handles the topic element depends on whether you are using the DITA map element to organize your books.
Example 6 shows the DITA-OT template in dita-ot/xsl/dita2fo-shell.xsl that creates a single fo:page-sequence wrapping around all the topics within the map. This template is called from the dita-setup template. The context of this template is the map element. (Actually, the context is defined by match="[contains(@class,'map/map')]", to be accurate.)
This style sheet operates on the temporary, merged XML file for the book in the build directory in the DITA OT, not directly on the source ditamap. In the temporary merged XML file, the map element surrounds all the topic content, not the topicrefs that it surrounds in the ditamap files. So even though the context is the map element, when this template issues the <xsl:apply-templates> element, the element it works on is a topic (or an element related to a topic).
Notice, as you did in Example 4, the relationship between the xsl:apply-template element for topics and the fo:page-sequence element. One is contained inside the other.
Example 6<xsl:template name="main-doc3">
<fo:page-sequence master-reference="chapter-master">
<fo:static-content flow-name="xsl-region-before">
...
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
...
</fo:static content>
<fo:flow flow-name="xsl-region-body">
<fo:block text-align="left" font-size="10pt"
font-family="Helvetica" break-before="page">
<xsl:apply-templates/>
</fo:block>
</fo:flow>
</fo:page-sequence>
<xsl:template>
Example 7 shows the DITA-OT template in xsl/xslfo/topic2foImpl.xsl that matches a top-level topic when there is no ditamap:
Example 7<xsl:template match="*[contains(@class,'topic/topic')]"
name="toptopic" mode="toplevel">
<xsl:call-template name="chapter-setup"/>
</xsl:template>
The following template matches all other topics, whether they are embedded in a map or a top-level topic. This template only creates fo:block elements, not fo:page-sequence elements.
<xsl:template match="*contains(@class,'topic/topic')]">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
The following template provides the fo:root and fo:page-sequence elements when the top-level topics are not contained in a map element. Just like the structure in , the xsl:apply-template element for lower-level topics is contained inside the fo:page-sequence element.
<xsl:template name="chapter-setup">
<!--Newline character (capture the native file
newline)-->
<xsl:variable name="newline"/>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
...
</fo:layout-master set>
<fo:page-sequence master-reference="common-page"
force-page-count="no-force">
<fo:static-content flow-name="xsl-region-before"
font-size="9pt" font-family="Helvetica">
...
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
...
</fo:static-content>
<!-- body -->
<fo:flow flow-name-"xsl-region-body">
<fo:block line-height="10pt" font size="9pt"
font-family="Helvetica" id="page1-1">
<xsl:apply-templates/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root
</xsl:template>
It is important to remember that in the DITA-OT, DITA files can be processed in two ways: as stand-alone DITA documents or as ditamaps. The dita2fo-shell.xsl file sets up the page flow when a ditamap is being processed. If a single DITA file is processed, the document is structured with the top element having a class attribute that contains the string topic/topic. The top-level topic is processed with the template:
<xsl:template match="*[contains(@class,'topic/topic')]"
name="toptopic" mode="toplevel">
which in turn calls the template:
<xsl:template name="chapter-setup">
For both processing as a stand-alone DITA document or a ditamap, topics beneath the map element or the top-level topic are processed by the template that begins:
<xsl:template match="*contains(@class,'topic/topic')]">
But by this time, the fo:page-sequence has already been created, so the whole book is now in a single large fo:page-sequence. This is the root cause of the memory problem for large books.
Next Page:
The solution in
the DITA Open Toolkit: multiple page sequences
