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

Re: xsl-fo? center external-graphic and align start si

Subject: Re: xsl-fo? center external-graphic and align start side of caption with start side of external-graphic
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 08 Dec 2009 15:14:52 -0500
Re:  xsl-fo? center external-graphic and align start si
At 2009-12-08 11:13 -0800, Jack Bates wrote:
I want some XSL-FO external-graphics to appear centered on the page,
with captions underneath

If the external-graphic is wider than the caption, then I want the left
or start side of the caption to be aligned with the left or start side
of the external-graphic

If the caption is wider than the external-graphic, then I want the
caption to appear centered on the page (I want the external-graphic also
centered on the page, as before)

There are no pre-built semantics for such a choice as you have expressed. Remember there is no feedback loop from the formatter to your transformation, so you have to find a way of expressing any contingencies by using the already-available semantics in the formatting language.


And measuring formatted items, or comparing the lengths of formatted items, is not available for any kind of comparison.

To achieve this I wrapped both the external-graphic and the caption in
blocks, then wrapped both those blocks in one block, and set
text-align="center" on that block's container. Then I set
text-align="start" on the caption's block. I hoped this would have the
effect of centering the block containing both external-graphic and
caption, and aligning the caption against the start side of that block.

Nope ... because blocks are as wide as their closest ancestral reference area.


I'm thinking you will have to know the width of the graphic explicitly in advance, and then you can create a container of that width and flow your caption into that container.

Wait ... have you tried centring a border-less table with auto-width? Put both blocks into a single table cell in a single row. The XSL-FO default for table-width is an automatic calculation made by the formatter, so hopefully it will be as tight as either the graphic or the caption but no bigger. Then, the way one centres a table with XSL-FO is to put it in a table-and-caption and use text-align= (which is the standard way to do inline-progression-direction centring) on the table-and-caption to align the child table. You typically then need another text-align= on the table to reset the alignment for the table cells (unless you want them centred as well).

That might get you closer to what you want.

I hope this helps.

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

--
XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19
Vote for your XML training:   http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

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.