Bảng XSL-FO

XSL-FO sử dụng phần tử <fo:table-and-caption> để định nghĩa bảng.

Bảng XSL-FO

Mô hình bảng XSL-FO rất khác biệt so với mô hình bảng HTML.

Có chín loại đối tượng XSL-FO có thể được sử dụng để tạo bảng:

  • 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 sử dụng <fo:table-and-caption> để định nghĩa bảng. Nó chứa một <fo:table> và một tùy chọn <fo:caption> 元素。

Thành phần <fo:table> chứa:

  • tùy chọn <fo:table-column> thành phần
  • tùy chọn <fo:table-header> thành phần
  • <fo:table-body> thành phần
  • tùy chọn <fo:table-footer> thành phần

mỗi thành phần trong số này có thể có một hoặc nhiều <fo:table-row> thành phần, mà <fo:table-row> Sẽ có một hoặc nhiều thành phần <fo:table-cell> Thành phần:

<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">Xe</fo:block>
    </fo:table-cell>
    <fo:table-cell>
      <fo:block font-weight="bold">Giá</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>

Kết quả xuất của mã trên: