Latest web development tutorials

XSL-FO Form

XSL-FO using <fo: table-and-caption> element to define form.


XSL-FO table (Tables)

XSL-FO table model with HTML table model is not completely different.

There are nine XSL-FO objects used to create the table:

  • fo: table-and-caption
  • fo: table
  • fo: table-caption
  • fo: table-column
  • fo: table-header
  • fo: table-footer
  • fo: table-body
  • fo: table-row
  • fo: table-cell

XSL-FO using<fo: table-and-caption > element to define form.It contains a<fo: table> and an optional <fo: caption>element.

<fo: table> element contains an optional<fo: table-column> element, an optional <fo: table-header>element, a<fo: table-body>element, an optional<fo: table -footer>element. Each of these elements may have one or more<fo: table-row> elements, <fo: table-row>will also have one or more<fo: table-cell>element:

<fo:table-and-caption>
<fo:table>
<fo:table-column column-width="25mm"/>
<fo:table-column column-width="25mm"/>

<fo:table-header>
<fo:table-row>
<fo:table-cell>
<fo:block font-weight="bold">Car</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-weight="bold">Price</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>

<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block>Volvo</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>$50000</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>SAAB</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>$48000</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>

</fo:table>
</fo:table-and-caption>

The output of the code above is as follows:

Car Price
Volvo $ 50000
SAAB $ 48,000