Tabel XSL-FO

XSL-FO menggunakan elemen <fo:table-and-caption> untuk mendefinisikan tabel.

Tabel XSL-FO

Model tabel XSL-FO sangat berbeda dengan model tabel HTML.

Ada sembilan jenis objek XSL-FO yang dapat digunakan untuk membuat tabel:

  • 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 menggunakan <fo:table-and-caption> untuk mendefinisikan tabel. Ini mengandung <fo:table> dan dapat memilih <fo:caption> Element.

Elemen <fo:table> mengandung:

  • opsional <fo:table-column> elemen
  • opsional <fo:table-header> elemen
  • <fo:table-body> elemen
  • opsional <fo:table-footer> elemen

setiap elemen dari mereka dapat memiliki satu atau lebih <fo:table-row> elemen, sementara <fo:table-row> dan akan disertai dengan satu atau lebih <fo:table-cell> Elemen:

<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">Mobil</fo:block>
    </fo:table-cell>
    <fo:table-cell>
      <fo:block font-weight="bold">Harga</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>

Output kode di atas: