Item8991: Header-only table violates XHTML DTD
A table generated by the TablePlugin
and containing only a header row will violate the XHTML DTD.
You can check this example e.g. using the W3C HTML Validator
. There you'll likely see an error message like this: end tag for "table" which is not finished
This kind of stub table is particularly useful in a wiki, where you want to specify the columns up front, and different editors to provide data rows at a later point ion time. You wouldn't want the layout of the header to change depending on whether there are data rows or not.
Unfortunately the XHTML 1.0 Transitional DTD
<!ELEMENT table (caption?, (col*|colgroup*), thead?, tfoot?, (tbody+|tr+))>
<!ELEMENT tbody (tr)+>
So you can't have a table with header but no body, and you can't have a table body without rows.
I can imagine two possible solutions:
- Append a bogus table row, and style it invisible via CSS.
- If there is no body, omit the thead tag and place stuff directly into table rows. Might break some skins.
This seems to be the location in TablePlugin
source code where the tbody gets omitted:
emitTable in Core.pm
I've written a patch
trying to address this issue. But as I don't have a Foswiki setup under my control, I haven't given it any testing whatsoever. Please test, tweak as necessary, and consider for inclusion.
- 08 May 2010
The first patch has problems somewhere around the colspan, but this second patch
does work for me.
- 08 May 2010