ตาราง XSL-FO

XSL-FO ใช้ส่วนประกอบ <fo:table-and-caption> มาคำนำเนียนตารางเลขา

ตาราง XSL-FO

โมเดลตาราง XSL-FO และโมเดลตาราง HTML ต่างกันมาก

มีเก้าชิ้น XSL-FO ที่ใช้สร้างตาราง:

  • 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 ใช้ <fo:table-and-caption> เพื่อคำนำเนียนตารางเลขาที่มี <fo:table> และอิงค์ไข่ <fo:caption> 元素。

<fo:table> องค์ประกอบประกอบด้วย:

  • เลือกใช้ได้ <fo:table-column> องค์ประกอบ
  • เลือกใช้ได้ <fo:table-header> องค์ประกอบ
  • <fo:table-body> องค์ประกอบ
  • เลือกใช้ได้ <fo:table-footer> องค์ประกอบ

และแต่ละองค์ประกอบนี้อาจมีองค์ประกอบหนึ่งหรือหลายองค์ประกอบ <fo:table-row> องค์ประกอบ <fo:table-row> จะมีองค์ประกอบหนึ่งหรือหลายองค์ประกอบ <fo:table-cell> องค์ประกอบ:

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

การออกเสียงของโค้ดดังกล่าว: