columns in xsl

Columns

1. Half page with multicolumn and the other half page without columns
2. newspaper layout with FOs
3. Spanning text across a two column page
4. Multi-column text
5. Two columns aligned at the end
6. One and two columns in single page?
7. How to balance columns
8. Balanced two column ending

1.

Half page with multicolumn and the other half page without columns

David Tolpin

No, currently it is not possible, because column-count is a property of fo:region-body, and there can be exactly one fo:region-body on a page. However, <fo:block span=all> may be used as a hack, but it is very difficult to position such blocks properly.

2.

newspaper layout with FOs

Arved Sandstrom

XSL 1.0 is heavily attuned to content-driven layout: one central body region and up to 4 peripheral regions per page master, page masters generally intended to select on rather unsophisticated conditions (first or last page, even/odd, etc), and most devastating for what you want: exactly _one_ flow per page-sequence.

You pretty much have to wait for XSL 2.0 to see layout-driven support. You can find papers dating back to '98, say (check out http://www.seyboldseminars.com/Events/sf98/transcripts/ETAPE_30.html, Stephen Deach's part near the end, for example), when the first XSL draft just came out, where the WG people are talking about the flow-map object that is only mentioned as an aside in the CR, and at that time they were also talking about multiple "content queues" per page sequence, switched into various regions by the flow-map. This all went away when reality set in. :-)

(For those who are curious about the difference, Deach has a useful paper, one URL for which is http://www.infoloom.com/gcaconfs/WEB/paris98/deach.HTM).

Ironically the issue may have been more with the spec...who was happy with what feature, in other words. Because N flows are about as simple to implement as one, and if you can properly handle 1-5 regions on each of a whole bunch of page-masters, you sure as heck can handle more than 5.

3.

Spanning text across a two column page

Ken Holman



>How can I span some text into 2 columns in a page context with a
>2-column layout?

By using the span="all" property on the blocks that you want to span on the page.

Note in XSL-FO 1.0 you can only span all of the columns or keep the width to the one column you are in.

4.

Multi-column text

Oleg Tkachenko




> I wanted to see if anyone has done something similar to this and 
> offer implementation suggestions. 
> In our DTD, we have a list type that allows the user to specify 
> the number of columns that they would like the list to format in 
> via an attribute on the list element. 
> The list then contains a series of 2 or more items that are just PCDATA.

> Basically, I need to count the number of items in the list and
> divide it by the number of columns they specified. 
> The items should then fill each column from top to bottom and then 
> any remainders would be placed in the last column.

> For example if the list contained 5 items and the user specified 
> they wanted 3 columns it would look like so:

> item 1 item 3 item 5    
> item 2 item 4

> Or if the list contained 5 items and the user specified 
> they wanted 2 columns it would look like so:

> item 1 item 4
> item 2 item 5
> item 3

Have you considered native declarative xsl-fo solution? Just declare how much columns you want on a region-body and let your favorite formatter to format your items appropriatively.

<fo:region-body column-count="{$user-defined-number-of-columns}" 
column-gap="10pt"/>

See 1. spec: xsl rec 2. example: "Multi-Column Regions" example at RenderX examples.

5.

Two columns aligned at the end

Ken Holman



>I want a 2 column composition to be bottom aligned.
>I mean that instead of being aligned on the top of each column, the last
>baselines should be aligned, not the top line.

Use display-align="after" on the <region-body> and all columns will be aligned to the after edge of the page ... which doesn't mean last baselines if you are using different font sizes, but if you are using the same font size then the baselines will coincidentally aligned on the last line.

6.

One and two columns in single page?

W. Eliot Kimber


> I've been trying to render a physical
> page in which the top half of the page has a single column
> of text (centered), and the bottom half has a dual column
> format.  The dual column text should then flow onto other
> body pages formatted entirely for dual column, which I handle
> with different page-masters.

To do this you have to define your fo:region-body to have two columns and then use span="all" on the blocks that should *not* be two columns.

Note that span= can only legally be specified on blocks that are direct children of fo:flow, which can complicate your block generation a little bit if you're in the habit of just blindly throwing container blocks around stuff whether they are really needed or not. Not all FO implementations enforce this rule, but some do.

To balance columns you follow a multi-column block by an empty, zero-height spanning block.

7.

How to balance columns

W. Eliot Kimber


> I have a two column book. I place a page break to start a new section
> and the page before the break does not balance the columns.

> Is this possible and how? I'm using Antenna House.

To balance columns issue an empty block with span="all":

<fo:block>Content in multiple columns</fo:block>
<fo:block span="all"><fo:leader leader-length="0pt" 
leader-pattern="space"/></fo:block>

The empty leader is to ensure that the block is honored as some processors will discard empty blocks.

This should work in all FO implementations that support multiple columns.

8.

Balanced two column ending

Colin Shapiro | Ken Holman

"Yes, include an empty spanned block at the end of your flow. The formatter will try to balance all of your columns on top of this empty block. Modulo keeps, breaks, widows, orphans, etc."

With XEP, you can omit the empty spanned block and just use a flow-section (one of the RenderX extensions). The columns inside of your flow-section will be balanced. See xep lists