I’m checking to see if anyone has an XSLT laying around that transforms HTML tables to CALS. I’ve found a lot of material on going the other way (CALS to HTML), but not from HTML. I thought somebody may have done this before so I don’t have to reinvent the wheel. I’m not looking for a complete solution. Just a starting point.
If I get far enough on my own, I’ll post it for future reference.
I’ve come up with a much simpler solution than what @Flack linked to:
There are two tricky points. First, a CALS table needs a tgroup/@cols attribute containing the number of columns. So we need to find the maximum number of cells in one row in the XHTML table – but we must heed colspan declarations so that a cell with colspan > 1 creates the right number of columns! The first template in my stylesheet does just that, based on @Tim C’s answer to the max cells per row problem.
Another problem is that for multi-column cells XHTML says “this cell is 3 columns wide” (colspan=”3″) while CALS will say “this cell starts in column 2 and ends in column 4” (namest=”2″ nameend=”4″). That transformation is done in the second template in the stylesheet.
The rest is indeed fairly straightforward. The stylesheet doesn’t deal with details like changing style=”width: 50%” into width=”50%” etc. but those are relatively common problems, I believe.