Tabela XSL-FO

XSL-FO używa elementu <fo:table-and-caption> do zdefiniowania tabeli.

Tabela XSL-FO

Model tabeli XSL-FO jest bardzo różny od modelu tabeli HTML.

Są dziewięć typów obiektów XSL-FO, które można użyć do tworzenia 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 używa <fo:table-and-caption> Element do zdefiniowania tabeli. Zawiera jedną <fo:table> oraz jeden opcjonalny <fo:caption> Element.

Element <fo:table> zawiera:

  • opcjonalnych <fo:table-column> elementów
  • opcjonalnych <fo:table-header> elementów
  • <fo:table-body> elementów
  • opcjonalnych <fo:table-footer> elementów

każdy z tych elementów może mieć jeden lub kilka <fo:table-row> elementów, a <fo:table-row> Będzie również zawierał jeden lub kilka <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">Samochód</fo:block>
    </fo:table-cell>
    <fo:table-cell>
      <fo:block font-weight="bold">Cena</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>

Wyjście kodu powyżej: