OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] Incorrect page sequence for TOC/Lot and preface pages withdouble-sided output


Hi Dave,

If you are seeing incorrect margins, then the problem is not in the templates you have 
customized, but in the selection of the page masters as pages are generated.  There is 
one more thing you need to do for eliminating the extra blank pages in page sequences. 
You need to customize the fo:page-sequence-master to remove the page-position="first" 
item, since the "first" page master's layout matches the "odd" page master layout, but 
that is not appropriate when the first page is even.  Here is the original 
fo:page-sequence-master for "lot" in the template named "setup.pagemasters" in 
fo/pagesetup.xsl:


    <fo:page-sequence-master master-name="lot">
      <fo:repeatable-page-master-alternatives>
        <fo:conditional-page-master-reference master-reference="blank"
                                              blank-or-not-blank="blank"/>
        <fo:conditional-page-master-reference master-reference="lot-first"
                                              page-position="first"/>
        <fo:conditional-page-master-reference master-reference="lot-odd"
                                              odd-or-even="odd"/>
        <fo:conditional-page-master-reference
                                              odd-or-even="even">
          <xsl:attribute name="master-reference">
            <xsl:choose>
              <xsl:when test="$double.sided != 0">lot-even</xsl:when>
              <xsl:otherwise>lot-odd</xsl:otherwise>
            </xsl:choose>
          </xsl:attribute>
        </fo:conditional-page-master-reference>
      </fo:repeatable-page-master-alternatives>
    </fo:page-sequence-master>

To customize this, your customization layer needs to have a template named 
"user.pagemasters" that contains a definition of a new fo:page-sequence-master that is 
the same as this one except it must have a new master-name and it must remove this 
element:

        <fo:conditional-page-master-reference master-reference="lot-first"
                                              page-position="first"/>

You can also remove the element for "blank", but it is not necessary because the 
no-force option prevents it from being used. With those gone, each page master is 
selected only by "odd" or "even", so when the first page is even it should get the 
even page master with those margins.

Then your customization layers needs to add a template named "select.user.pagemaster" 
to choose your new master-name for "lot".  See this reference for more details on 
custom page masters:

http://www.sagehill.net/docbookxsl/PageDesign.html


Bob Stayton
Sagehill Enterprises
bobs@sagehill.net


----- Original Message ----- 
From: redlettucemail
To: docbook-apps@lists.oasis-open.org
Sent: Sunday, April 10, 2011 1:42 AM
Subject: [docbook-apps] Incorrect page sequence for TOC/Lot and preface pages 
withdouble-sided output


I have used the workaround code below to delete blank pages, and renumber, so that 
there are no blank pages between the Table of contents and each of the lists of 
figures, tables and examples. The LOTs (and TOC) all appear on their separate pages, 
but when I set the document to double-sided output (which has different inner and 
outer margins) the LOT pages and the following Preface all appear with margins set up 
for recto (with a larger inner margin), and the page number in the footer is in the 
same position for all pages (it should alternate between left and right for subsequent 
pages). The output should alternate between recto and verso margins.

The first code below is the workaround to delete blank pages. The second is to specify 
page numbering on the LOT pages. I think I have narrowed down the problem to the first 
batch of code in the first example (by iteratively deleting each part of the code – 1 
and 2 – and transforming), but I can’t see how the workaround affects the page 
sequence for LOTs. Thanks very much.
=========================================


<!--Delete blank pages in LOTs and front matter (both 1 and 2 below are required
  code)-->
  <!--1. don't force pages to end on even-->
  <xsl:template name="force.page.count">
    <xsl:param name ="element" select = "local-name(.)"/>
    <xsl:param name = "master-reference" select="''"/>

    <xsl:choose>
      <xsl:when test = "starts-with($master-reference,
        'lot')" >no-force </xsl:when>
      <xsl:when test = "starts-with($master-reference,
        'front')"> no-force </xsl:when>
      <xsl:when test ="$element = 'preface'"> end-on-even</xsl:when>
      <!-- double-sided output -->
      <xsl:when test ="$double.sided != 0" > end-on-even</xsl:when> <!--  
