Inside Xslt

Creating Table Cells : <fo:table- cell >

Again matching table construction in HTML closely, you place data in a tables individual cells with the <fo:table-cell> element. Note that to specify the font and other characteristics of that content, you can enclose an <fo:block> element inside each <fo:table-cell> element. If you wish, you can connect a table cell with a particular table column using the column-number property, or even make a cell span multiple rows and columns , as in HTML tables.

You can use the following XSL-FO properties with the <fo:table-cell> element:

In tables.fo, I put both the labels for each column and table data in table cells this way:

<fo:table> <fo:table-column column-width="30mm"/> <fo:table-column column-width="30mm"/> <fo:table-column column-width="30mm"/> <fo:table-column column-width="30mm"/> <fo:table-column column-width="30mm"/> <fo:table-column column-width="30mm"/> <fo:table-body> <fo:table-row> <fo:table-cell border-width="0.5mm"> <fo:block font-weight="bold" font-size="18pt"> Name </fo:block> </fo:table-cell> <fo:table-cell border-width="0.5mm"> <fo:block font-weight="bold" font-size="18pt"> </fo:block> Mass </fo:table-cell> <fo:table-cell border-width="0.5mm"> <fo:block font-weight="bold" font-size="18pt"> Day </fo:block> </fo:table-cell> <fo:table-cell border-width="0.5mm"> <fo:block font-weight="bold" font-size="18pt"> Radius </fo:block> </fo:table-cell> <fo:table-cell border-width='0.5mm"> <fo:block font-weight="bold" font-size="18pt"> Density </fo:block> </fo:table-cell> <fo:table-cell border-width="0.5mm"> <fo:block font-weight="bold" font-size="18pt"> Distance </fo:block> </fo:table-cell> </fo:table-row> <fo:table-row> <fo:table-cell border-width="0.5mm"> <fo:block font-size="18pt">Mercury</fo:block> </fo:table-cell> <fo:table-cell border-width="0.5mm"> <fo:block font-size="18pt">.0553</fo:block> </fo:table-cell> <fo:table-cell border-width="0.5mm"> <fo:block font-size="18pt">58.65</fo:block> </fo:table-cell> <fo:table-cell border-width="0.5mm"> <fo:block font-size="18pt">1516</fo:block> </fo:table-cell> <fo:table-cell border-width="0.5mm"> <fo:block font-size="18pt">.983</fo:block> </fo:table-cell> <fo:table-cell border-width="0.5mm"> <fo:block font-size="18pt">43.4</fo:block> </fo:table-cell> </fo:table-row> . . . </fo:table-body> </fo:table>

And thats itthe result appears in Figure 11.2, where you see the fully formatted table as created by the fop processor. Now youve learned to create tables with XSL formatting objects.

Theres a lot more to XSL-FO, of course. The next chapter takes a look at working with lists, positioning, columns, page sequences, and more.

Категории