- From: G. Ken Holman <gkholman@CraneSoftwrights.com>
- Date: Sat, 26 Jul 2003 22:04:24 -0400
- To: www-xsl-fo@w3.org
At 2003-07-26 15:56 -0700, Mark Lundquist wrote:
>I have a bad feeling that this will turn out to be something I can't do,
>but here goes... :-/
I think you've got one chance at it, but it depends on the capabilities of
your processor.
>I have a block that needs to be centered within an enclosing block.
I'm assuming that you want to border this block, otherwise there would be
no worry for just centering your content and the fact that it was a block
in a block would be immaterial.
I'm also assuming your block is only one line long, because if it was
longer than one line long you would want to specify the width for wrapping
purposes.
These assumptions are not required for the description below, but I'm
trying to guess why you have your specific need.
>If I had any way of knowing what the width of the inner block was going to
>be, I could calculate start-indent and end-indent to "split the
>difference". The trouble is, I don't know the width of the inner block,
>because it's dependent on content.
You don't say how it is dependent ... but the width of blocks has to be
specified in order for the formatting to know how to control the wrapping
of long lines. This discussion came up earlier for rotated blocks.
However ... the one way I can give you what I think you are asking for is
to centre an auto-width table. You have to rely on the auto-width
algorithm as implemented by the processor to not wrap your lines, but as I
said I think your line is probably short.
<block space-before="5cm">This is another test.</block>
<table-and-caption text-align="center">
<table border="solid">
<table-body>
<table-cell>
<block>Here is text.</block>
</table-cell>
</table-body>
</table>
</table-and-caption>
<block space-before=".5cm">This is yet another test.</block>
<table-and-caption text-align="center">
<table border="solid">
<table-body>
<table-cell>
<block>Here is longer text.</block>
</table-cell>
</table-body>
</table>
</table-and-caption>
The default for table-layout= is "auto", but not all processors support
it. The way to centre a table is to put it in <table-and-caption> and use
text-align= in the <table-and-caption>.
The above fragment of FO works just fine in Antenna House XSL Formatter
giving you a bordered one-block line centred in the inline-progression
direction.
BTW, even if you aren't just dealing with text, or don't have the need for
borders, and you have an arbitrary block created by some other process in
your stylesheet and you just want to centre whatever is in that block
produced by the other process, the above will still work ... just put your
block in the one-cell table. Note that for brevity I'm using the
cell-based row-grouping strategy for the table row building, since it is
only one cell ... but it means I don't have to put in table-row.
I hope this helps.
....................... Ken
--
Upcoming hands-on courses: in-house corporate training available;
North America public: XSL-FO Aug 4,2003; XSLT/XPath Aug 12, 2003
G. Ken Holman mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
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-11-X Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners: http://XMLGuild.info
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/f/bc
Received on Saturday, 26 July 2003 22:04:41 UTC