I'm creating custom PDF output from a DITA bookmap using the AntennaHouse formatting engine. I'm trying to create a custom header that appears only on the first page of the book. These books can have multiple chapters, so the strategy I'm using is to create one page sequence for the first chapter, and then a different page sequence for the remaining chapters.
I distinguish between the first chapter processing and the rest of the chapters to be processed like this (in the file commons.xsl). The first block determines the chapter number and puts it in the variable "chapterNumber". The second block describes how to process chapters, depending on the content of the chapterNumber variable:
<xsl:variable name="id" select="@id"/>
<xsl:variable name="topicChapters">
<xsl:copy-of select="$map//*[contains(@class, ' bookmap/chapter ')]"/>
</xsl:variable>
<xsl:variable name="chapterNumber">
<xsl:number format="1" value="count($topicChapters/*[@id = $id]/preceding-sibling::*) + 1"/>
</xsl:variable>
<xsl:when test="$topicType = 'topicChapter'">
<xsl:choose>
<xsl:when test="$chapterNumber = '1'">
<xsl:call-template name="processFirstChapter"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="processTopicChapter"/>
</xsl:otherwise>
</xsl:choose>
The page sequence for the first chapter looks like this:
<fo:page-sequence-master master-name="body-first-sequence">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="first" master-reference="body-first"/>
<fo:conditional-page-master-reference page-position="rest" master-reference="body-rest"/>
<fo:conditional-page-master-reference master-reference="body-rest"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
The page sequence for the remaining chapters looks like this:
<fo:page-sequence-master master-name="body-sequence">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="any" master-reference="body-rest"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
During processing, I call two templates, one for the first chapter, and one for the rest of the chapters:
<xsl:template name="insertBodyStaticContents">
<xsl:call-template name="insertBodyFootnoteSeparator"/>
<xsl:call-template name="insertBodyRestHeader"/>
<xsl:call-template name="insertBodyFooter"/>
</xsl:template>
<xsl:template name="insertBodyFirstStaticContents">
<xsl:call-template name="insertBodyFootnoteSeparator"/>
<xsl:call-template name="insertBodyFirstHeader"/>
<xsl:call-template name="insertBodyFooter"/>
</xsl:template>
Those templates in turn call header templates, one for the first page of the first chapter, the other one for all remaining pages:
<xsl:template name="insertBodyFirstHeader">
<fo:static-content flow-name="first-body-header">
<fo:block-container z-index="-1" position="absolute" top="0pt" left="0pt" height="1.5in" width="100%">
<fo:block>
<fo:external-graphic src="Configuration/OpenTopic/cfg/common/artwork/qrgraphic.png"/>
</fo:block>
</fo:block-container>
<!-- set the title -->
<fo:block xsl:use-attribute-sets="__qrc__title__header">
<xsl:value-of select="//*[contains(@class,' bookmap/mainbooktitle ')]"/>
</fo:block>
<!-- set the subtitle -->
<fo:block xsl:use-attribute-sets="__first__heading__qrctext">
Quick Reference Card
</fo:block>
</fo:static-content>
</xsl:template>
<xsl:template name="insertBodyRestHeader">
<fo:static-content flow-name="rest-body-header">
<!-- set the title -->
<fo:block xsl:use-attribute-sets="__qrc__title__header2">
<xsl:value-of select="//*[contains(@class,' bookmap/mainbooktitle ')]"/>
</fo:block>
<!-- set the subtitle -->
<fo:block xsl:use-attribute-sets="__firstheading__subtitle">
Quick Reference Card
</fo:block>
</fo:static-content>
</xsl:template>
Everything works except for one strange glitch--if the first chapter of the book is longer than one page, then the first page of the first chapter has the correct header (the one with the flow name called first-body-header) but on subsequent pages of that chapter, the header is blank. Chapters two and greater also have the correct header (the one with the flow name called rest-body-header). I know that the code for that header is correct, since it appears in chapter two and beyond. But that exact same header is supposed to appear on pages 2+ of the first chapter, and it doesn't appear. I can't for the life of me figure out what's going wrong with my code. Any help is appreciated.