end-on-even -->
      <!-- single-sided output -->
      <xsl:otherwise> no-force </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!--2. reset initial page number for deleted blank pages-->
  <xsl:template name="initial.page.number">
    <xsl:param name ="element" select = "local-name(.)"/>
    <xsl:param name = "master-reference" select="''"/>

    <!-- Select the first content that the stylesheet places
      after the TOC -->
    <xsl:variable name="first.book.content"
      select= "ancestor::d:book/*[
      not(self::d:title or
      self::d:subtitle or
      self::d:titleabbrev or
      self::d:bookinfo or
      self::d:info or
      self::d:dedication or
      self::d:preface or
      self::d:toc or
      self::d:lot)][1]"/>
    <xsl:choose>
      <!-- double-sided output -->
      <xsl:when test ="$double.sided != 0" >
        <xsl:choose>
          <xsl:when test="starts-with($master-reference,
            'lot')" >auto </xsl:when> <!-- OPTIONS: auto, auto-odd -->
          <xsl:when test="starts-with($master-reference,
            'front')"> auto </xsl:when>
          <xsl:when test="$element = 'preface'">auto </xsl:when>
          <xsl:when test="$element = 'toc'"> auto </xsl:when>
          <xsl:when test="$element = 'book'">1 </xsl:when>
          <!-- preface typically continues TOC roman numerals -->
          <!-- Change page.number.format if not -->
          <xsl:when test="$element = 'preface'">auto-odd </xsl:when>
          <xsl:when test="($element = 'dedication' or $element = 'article')
            and not(preceding::chapter
            or preceding::d:preface
            or preceding::d:appendix
            or preceding::d:article
            or preceding::d:dedication
            or parent::d:part
            or parent::d:reference)"> 1 </xsl:when>
          <xsl:when test="generate-id($first.book.content) =
            generate-id(.)"> 1 </xsl:when>
          <xsl:otherwise> auto-odd </xsl:otherwise>
        </xsl:choose>
      </xsl:when>

      <!-- single-sided output -->
      <xsl:otherwise>
        <xsl:choose>
          <xsl:when test="$element = 'toc'"> auto </xsl:when>
          <xsl:when test="$element = 'book'">1 </xsl:when>
          <xsl:when test="$element = 'preface'">auto </xsl:when>
          <xsl:when test="($element = 'dedication' or $element = 'article') and
            not(preceding::d:chapter
            or preceding::d:preface
            or preceding::d:appendix
            or preceding::d:article
            or preceding::d:dedication
            or parent::d:part
            or parent::d:reference)"> 1 </xsl:when>
          <xsl:when test="generate-id($first.book.content) =
            generate-id(.)"> 1 </xsl:when>
          <xsl:otherwise> auto </xsl:otherwise>
        </xsl:choose>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
====================================================
  <!--specify content for footer text-->
  <xsl:template name="footer.content">
    <xsl:param name ="pageclass" select ="''"/>
    <xsl:param name ="sequence" select ="''"/>
    <xsl:param name ="position" select ="''"/>
    <xsl:param name ="gentext-key" select ="''"/>

    <fo:block>
      <!-- pageclass can be: lot, front, body, back -->
      <!-- sequence can be: odd, even, first, blank -->
      <!-- position can be: left, center, right -->
      <xsl:choose>
        <xsl:when test="$pageclass = 'titlepage'">
           <!--nop; no footer on title pages-->
        </xsl:when>

        <xsl:when test="$pageclass = 'lot' or $pageclass = 'front'">
          <xsl:choose>

            <!-- if double-sided document -->
            <xsl:when test="$double.sided != 0 and ($sequence = 'odd' or
              $sequence = 'first')">
              <xsl:choose>
                <xsl:when test="$position = 'right'" >
                   <fo:page-number/>
                </xsl:when>
              </xsl:choose>
            </xsl:when>

            <xsl:when test="$double.sided != 0 and $sequence = 'even'">
              <xsl:choose>
                <xsl:when test="$position = 'left'" >
                  <fo:page-number/>
                </xsl:when>
              </xsl:choose>
            </xsl:when>

            <!-- if single-sided document -->
              <xsl:when test="$double.sided = 0 and $position = 'center'">
                <fo:page-number/>
              </xsl:when>

            <xsl:otherwise/>
          </xsl:choose>
        </xsl:when>

        <xsl:when test="$pageclass = 'body' or $pageclass = 'back' or $pageclass
          = 'index'">
        <!-- put page number on left for verso pages -->
          <xsl:choose>
            <xsl:when test="$double.sided != 0 and $sequence = 'even'
              and $position='left'">
              <fo:page-number/>
            </xsl:when>

            <!-- put page number on right for recto pages -->
            <xsl:when test="$double.sided != 0 and ($sequence = 'odd' or $sequence = 
'first')
              and $position='right'">
              <fo:page-number/>
            </xsl:when>

            <!-- put page number on blank pages -->
            <xsl:when test="$sequence='blank'">
              <xsl:choose>
                <xsl:when test="$double.sided != 0 and $position = 'left'">
                  <fo:page-number/>
                </xsl:when>
                <xsl:when test="$double.sided = 0 and $position = 'center'">
                  <fo:page-number/>
                </xsl:when>
                <xsl:otherwise>
                  <!-- nop -->
                </xsl:otherwise>
              </xsl:choose>
            </xsl:when>

            <!-- if single-sided document, put page number in centre for all pages -->
            <xsl:when test="$double.sided = 0 and $position='center'">
              <fo:page-number/>
            </xsl:when>
            <xsl:otherwise>
              <!-- put nothing in footer -->
            </xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        </xsl:choose>
    </fo:block>
  </xsl:template>

Dave Gardiner 



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]