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

From: G. Ken Holman <>
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"?><!>
<root xmlns=""
       font-family="Times" font-size="20pt">

     <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"/>

   <page-sequence master-reference="frame">
     <flow flow-name="frame-body" xmlns="">
       <block>This is a test of centring a table</block>
       <block>First, the table:</block>
       <table border="solid 1pt" width="3in">
             <block>Hello world!</block>
       <block>Next, using text-align= per the spec:</block>
       <table-and-caption text-align="center">
         <table border="solid 1pt" width="3in">
               <block>Hello world!</block>
       <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 border="solid 1pt" table-layout="auto" width="3in">
                   <block>Hello world!</block>

XSL-FO/XSLT/XQuery hands-on training - Los Angeles, USA 2009-06-08
Crane Softwrights Ltd.
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:
Video overview:
G. Ken Holman       
Male Cancer Awareness Nov'07
Legal business disclaimers:
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service
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