Tabela XSL-FO

O XSL-FO usa o elemento <fo:table-and-caption> para definir a tabela.

Tabela XSL-FO

O modelo de tabela do XSL-FO é muito diferente do modelo de tabela do HTML.

Existem nove objetos XSL-FO que podem ser usados para criar tabelas:

  • 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

O XSL-FO usa <fo:table-and-caption> para definir a tabela. Ela contém um <fo:table> e um elemento opcional <fo:caption> Elemento.

O elemento <fo:table> contém:

  • Opcional <fo:table-column> elementos
  • Opcional <fo:table-header> elementos
  • <fo:table-body> elementos
  • Opcional <fo:table-footer> elementos

cada um desses elementos pode ter um ou mais <fo:table-row> elementos, e <fo:table-row> Também será acompanhado por um ou mais <fo:table-cell> Elemento:

<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">Carro</fo:block>
    </fo:table-cell>
    <fo:table-cell>
      <fo:block font-weight="bold">Preço</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>

Saída do código acima: