xsl-list
[Top] [All Lists]

Re: [xsl] XSL-FO: Background text spanned on several table cells

2009-02-19 10:00:38
At 2009-02-19 14:26 +0000, Florent Georges wrote:
  Let's say I have a table with 5 columns, and a variable count
of rows.  For some rows, I would like to put a text in the
background, that is spanned over the first 3 columns.  For
instance with the following table:

    +-----+-----+-----+-----+-----+
    | aaa | bbb | ccc | ddd | eee |
    +-----+-----+-----+-----+-----+
    | 111 | 222 | 333 | 444 | 555 |
    +-----+-----+-----+-----+-----+
    | vvv | www | xxx | yyy | zzz |
    +-----+-----+-----+-----+-----+

  I would like to draw the text "[ DRAFT ]" in the background of
the cells 111, 222 and 333 (for instance, but that can happen in
any row, any number of times.)  The text has to be centered
vertically on the row and horizontally within the three cells.

  I don't have any concrete example because I don't know what
way to follow.  Would you have any clue?

The FO file below gives you the effect you want in both Antenna House and RenderX ... I'm confident you can generalize this algorithmically into what you want. One key, however, is your expectation of the cell heights ... I'm not sure you can achieve what you want with unspecified block-container maximum heights. You'll have to have rigid cell boundaries, I think, to get the desired effect.

Below I'm creating a spanned set of rows and columns for the area in draft, and in that single cell I'm laying down the "DRAFT" with a z-index="1" and then redrawing the desired table cells in a new table on top of "DRAFT" by using a z-index="2".

I hope this helps.

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

<?xml version="1.0" encoding="US-ASCII"?><!--florent.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 for Florent</block>
      <table table-layout="fixed">
        <table-column column-width="1in" number-columns-repeated="5"/>
        <table-body>
          <table-row block-progression-dimension=".5in"
                     display-align="center">
            <table-cell text-align="center"><block>aaa</block></table-cell>
            <table-cell text-align="center"><block>bbb</block></table-cell>
            <table-cell text-align="center"><block>ccc</block></table-cell>
            <table-cell text-align="center"><block>ddd</block></table-cell>
            <table-cell text-align="center"><block>eee</block></table-cell>
          </table-row>
          <table-row block-progression-dimension=".5in"
                     display-align="center">
            <table-cell number-columns-spanned="3">
              <block-container block-progression-dimension=".5in">
                <block-container absolute-position="absolute" z-index="1"
                                 text-align="center" display-align="center">
                  <block font-weight="bold" font-size="40pt" color="#cccccc">
                    [ Draft ]
                  </block>
                </block-container>
                <block-container absolute-position="absolute" z-index="2"
                                 display-align="center">
                  <table table-layout="fixed">
                    <table-column column-width="1in"
                                  number-columns-repeated="3"/>
                    <table-body>
<table-cell text-align="center"><block>111</block></table-cell> <table-cell text-align="center"><block>222</block></table-cell> <table-cell text-align="center"><block>333</block></table-cell>
                    </table-body>
                  </table>
                </block-container>
              </block-container>
            </table-cell>
            <table-cell text-align="center"><block>444</block></table-cell>
            <table-cell text-align="center"><block>555</block></table-cell>
          </table-row>
          <table-row block-progression-dimension=".5in"
                     display-align="center">
            <table-cell text-align="center"><block>vvv</block></table-cell>
            <table-cell text-align="center"><block>www</block></table-cell>
            <table-cell text-align="center"><block>xxx</block></table-cell>
            <table-cell text-align="center"><block>yyy</block></table-cell>
            <table-cell text-align="center"><block>zzz</block></table-cell>
          </table-row>
        </table-body>
      </table>
    </flow>
  </page-sequence>
</root>

--
Upcoming hands-on  XQuery, XSLT, UBL & code list training classes:
Brussels, BE 2009-03;  Prague, CZ 2009-03, http://www.xmlprague.cz
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(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--