Tableau XSL-FO

XSL-FO utilise l'élément <fo:table-and-caption> pour définir un tableau.

Tableau XSL-FO

Le modèle de tableau XSL-FO est très différent du modèle de tableau HTML.

Il y a neuf types d'objets XSL-FO qui peuvent être utilisés pour créer des tableaux :

  • 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 utilise <fo:table-and-caption> Il contient un <fo:table> ainsi qu'un élément optionnel <fo:caption> Élément.

L'élément <fo:table> contient :

  • optionnel <fo:table-column> éléments
  • optionnel <fo:table-header> éléments
  • <fo:table-body> éléments
  • optionnel <fo:table-footer> éléments

chaque élément de ces éléments peut posséder un ou plusieurs <fo:table-row> éléments, et <fo:table-row> Il en comportera également un ou plusieurs <fo:table-cell> Élément :

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

Sortie du code ci-dessus :