How to use XSL-FO Table in XML

In this articles i am going to explain about XSL-FO Table in XML
  • 2247

XSL-FO Tables in XML

  • The XSL-FO table model is not very different from the HTML table model.

  • XSL-FO supports an own table structure.

  • XSL-FO Tables structure is neither identical with the traditional CALS table structure nor with the HTML table structure.

  •  XSL-FO Tables is very suitable in order to take both table models as initial point for the typographical implementation.

  • The XSL-FO table concept is especially easy to use for the table setting

 There are nine elements and numerous attributes are available.

  • <fo:table> is the central (the top) and obligatory element for generating a table.

  • <fo:table-body> contains the tabular content of the table which consists of rows and cells

  • <fo:table-column> allows the pre-specification of various characteristics for the columns of the table.

  • <fo:table-and-caption>: If the table has a headline or a caption, this element is the top of the table.

  • <fo:table-caption> incorporates the headline or caption of a table which has top element.

  • <fo:table-row> determines the content and the characteristics of the table rows.

  • <fo:table-cell> determines the content and the characteristics of the table cells.

  • <fo:table-header> generates the header of the table which is automatically repeated if a page break occurs.

  • <fo:table-footer> generates the footer of a table which is automatically repeated if a page break occurs.

For the start a simpe table example

<?xml version="1.0" encoding="utf-8"?>

<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">Employee No</fo:block>

        </fo:table-cell>

        <fo:table-cell>

          <fo:block font-weight="bold">Name</fo:block>

        </fo:table-cell>

      </fo:table-row>

    </fo:table-header>

    <fo:table-body>

      <fo:table-row>

        <fo:table-cell>

          <fo:block>101</fo:block>

        </fo:table-cell>

        <fo:table-cell>

          <fo:block>Dinesh</fo:block>

        </fo:table-cell>

      </fo:table-row>

      <fo:table-row>

        <fo:table-cell>

          <fo:block>102</fo:block>

        </fo:table-cell>

        <fo:table-cell>

          <fo:block>Manish</fo:block>

        </fo:table-cell>

      </fo:table-row>

    </fo:table-body>

  </fo:table>

</fo:table-and-caption>

 

The output from the code above would be something like this

 

Employee No

Name

101

Dinesh

102

Manish

Further Readings

You may also want to read these related articles

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

 

© 2020 DotNetHeaven. All rights reserved.