Tablas de XSL-FO

XSL-FO utiliza el elemento <fo:table-and-caption> para definir la tabla.

Tablas de XSL-FO

El modelo de tabla de XSL-FO es muy diferente del modelo de tabla HTML.

Hay nueve tipos de objetos XSL-FO que se pueden usar para crear tablas:

  • 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 utiliza <fo:table-and-caption> definir la tabla. Contiene un <fo:table> y un elemento opcional <fo:caption> Elemento.

El elemento <fo:table> contiene:

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

cada uno de estos elementos puede tener uno o más <fo:table-row> elementos, y <fo:table-row> También llevará uno o más <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">Coche</fo:block>
    </fo:table-cell>
    <fo:table-cell>
      <fo:block font-weight="bold">Precio</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>

Salida del código anterior: