Re: [xsl] absolute position fo:block to attain magazine like layout

Subject: Re: [xsl] absolute position fo:block to attain magazine like layout
From: "W. Eliot Kimber" <eliot@xxxxxxxxxx>
Date: Wed, 13 Nov 2002 08:14:37 -0600
G. Ken Holman wrote:
> At 2002-11-12 10:50 -0600, W. Eliot Kimber wrote:

>> It just occurred to me that you could possibly fake this if you know
>> the  exact geometry of everything:
[...]
> XSL-FO 1.0 doesn't have any synchronization constructs or ways to
> determine how far down a column one has been, in order to position the
> side float.
>
> At least I'm pretty sure it cannot be done, but, Eliot, you've managed
> magic in the past.

Included below is one solution that works with XSL Formatter (but not
with XEP--it isn't doing the first-column end-ward side float and I
don't know why not--the XEP docs indicate that side floats are
supported; also, XEP positions absolutely positioned blocks relative to
the page, not the containing refenence area--this is a documented
restriction, so I would have to calculate its offset differently for
XEP). I think this example is 100% correct WRT to the FO spec, but it's
always possible I'm inadvertantly taking advantage of a bug or relaxed
constraint of a particular implementation.

The restriction on this approach is that you have to be able to
explicitly start both columns--this obviously won't satisfy the
requirement to do this in the middle of an arbitrarily flowed column
sequence. But I think that it could satisfy the start-page sequence use
case. Also, I don't think you'd be able to achieve the same effect at
the bottom of a column (not without column-based after floats).

I've also been thinking about the posibility of applying a two-layer
approach to this type of layout problem, where you use a second XML
document to bind presentation-specific information to more generic
content and then combine them at XSLT time. For example, you could have
a separate layer that links to the paragraphs that need to start new
columns in order to be able to "synchronize" the two columns in order to
anchor the floats needed to achieve the effect in my example above. This
second layer could also include the data needed to populate the
decorative elements, such as the overlayed block in my sample. But I
haven't really thought this out so I don't know if it's actually
practical or useful. I know another intriguing idea was posted here or
in one of the other FO-related forums not too long ago, although I
haven't had a chance to follow up on that idea yet.

Of course, it might be just as easy to add format tweaking attributes to
the elements in question. There's something to be said for by-hand
two-pass format tuning--it's cheap, it's easy, and it does work (and
it's been SOP for word processing software for more than a decade).

Cheers,

Eliot

FO sample:

<?xml version="1.0"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";
font-family="Helvetica" font-size="12pt" line-height="120%" xml:lang="en">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="base-page" page-height="11in"
page-width="8.5in">
       <fo:region-body margin-top="2in" margin-left="0.5in"
margin-right="0.5in"/>
     </fo:simple-page-master>
     <fo:simple-page-master master-name="first-page" page-height="11in"
page-width="8.5in">
       <fo:region-before extent="2in"/>
       <fo:region-body margin-top="3in" margin-left="0.5in"
margin-right="0.5in" column-count="2" column-gap="0.25in"/>
     </fo:simple-page-master>
   </fo:layout-master-set>
   <fo:page-sequence master-reference="first-page">
     <fo:flow flow-name="xsl-region-body">
       <fo:block border-width="1pt"
           border-style="solid"
           border-color="blue">
         <fo:float float="end">
           <fo:block-container
             background-color="yellow"
             block-progression-dimension="3in - 1.5in"
             inline-progression-dimension="(7.5in div 4) - (0.25in div 2)"
           ></fo:block-container>
         </fo:float>
         <fo:block
             intrusion-displace="line"
             text-align-last="justify"
           ><fo:leader
             font-weight="bold"
             leader-pattern="use-content"
             leader-length="100%">Column 1 </fo:leader>
         </fo:block>
         <fo:block>Test of the ability to create an absolutely
positioned block
in the middle of two columns that appears to intrude into
both columns.</fo:block>
         <fo:block space-before="12pt">The areas generated by the
fo:block-container
formatting object have a value of "true" for the
is-referencearea.</fo:block>
         <fo:block space-before="12pt">The size of the viewport-area and
the
reference-area has to be fixed in the inline-progression-direction. It
must be specified unless the inline-progression-direction is parallel to
the inline-progression-direction of
the reference-area into which the areas generated by this flow object
are placed.
       </fo:block>
       </fo:block>
       <fo:block
           break-before="column"
           border-width="1pt"
           border-style="solid"
           border-color="green">
         <fo:float float="start">
           <fo:block-container
             background-color="yellow"
             block-progression-dimension="3in - 1.5in"
             inline-progression-dimension="(7.5in div 4) - (0.25in div 2)"
             margin-right="0"
             padding-end="10pt"
           ></fo:block-container>
         </fo:float>
         <fo:block>
           <fo:leader font-weight="bold" leader-pattern="use-content"
leader-length="100%">Column 2 </fo:leader>
         </fo:block>
         <fo:block space-before="12pt">The fo:block-container flow
object is used to generate a block-level reference-area, typically
containing
text blocks with a different writing-mode. In addition, it can also be
used with a different referenceorientation
to rotate its content.</fo:block>
         <fo:block space-before="12pt">The fo:block-container formatting
object generates one or more viewport/reference pairs. The fo:blockcontainer
returns these areas and any page-level-out-of-line areas returned by the
children of the fo:blockcontainer.</fo:block>
       </fo:block>
       <fo:block-container
           z-index="100"
           border-width="4pt"
           border-style="inset"
           border-color="black"
           block-progression-dimension="3in"
           inline-progression-dimension="7.5in div 2"
           display-align="center"
           text-align="center"
           absolute-position="absolute"
           left="(-7.5in div 4) - (0.25in div 2)"
           top="-1.5in"
           background-color="purple"
       ><fo:block
           font-weight="bold"
           font-size="36pt"
           color="white"
           line-height="120%"
         >Center treatment</fo:block>
       </fo:block-container>
     </fo:flow>
   </fo:page-sequence>
</fo:root>
--
W. Eliot Kimber, eliot@xxxxxxxxxx
Consultant, ISOGEN International

1016 La Posada Dr., Suite 240
Austin, TX  78752 Phone: 512.656.4139



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


Current Thread