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] How to remove page breaks between articles in book


Hi Michael,
I thought about this some more and created a more general solution that does not require modifying the book template, and handles mixed content in a book. The book template does xsl:apply-templates on all of its children. I created one template that matches on the first article of a sequence and creates a fo:page-sequence for the set of articles. After processing its content, it applies templates in a new mode to the next element *if* it is an article. That template just processes its content without creating a fo:page-sequence, and then processes the next element if it is an article. This recursive processing stops when the next element is not an article. You have to use a new mode so that you can turn off the normal processing of those subsequent articles so they are not processed twice.


<!-- this template selects the first of a sequence of articles and
creates the fo:page-sequence for the sequence -->
<xsl:template match="d:article[not(preceding-sibling::*[1]/self::d:article)]">
 <xsl:variable name="id">
   <xsl:call-template name="object.id"/>
 </xsl:variable>

 <xsl:variable name="master-reference">
   <xsl:call-template name="select.pagemaster"/>
 </xsl:variable>

 <fo:page-sequence hyphenate="{$hyphenate}"
                   master-reference="{$master-reference}">
   <xsl:attribute name="language">
     <xsl:call-template name="l10n.language"/>
   </xsl:attribute>
   <xsl:attribute name="format">
     <xsl:call-template name="page.number.format">
       <xsl:with-param name="master-reference" select="$master-reference"/>
     </xsl:call-template>
   </xsl:attribute>
   <xsl:attribute name="initial-page-number">
     <xsl:call-template name="initial.page.number">
       <xsl:with-param name="master-reference" select="$master-reference"/>
     </xsl:call-template>
   </xsl:attribute>

   <xsl:attribute name="force-page-count">
     <xsl:call-template name="force.page.count">
       <xsl:with-param name="master-reference" select="$master-reference"/>
     </xsl:call-template>
   </xsl:attribute>

   <xsl:attribute name="hyphenation-character">
     <xsl:call-template name="gentext">
       <xsl:with-param name="key" select="'hyphenation-character'"/>
     </xsl:call-template>
   </xsl:attribute>
   <xsl:attribute name="hyphenation-push-character-count">
     <xsl:call-template name="gentext">
<xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
     </xsl:call-template>
   </xsl:attribute>
   <xsl:attribute name="hyphenation-remain-character-count">
     <xsl:call-template name="gentext">
<xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
     </xsl:call-template>
   </xsl:attribute>

   <xsl:apply-templates select="." mode="running.head.mode">
     <xsl:with-param name="master-reference" select="$master-reference"/>
   </xsl:apply-templates>

   <xsl:apply-templates select="." mode="running.foot.mode">
     <xsl:with-param name="master-reference" select="$master-reference"/>
   </xsl:apply-templates>

   <fo:flow flow-name="xsl-region-body">
     <xsl:call-template name="set.flow.properties">
       <xsl:with-param name="element" select="local-name(.)"/>
       <xsl:with-param name="master-reference" select="$master-reference"/>
     </xsl:call-template>

     <fo:block id="{$id}"
               xsl:use-attribute-sets="component.titlepage.properties">
       <xsl:call-template name="article.titlepage"/>
     </fo:block>

     <xsl:call-template name="make.component.tocs"/>

     <!-- this processes the content of this first article -->
     <xsl:apply-templates/>

     <!-- this processes the next article in the sequence in a new mode -->
     <xsl:apply-templates select="following-sibling::*[1][self::d:article]"
              mode="more.articles"/>
   </fo:flow>
 </fo:page-sequence>
</xsl:template>

<!-- this template turns off processing of a subsequent article in
normal mode so it is not processed twice -->
<xsl:template match="d:article[preceding-sibling::*[1]/self::d:article]"/>

<!-- This template processes subsequent articles without a page-sequence -->
<xsl:template match="d:article[preceding-sibling::*[1]/self::d:article]"
             mode="more.articles">
 <xsl:variable name="id">
   <xsl:call-template name="object.id"/>
 </xsl:variable>

 <fo:block id="{$id}"
           xsl:use-attribute-sets="component.titlepage.properties">
   <xsl:call-template name="article.titlepage"/>
 </fo:block>

 <xsl:call-template name="make.component.tocs"/>

 <!-- process the content of the current article -->
 <xsl:apply-templates/>

 <!-- process the next article in sequence in new mode -->
 <xsl:apply-templates select="following-sibling::*[1][self::d:article]"
                      mode="more.articles"/>
</xsl:template>

Let me know if any of this is unclear.

Bob Stayton
Sagehill Enterprises
bobs@sagehill.net

--------------------------------------------------
From: "Michael Broschinsky" <mikebroschinsky@mail.com>
Sent: Wednesday, March 20, 2013 4:44 PM
To: "Bob Stayton" <bobs@sagehill.net>; <docbook-apps@lists.oasis-open.org>
Subject: Re: [docbook-apps] How to remove page breaks between articles in book

Bob,

I think I will need your help on this. In spite of having used DocBook for some time now, the stock stylesheets have been most sufficient for my needs. I haven't yet really learned XSL.

So, I created a customization layer, my-customizations.xsl and copied into it the template match for d:book from fo/divisions.xsl (ver. 1.78.1) beginning with <xsl:template match="d:book"> and ending with <xsl:template match="d:book/d:titleabbrev"></xsl:template>.

Then I copied the d:article template from fo/component.xsl (ver. 1.78.1) beginning with <xsl:template match="d:article"> through <xsl:template match="d:article/d:titleabbrev"></xsl:template>.

I then removed the lines <fo:page-sequence hyphenate="{$hyphenate}" master-reference="{$master-reference}"> through the closing </fo:page-sequence>.

And then...

Well, I don't know what to do then

----- Original Message -----
From: Bob Stayton
Sent: 03/18/13 09:18 AM
To: Michael Broschinsky, docbook-apps@lists.oasis-open.org
Subject: Re: [docbook-apps] How to remove page breaks between articles in book

Hi Michael,
An XSL-FO output file is structured into a series of fo:page-sequences, each
with its own designation of a page-master to declare the page specs. The
default processing of article is to put each article in its own
fo:page-sequence. That always forces a page break between articles.

To prevent such page breaks, the XSL template matching on book in
fo/division.xsl would need to be customized. When it encounters a set of
articles, it should start a single fo:page-sequence and apply-templates to
all the articles inside that sequence. But since fo:page-sequences cannot
be nested, you would also need to customize the template for article in
fo/component.xsl to remove its fo:page-sequence.
[...snip...]




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