[xsl] Cocoon (daisy) to PDF output includes unwanted blank page

Subject: [xsl] Cocoon (daisy) to PDF output includes unwanted blank page
From: Robert Raleigh <rraleigh@xxxxxxxxxxxx>
Date: Wed, 28 Jan 2009 13:22:06 -0700
I'm using a CMS publishing system called Daisy, which has an option for outputting to PDF using XSLt stylesheets and FOP. I've been trying to create a stylesheet that applies a unique full-page graphic to the Table of Contents pages (but not to the rest of the pages in the document). I'm running into a problem where a blank page shows up in the PDF output between the TOC and the start of the document.

Here are the relevant portions of my stylesheet:

<!--master page definitions-->

<fo:layout-master-set>
<fo:simple-page-master master-name="frontpage"
page-height="11in"
page-width="8.5in"
margin-top="2cm"
margin-bottom="2cm"
margin-left="2cm"
margin-right="2cm">
<fo:region-body region-name="body"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="tocpage"
page-height="11in"
page-width="8.5in"
margin-top=".5in"
margin-bottom=".5in"
margin-left=".5in"
margin-right=".5in">
<fo:region-body region-name="body"/>
</fo:simple-page-master>


      <fo:simple-page-master master-name="simplepage"
         page-height="11in"
         page-width="8.5in"
         margin-top=".5in"
         margin-bottom=".5in"
         margin-left=".5in"
         margin-right=".5in">
         <fo:region-body region-name="body"
           margin-bottom="1.5in" margin-top="1in"/>
         <fo:region-after region-name="bottom" extent="1in"/>
       </fo:simple-page-master>

       <fo:simple-page-master master-name="indexpage"
         page-height="11in"
         page-width="8.5in"
         margin-top="1cm"
         margin-bottom="1cm"
         margin-left="2.5cm"
         margin-right="2cm">
         <fo:region-body region-name="body"
           margin-bottom="1.5cm" margin-top="1.5cm" column-count="3"/>
         <fo:region-before region-name="top" extent="1.3cm"/>
         <fo:region-after region-name="bottom" extent="1.3cm"/>
       </fo:simple-page-master>
     </fo:layout-master-set>

<!--Section for creating PDF bookmarks.-->

<xsl:apply-templates select="toc" mode="pdfbookmarks"/>

<!--Page sequence for TOC template.-->

       <fo:page-sequence master-reference="tocpage">
           <fo:flow flow-name="body">
               <xsl:apply-templates select="toc"/>
           </fo:flow>
       </fo:page-sequence>

<!--Simple page sequence for processing everything else (I have to use a NOT declaration to exclude the TOC or it gets processed twice.-->

<fo:page-sequence master-reference="simplepage">
<fo:static-content flow-name="bottom">
<xsl:call-template name="footer"/>
</fo:static-content>
<fo:flow flow-name="body">
<fo:block xsl:use-attribute-sets="body.text">
<xsl:apply-templates select="*[not(self::toc)]"/>
<!-- Normally the footnotes for the previous chapter are inserted at the start of the next chapter
(see h1 template), but for the last chapter we have to do it here. -->
<xsl:if test="$footnotesAtEndOfChapter">
<xsl:call-template name="insertFootNotes">
<xsl:with-param name="footnotes" select="descendant::span[@class='footnote' and count(following::h1) = 0] | descendant::a[@href != string(.) and not(starts-with(@href, '#')) and count(following::h1) = 0]"/>
</xsl:call-template>
</xsl:if>
</fo:block>
</fo:flow>
</fo:page-sequence>


<!--TOC templates (one of which is for processing tocentry elements, which are children of the toc element), which includes formatting for the full-page graphic in the form of a block container.-->

<xsl:template match="toc">
<fo:block-container
width="8.5in"
height="11in"
absolute-position="absolute"
top="-.5in"
left="-.5in"
right="-.5in"
bottom="-.5in"
background-image="file:///C:/wikidata/books/publicationtypes/testpdf/resources/images/iomanager_template2.svg"


       background-repeat="no-repeat">
   <fo:block
       space-before="2in"
       font-size="20pt"
       font-weight="bold"
       text-align="center"
       padding-before="2in">
     <i18n:text key="toc"/>
   </fo:block>
   <fo:block
       line-height="20pt"
       margin-right="1.5in">
     <xsl:apply-templates select="tocEntry">
       <xsl:with-param name="level" select="1"/>
     </xsl:apply-templates>
   </fo:block>
   </fo:block-container>
 </xsl:template>

<xsl:template match="tocEntry">
<xsl:param name="level"/>
<fo:block
margin-left="1.5in"
text-align="justify"
text-align-last='justify'
start-indent="{$level - 1}cm">
<xsl:if test="tocEntry">
<xsl:attribute name="keep-with-next">always</xsl:attribute>
</xsl:if>
<xsl:if test="$level = 1">
<xsl:attribute name="font-size">14pt</xsl:attribute>
<xsl:attribute name="padding-before">.8cm</xsl:attribute>
</xsl:if>
<fo:basic-link internal-destination="{@targetId}">
<xsl:if test="@daisyNumber">
<xsl:value-of select="@daisyNumber"/><xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="caption/node()"/>
<fo:leader leader-pattern='rule' rule-style="dotted" rule-thickness="0.1mm"/>
<fo:page-number-citation ref-id="{@targetId}"/>
</fo:basic-link>
</fo:block>
<xsl:apply-templates select="tocEntry">
<xsl:with-param name="level" select="$level + 1"/>
</xsl:apply-templates>
</xsl:template>


I can provide a full set of files if that would be more useful. Any help is greatly appreciated.

Regards,

Robert Raleigh
Technical Communications
Fusion-io


CONFIDENTIAL


This document and attachments contain information from Fusion-io, Inc. which is confidential and/or legally privileged. The information is intended only for the use of the individual or entity named on this transmission. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking of any action in reliance on the contents of this emailed information is strictly prohibited, and that the documents should be returned to Fusion-io, Inc. immediately. In this regard, if you have received this email in error, please notify us by return email immediately.

Current Thread