Item8991: Header-only table violates XHTML DTD

pencil
Priority: Low
Current State: Closed
Released In: 1.1.3
Target Release: patch
Applies To: Extension
Component: TablePlugin
Branches:
Reported By: MartinVonGagern
Waiting For:
Last Change By: KennethLavrsen
A table generated by the TablePlugin and containing only a header row will violate the XHTML DTD.

Example:

Name Phone

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 </thead></table>.

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 states:
<!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:
  1. Append a bogus table row, and style it invisible via CSS.
  2. 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.

-- MartinVonGagern - 08 May 2010

The first patch has problems somewhere around the colspan, but this second patch does work for me.

-- MartinVonGagern - 08 May 2010
 

ItemTemplate edit

Summary Header-only table violates XHTML DTD
ReportedBy MartinVonGagern
Codebase 1.1.2, trunk
SVN Range
AppliesTo Extension
Component TablePlugin
Priority Low
CurrentState Closed
WaitingFor
Checkins distro:f21d7d468081 distro:4f40da3ea3a7
TargetRelease patch
ReleasedIn 1.1.3
I Attachment Action Size Date Who Comment
Item8991a.patchpatch Item8991a.patch manage 1 K 08 May 2010 - 09:02 MartinVonGagern Untested attempt at a solution
Item8991b.patchpatch Item8991b.patch manage 1 K 08 May 2010 - 21:42 MartinVonGagern Working solution
Topic revision: r6 - 16 Apr 2011, KennethLavrsen
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy