xsl-list
[Top] [All Lists]

Re: [FO] Conditional page break

2002-08-29 10:14:10
At 2002-08-29 09:46 -0700, Troy Ely wrote:
<letter>
    <section title="The Boarding House">
Mrs Mooney was a butcher's daughter. She was a woman who
was quite able to keep things to herself: a determined woman.
She had married her father's foreman, and opened a butcher's
shop near Spring Gardens. But as soon as his father-in-law was
dead Mr Mooney began to go to the devil. He drank, plundered
the till, ran headlong into debt. It was no use making him
take the pledge: he was sure to break out again a few days
after. By fighting his wife in the presence of customers and
by buying bad meat he ruined his business. One night he went
for his wife with the cleaver, and she had to sleep in a
neighbour's house.
    </section>
    <section title="After the Race">
The cars came scudding in towards Dublin, running evenly like
pellets in the groove of the Naas Road. At the crest of the
hill at Inchicore sightseers had gathered in clumps to watch
the cars careering homeward, and through this channel of
poverty and inaction the Continent sped its wealth and
industry. Now and again the clumps of people raised the
cheer of the gratefully oppressed. Their sympathy, however,
was for the blue cars - the cars of their friends, the French.
    </section>
    <signature>
James Joyce
    </signature>
    <CCs>
        <cc>Poe</cc>
        <cc>Maupassant</cc>
    </CCs>
    <docstamp>
JJ:1914:ss12345
    </docstamp>
</letter>
...
Currently, the app turns each element into an fo:block.
...
However, the business requires that the sig/cc/docstamp
combination never appear on a page by itself -- there must
always be at least 2 lines of text preceding it.

Is there a way to force a certain number of lines to the
next page, when the content of the block will fit within
a page?

The following stylesheet will produce the result you need when I test it with Antenna House, and I've kept the widow count at the default of 2.

Note that the signature is being kept with the last area of the preceding block and that pulls the minimum number of widow lines onto the page with the signature block.

I hope this helps.

............... Ken

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns="http://www.w3.org/1999/XSL/Format";
                version="1.0">

<xsl:template match="/">
<root xmlns="http://www.w3.org/1999/XSL/Format";
      font-family="Times" font-size="24pt">

  <layout-master-set>
    <simple-page-master master-name="frame"
                        page-height="297mm" page-width="210mm"
                        margin-top="15mm" margin-bottom="15mm"
                        margin-left="15mm" margin-right="15mm">
      <region-body region-name="frame-body"/>
    </simple-page-master>
  </layout-master-set>

  <page-sequence master-reference="frame">
    <flow flow-name="frame-body">
      <xsl:apply-templates/>
    </flow>
  </page-sequence>
</root>
</xsl:template>

<xsl:template match="section">
  <block space-after="1em"><xsl:apply-templates/></block>
</xsl:template>

<xsl:template match="signature|cc|docstamp">
  <block keep-with-previous="always"><xsl:apply-templates/></block>
</xsl:template>

</xsl:stylesheet>


--
Upcoming hands-on in-depth      Europe:         Sep 18-Sep 20,2002
XSLT/XPath and XSL-FO           North America:  Sep 30-Oct  4,2002
instructor-led deliveries       Japan:          Oct  7-Oct 11,2002

G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0  +1(613)489-0999 (Fax:-0995)
ISBN 0-13-065196-6                       Definitive XSLT and XPath
ISBN 1-894049-08-X   Practical Transformation Using XSLT and XPath
ISBN 1-894049-07-1               Practical Formatting Using XSL-FO
XSL/XML/DSSSL/SGML/OmniMark services, books (electronic, printed),
articles, training (instructor-live,Internet-live,web/CD,licensed)
Next public training:     2002-09-11,13,18,19,30,10-03,07,10,12-08


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>