Re: [xep-support] Built-in functions to know available width in area

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Fri May 29 2009 - 13:47:20 PDT

At 2009-05-29 11:54 -0700, Alejandro Masino wrote:
>I was wondering whether there is a way to know the available width in a
>page area through a built-in function or variable, or at least know the
>page dimensions at any time in a transformation sheet....

The processing model for XSLT/XSL-FO is that the transformation is
fully complete before the layout even begins. There is no feedback
loop from the formatting back to the transformation.

For example, if you are using Saxon for XSLT and XEP for XSL-FO,
Saxon is long finished before XEP lays out the XSL-FO instance.

>The problem I have is that I need to provide a solution for table
>alignment (@text-align[left|right|center] is not properly handled in
>table or table-and-caption elements) and need to know the exact width of
>the area where the table should be rendered (so I can properly set the
>width of the columns of the enclosing table I'm using to do the
>alignment) ;

You are correct that in XSL-FO a table is centred by using
text-align="center" on the table-and-caption element ... but when
that is not available you can centre a table of known width by
putting it in a bounding table that uses proportional width on the
side columns.

>I could
>do it calculating myself all the dimensions I set when defining the
>page, but as I have different page masters with different orientation...

The specification has no way of communicating this information
determined at layout time back to the transformation facility.

But if you know the width of your table and all you are worried about
is centring that table regardless of the page orientation and
dimension, that is easily accommodated by using the bounding table
and proportional widths on the side columns. And this works in XEP.

I hope the example below helps ... it will centre a 3" table
regardless of the page dimension and orientation.

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

<?xml version="1.0" encoding="US-ASCII"?><!--alejandro.fo-->
<root xmlns="http://www.w3.org/1999/XSL/Format"
       font-family="Times" font-size="20pt">

   <layout-master-set>
     <simple-page-master master-name="frame"
                         page-height="297mm" page-width="210mm"
                         margin-top="15mm" margin-bottom="15mm"
                         margin-left="15mm" margin-right="15mm">
       <region-body region-name="frame-body"/>
     </simple-page-master>
   </layout-master-set>

   <page-sequence master-reference="frame">
     <flow flow-name="frame-body" xmlns="http://www.w3.org/1999/XSL/Format">
       <block>This is a test of centring a table</block>
       <block>First, the table:</block>
       <table border="solid 1pt" width="3in">
         <table-body>
           <table-cell>
             <block>Hello world!</block>
           </table-cell>
         </table-body>
       </table>
       <block>Next, using text-align= per the spec:</block>
       <table-and-caption text-align="center">
         <table border="solid 1pt" width="3in">
           <table-body>
             <table-cell>
               <block>Hello world!</block>
             </table-cell>
           </table-body>
         </table>
       </table-and-caption>
       <block>Finally, using a bounding table:</block>
       <table width="100%" table-layout="fixed">
         <table-column column-width="proportional-column-width(1)"/>
         <table-column column-width="3in"/>
         <table-column column-width="proportional-column-width(1)"/>
         <table-body>
           <table-cell><block/></table-cell>
           <table-cell>
             <table border="solid 1pt" table-layout="auto" width="3in">
               <table-body>
                 <table-cell>
                   <block>Hello world!</block>
                 </table-cell>
               </table-body>
             </table>
           </table-cell>
           <table-cell><block/></table-cell>
         </table-body>
       </table>
     </flow>
   </page-sequence>
</root>

--
XSL-FO/XSLT/XQuery hands-on training - Los Angeles, USA 2009-06-08
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/f/
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@CraneSoftwrights.com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/f/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal
-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo@renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/terms-of-service.html
Received on Fri May 29 14:11:08 2009

This archive was generated by hypermail 2.1.8 : Fri May 29 2009 - 14:11:09 PDT