[xsl] XSL-FO: page-breaking with all block-containers having absolute-position="fixed"

Subject: [xsl] XSL-FO: page-breaking with all block-containers having absolute-position="fixed"
From: "Kyle Partridge" <kpartridge@xxxxxxxxxxxx>
Date: Wed, 25 Feb 2004 16:47:35 -0500

I've got an xml document that I'm trying to process into xsl-fo.  (For
those of you who have helped me in the past, thanks again - and yes,
it's the same document!)  (The main portion of) the xml document is laid
out like the below segment.  Note that each attribute on the region
elements represents a numerical measurement in pts that is supposed to
represent the fixed, absolute-positioning of the region.   

	<region left="36" top="14.25" width="120.75" height="12"
align-x="36" align-y="24">
	   <text use-page-width="false" push-down="false"
		<p style="Normal">Area 1: this is a text region.</p>
	<region left="480" top="26.25" width="225" height="60"
align-x="480" align-y="36">
	   <text use-page-width="false" push-down="false"
	   	<p style="Normal">Region - might be page 3 now.
Curiously,<br/> 		 the page break I inserted on the first
page seems to be<br/>
		 influencing the height of THIS page, as well I
		 know what's up with that, but sadly, I have to
		 the behavior if I can.</p>
	<region left="36" top="44.25" width="329.25" height="12"
align-x="36" align-y="54">
	   <text use-page-width="false" push-down="false"
		<p style="Normal">Area 2: another text region.</p>
	<region left="0" top="216" width="6000" height="6" align-x="0"
	<region left="42" top="314.25" width="350.25" height="12"
align-x="42" align-y="324">
	   <text use-page-width="false" push-down="false"
		<p style="Indent">Here is an indent styled item. It
		really be on page 2.</p>
	<region left="498" top="482.25" width="171.75" height="60"
align-x="498" align-y="492">
	   <text use-page-width="false" push-down="false"
		<p style="Normal">Here's another region.<sp
count="2"/>This region is</p>
		<p style="Normal">on some other page - given the 8.5
		<p style="Normal">11 inch page layout currently in use.
		<p style="Normal">think it might be considered page 4,
		<p style="Normal">I'm not too sure how this works!</p>
	<region left="96" top="590.25" width="270.75" height="12"
align-x="96" align-y="600">
	   <text use-page-width="false" push-down="false"
		<p style="Normal">Something at the bottom of the page -
let's see what happens!!</p>

	So far, I'm rendering this document using fo:block-containers
with absolute-position="fixed" and transferring the coordinates of the
regions (in pts) from the xml into my fo document.  The trouble is, I
can't find a way to properly render page breaks in the document????  

	I don't like the idea of having to draw each page separately,
using always another fo:page-sequence and fo:flow...it would be great if
the regions could just cascade from one page to the next, behaving as-if
they were all on one continual page (except in the case of a hard page
break) because the region-coordinates in the xml (you may have noted!)
simply continue to grow and grow, regardless of the document's stated

	Let's say the page size (conveyed in the xml document) is height
= 792pts and width=612pts (an 8.5 x 11 page) - so I'm setting this page
size on the fo:simple-page-master, like so:

<fo:simple-page-master master-name="worksheet" page-height="792pt"

	Then I've got my fo:block-containers - I convert each to move it
away from the page edge(s) (margins are specified in the xml as 86.4pts
each, top, left, right, and bottom)...but as you can see from the region
attributes in the xml snippet above, **the region sizes just continue to
grow, regardless of any hard page breaks**.  So in the case of a hard
page break, regions prior to the break would have positioning
coordinates equal to the existing position coordinates on the region
element, but regions AFTER the break would have top and bottom
positioning coordinates equal to the page-height minus the top and
bottom coordinate??? Yuck.

	I hope this is making some sense, and that someone can give me
some advice on a *better way* to do this!  The rendered results are so
far excellent, but the coding methods seem to me to leave a lot to be
desired!  I've included my existing region template below (without any
page-break handling), for those who want to see that.

Many thanks in advance for any advice!

<xsl:template match="ws:region">
<xsl:variable name="top_add" select="//ws:pageModel//ws:margins/@top"/>
<xsl:variable name="left_add"
<xsl:element name="fo:block-container">
	<!-- *** absolute-position *** -->
	<xsl:attribute name="absolute-position">
	<!-- *** top *** -->
	<xsl:attribute name="top">
		<xsl:value-of select="number(@top)+$top_add"/>
		<xsl:value-of select="$units"/>
	<!-- *** left *** -->
	<xsl:attribute name="left">
		<xsl:value-of select="number(@left)+$left_add"/>
		<xsl:value-of select="$units"/>
	<xsl:variable name="baseline-dev">
		<!-- this won't work in all cases, need to refine -->
select="(count(ws:text/ws:p[@style='List'])*3) +
	<!-- *** height *** -->
	<xsl:attribute name="height">
	<xsl:value-of select="number(@height)+3+$baseline-dev"/>
	<xsl:value-of select="$units"/>
	<!-- *** width *** -->
	<xsl:attribute name="width">
		<xsl:value-of select="@width"/>
		<xsl:value-of select="$units"/>
	<!-- *** inner block *** -->
	<xsl:element name="fo:block">


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

Current Thread