Search code examples
xsltapache-fop

FOP is it possible to create a table with only <table-head> but no <table-body>?


I'm using FOP to transform HTML(embedded in XML) to PDF. The HTML snippet is like below:-

<table border="1" width="100%">
  <thead>
    <tr>
      <th>Name</th>
      <th>Value</th>
    </tr>
  </thead>
  <tbody/>
</table>

When I transform, I get this error:-

Caused by: org.apache.fop.fo.ValidationException: Error(Unknown location): fo:table-body i
s missing child elements.
Required Content Model: marker* (table-row+|table-cell+)

I got the similar error when removing the <tbody/> element:-

org.apache.fop.fo.ValidationException: Error(Unknown location): fo:table is missing child
elements.
Required Content Model: (marker*,table-column*,table-header?,table-footer?,table-body+)

Looks like table-body is required to fo:table and table-row is required to table-body. My question is:-

Is it possible to create a table with only table-header and without table-body or with an empty table-body?


Solution

  • You can ofcourse, the the following way:

    1. Create the <fo:table-body>
    2. Create <fo:table-cells even if it requires
    3. Put the border size zero and color white, or the color of your page background