W3C home > Mailing lists > Public > www-xsl-fo@w3.org > July 2003

Re: Center block within block?

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Sun, 27 Jul 2003 09:07:47 -0400
Message-Id: <5.2.0.9.0.20030727084128.02d3f628@pop.storm.ca>
To: www-xsl-fo@w3.org

At 2003-07-27 08:36 +0100, Dave Pawson wrote:
><fo:block space-before="5cm" border="thin solid black">This is text in the 
>outer space.
><fo:block text-align="center">and  centred  text.</fo:block>
>and more outer text
></fo:block>
>
>Seems simpler Ken.

If the original poster wanted the block to be as wide as the parent 
reference area, I *totally* agree.  But that wasn't what I gleaned from the 
wording that was used.

>  Why use of tables -

In your example above, the inner block is as wide as the outer block.  If 
you turned on the border of your inner block, the text would be centred, 
but the border around the text would be as wide as the outer block.  You 
wouldn't see "a centred block within a block", you would see three lines of 
text separated by horizontal rules ... try out the following in your test 
stylesheet to see (I've given you a namespace declaration so you should be 
able to paste it in without adding any namespace prefixes):

<block space-before="5cm" border="thin solid black"
        xmlns="http://www.w3.org/1999/XSL/Format">
   This is text in the outer space.
   <block text-align="center" border="thin solid black">
     and  centred  text.
   </block>
   and more outer text
</block>

>or am I missing something?

The original poster talked about setting the start and end indents in order 
to centre the "inner block" ... not the inside text.  A block perhaps 
generated elsewhere in the stylesheet might have a specific width, might be 
a set number of lines ... he didn't say ... for some reason, the original 
poster talked about this block as if it were a standalone construction in 
the transformation he is doing.

You'll note that I made some assumptions about what the original poster 
might have wanted based on his wording, and the solution I gave was to 
those assumptions.  The simple approach above would not have met those 
assumptions.

Now, take the above modified example with the border on the inner block, 
and put that into a table as I suggested, and try out the following in 
Antenna House XSL Formatter:

<block space-before="5cm" border="thin solid black"
        xmlns="http://www.w3.org/1999/XSL/Format">
   This is text in the outer space.
   <table-and-caption text-align="center">
     <table>
       <table-body>
         <table-cell>
           <block text-align="center" border="thin solid black">
             and  centred  text.
           </block>
         </table-cell>
       </table-body>
     </table>
   </table-and-caption>
   and more outer text
</block>

Now you will see what looks like "a block within a block" which is what I 
thought the original poster was asking for.  The presentation of the two 
examples above is quite different, and I thought he was looking for the latter.

Of course I apologize if I'm looking too deep for an answer, but I had just 
assumed he was treating a complex issue and not a simple issue.  But then, 
Dave, you *know* I always try to make things more complex than they really are.

:{)}

But, seriously, if I've assumed correctly about the "block within a block" 
comment, I think the table-based approach is the *only* way to get that 
desired effect, and this isn't a pedantic exercise.  Challenges like this 
come up when teaching XSL-FO to my students: they will come to class with 
specific formatting objectives in mind that they couldn't handle or figure 
out, and after going through all of the constructs we contrast the 
behaviours of edges and spaces and ancestral reference areas, etc. in an 
interactive part of the class.

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 Sunday, 27 July 2003 09:07:51 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:06:11 GMT