[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xsl:fo - keeps and breaks problem..

Subject: Re: xsl:fo - keeps and breaks problem..
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 12 Sep 2002 18:18:52 +0200
fo keep together problem
At 2002-09-12 09:08 +0100, Andy Joslin wrote:
some nodes have nested foo's inside them...

<foo type="a" name="Fooey">
      <foo type="x" name="FooChild"/>
      <foo type="y" name="FooChild2"/>
</foo>

So far I've written a single template match for the foo element that
returns a fo:block (of full page width) for each match and calls itself
if it has any foo children, thereby producing nested fo:blocks where
appropriate..

The problem that I'm having is when trying to prevent any one foo result
from splitting over two pages. I'd like to keep all the contents of one
foo match together (ignore the nested ones for now); so either encourage
it to keep on one page or break and go to the next.

Have you tried putting in your one template rule the following test:


  <xsl:if test="not(parent::foo)">
    <xsl:attribute name="keep-together">always</xsl:attribute>
  </xsl:if>

The above will only put the keep-together= on the "top level" foo elements, and will give an error if any one of them exceeds a page. Remember to not put this attribute on the literal result element within which you have the test, or if it is a child it will end up using that copy of the attribute node.

I wonder if you could probably get fancy and do the following:

  <xsl:attribute name="keep-together">
    <xsl:value-of select="count(ancestor-or-self::foo)"/>
  </xsl:attribute>

This will make your top level foo's keep together with a strength of 1, then if one doesn't fit on a page it flows normally on the page but its children retain their strength of 2 and they, in turn, stay together on a page unless one of them should be too long and not be able to fit, after which their children will have a strength of 3 to keep together.

I hope this helps.

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


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

G. Ken Holman               mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.        http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0  +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                     Definitive XSLT and XPath
ISBN 0-13-140374-5                             Definitive XSL-FO
ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
ISBN 1-894049-10-1             Practical Formatting Using XSL-FO
Next public training:           2002-09-13,18,19,30,10-03,12-08,
-                                                  2003-03-04,07


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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.