XHTML to DITA transformation ignores <th> tag in table

Post here questions and problems related to editing and publishing DITA content.
oxmand
Posts: 2
Joined: Tue Jun 23, 2020 4:14 pm

XHTML to DITA transformation ignores <th> tag in table

Post by oxmand »

Hi all,

I am trying to transform an XHTML table to DITA. The DITA output looks fine except for one thing: it omits the table header row. Here is the XHTML:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <link href="style.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
        <h2>Country Availability</h2>
        <h3>Australia</h3>
        <table>
            <tbody>
            	<tr>
                    <th>A</th>
                    <th>B</th>
                    <th>C</th>
                </tr>
                <tr>
                    <td>X</td>
                    <td>Y</td>
                    <td>Z</td>
                </tr>
            </tbody>
        </table>
    </body>
</html>
Any idea what the issue may be?
Thanks!
Radu
Posts: 9046
Joined: Fri Jul 09, 2004 5:18 pm

Re: XHTML to DITA transformation ignores <th> tag in table

Post by Radu »

Hi,

Ideally your table would have defined the header rows in a thead element like this:

Code: Select all

<table>
            <thead>
                <tr>
                    <th>A</th>
                    <th>B</th>
                    <th>C</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>X</td>
                    <td>Y</td>
                    <td>Z</td>
                </tr>
            </tbody>
        </table>
but indeed the XHTML to DITA conversion stylesheets should not lose content even with your current approach, we'll look into fixing them.
We have a free Oxygen add-on which is more maintained than the conversion stylesheets:
https://github.com/oxygenxml/oxygen-resources-converter

The add-on should convert the HTML to DITA without losing data, but it will still not mark that first row as a header row because it was not defined inside a <thead>.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
oxmand
Posts: 2
Joined: Tue Jun 23, 2020 4:14 pm

Re: XHTML to DITA transformation ignores <th> tag in table

Post by oxmand »

Thank you very much for your reply, Radu.
Post Reply